PDA

View Full Version : BG texture in ortho perspectives



10-18-2000, 06:05 AM
umm, maybe im not looking in the right spots for information, but is it possible to have a backround texture in an ortho perspective, or rather to make it appear as a backround?

cire
10-18-2000, 12:42 PM
Sure.

Just draw the background (textured) quad near the far clipping plane first. Then draw everything else after it.

You can even disable depth testing while drawing the background (which will make things faster) b/c you know it's supposed to be behind everything else.

Lemme know if you want an example ...

/ec

wazoo69
10-18-2000, 01:01 PM
Would you mind posting that sample, just to
make sure I'm doing it right?? I'm getting
some funky results... http://www.opengl.org/discussion_boards/ubb/frown.gif

thanks,
Wazoo

Bob
10-19-2000, 12:36 AM
For a background, you can also disable depthwrites, and not only depthtest. This way you save even more speed, and then you can draw the quad wherever you like http://www.opengl.org/discussion_boards/ubb/rolleyes.gif

Some code would probably look something like this.



glMatrixMode(GL_PROJECTION);
glLoadIdentity()
glOrtho(0, 1, 0, 1, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
glBegin(GL_QUAD);
glTexCoord2f(0,0);
glVertex2f(0,0);
glTexCoord2f(1,0);
glVertex2f(1,0);
glTexCoord2f(1,1);
glVertex2f(1,1);
glTexCoord2f(0,1);
glVertex2f(0,1);
glEnd();
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

Maybe you have to tweak the coordinates to get the texture right...


[This message has been edited by Bob (edited 10-19-2000).]

Kilam Malik
10-19-2000, 02:00 AM
To make it even more faster: You must only clear the depth buffer:

glClear(GL_DEPTH_BUFFER_BIT).

The color buffer is overwritten completely with every frame when you got a background texture.

Kilam.

Humus
10-19-2000, 05:41 AM
To speed things up even more draw the background with Z-testing disabled.
glDisable(GL_DEPTH_TEST);