2D clipping problem
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
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
What hardware/OS is this happening on?
OS 10.3.8 G5 tower with ATI 9600 card
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.
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.
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...
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
SDL & SGE Clipping Problems | merrill541 | 1 | 3,289 |
Sep 12, 2009 10:27 PM Last Post: merrill541 |
|
SDL Clipping Issue | Talyn | 14 | 8,223 |
Jul 15, 2008 11:20 AM Last Post: Talyn |
|
glCopyTexImage2D and clipping | james_the_bard | 3 | 7,013 |
Nov 14, 2005 03:16 PM Last Post: Skorche |
|
wierd...light clipping...or something [edited] | ghettotek | 2 | 3,861 |
Feb 11, 2003 07:10 AM Last Post: ghettotek |