LWJGL Forum

Programming => OpenGL => Topic started by: bedelf on May 02, 2005, 03:18:48

Title: opengl cliprect
Post by: bedelf on May 02, 2005, 03:18:48
Ok, say I'm using opengl for 2D stuff only, just making quads with textures on them, and my window is setup like this:

       glMatrixMode(GL_PROJECTION);
       glLoadIdentity();
       glOrtho(0, width, height, 0, -1, 1);
       glViewport(0, 0, width, height);

Let's say my window is 800x600. I'm trying to find the easiest way to limit rendering to say a small box in the middle of the screen. Not nessesarily calculating what not to draw, but acually having it take no effect outside the box, with all my screen coordinates remaining the same. Similar, if not exactly like a java 2d clipRect() call. If part of the quad lands within the box, that part of the texture would show, the rest would do nothing.

I'm not having much luck searching around for this. Thanks in advance if anyone is up for this.
Title: opengl cliprect
Post by: princec on May 02, 2005, 10:16:26
glEnable(GL_SCISSOR_TEST);
glScissor(x,y,w,h);

Cas :)
Title: opengl cliprect
Post by: bedelf on May 04, 2005, 02:38:51
Part of me almost wants to believe that doesn't work so I don't feel stupid.

Almost.
Title: opengl cliprect
Post by: elias4444 on May 05, 2005, 17:26:04
Ah man... there goes all that stencil buffer stuff I was learning.  :P