Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It sounds like what you want to do is similar to what you would when drawing a 2D HUD in a simple game, or just a background that is persistent. I'm no expert, but I did just that relatively recently. What you want to do is change the projection matrix to an orthographic projection, render your quad, and then switch back to whatever projection you had before. You can do this with the matrix stack, and it is completely independent of any camera.</p> <p>So, first:</p> <pre><code>glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); int w = glutGet(GLUT_WINDOW_WIDTH); int h = glutGet(GLUT_WINDOW_HEIGHT); gluOrtho2D(0, w, h, 0); </code></pre> <p>This pushes a new projection matrix onto the projection stack (I was using glut for this project, but it should translate to just normal OpenGL). Then, I get the window width and height, and use gluOrtho2D to set up my orthographic projection.</p> <p>Next:</p> <pre><code>glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Draw your quad here in screen coordinates </code></pre> <p>Here I just push a new, clean matrix onto the modelview. You may not need to do this.</p> <p>Lastly:</p> <pre><code>glPopMatrix() // Pops the matrix that we used to draw the quad glMatrixMode(GL_PROJECTION); glPopMatrix(); // Pops our orthographic projection matrix, which restores the old one glMatrixMode(GL_MODELVIEW); // Puts us back into GL_MODELVIEW since this is probably what you want </code></pre> <p>I hope this helps. As you can tell, it requires no use of the eye position. This is mainly because when we use a new orthographic projection that perfectly fits our window, this is irrelevant. This may not put your quad in the back however, if this is executed after the other draw calls.</p> <p>EDIT: Turning off depth testing and clearing the depth buffer could help as well, as Boojum suggests.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload