2D clipping problem

Member
Posts: 22
Joined: 2005.02
Post: #1
Hi, this is my code for creating a context for a 2D view:

glViewport(0, 0, window_width, window_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, window_width, window_height, 0, -1.0, 1.0);
glDisable(GL_DEPTH_TEST);

Everything looks ok, but every quad with negative coordinates will now be clipped away, which make objects disappear too soon when moving out of the window left or up.

I do it like this:

glBegin(GL_QUADS);
glVertex2s(rect.GetLeft(), rect.GetTop());
glVertex2s(rect.GetRight(), rect.GetTop());
glVertex2s(rect.GetRight(), rect.GetBottom());
glVertex2s(rect.GetLeft(), rect.GetBottom());
glEnd();

if rect.GetLeft() or rect.GetTop() is lower than 0 the whole rect won't be drawn even if parts of it should be visible!?! Why that?

-Sebastian
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
What hardware/OS is this happening on?
Quote this message in a reply
Member
Posts: 22
Joined: 2005.02
Post: #3
OS 10.3.8 G5 tower with ATI 9600 card
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
That definitely should not be happening. Are you sure your coordinates are valid all the time? (i.e. GetRight() returns a short, not an unsigned short?)

If the project is small, and doesn't depend on any weird 3rd party libraries, post a link to an archive and we'll take a look.
Quote this message in a reply
Member
Posts: 22
Joined: 2005.02
Post: #5
Thanks for this offer. I've figured it out... It was not in my drawing code. I've found out my draw function was not called at all when coordinates were negative...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SDL & SGE Clipping Problems merrill541 1 2,319 Sep 12, 2009 10:27 PM
Last Post: merrill541
  SDL Clipping Issue Talyn 14 4,692 Jul 15, 2008 11:20 AM
Last Post: Talyn
  glCopyTexImage2D and clipping james_the_bard 3 5,229 Nov 14, 2005 03:16 PM
Last Post: Skorche
  wierd...light clipping...or something [edited] ghettotek 2 2,658 Feb 11, 2003 07:10 AM
Last Post: ghettotek