   Quick and Easy Fade to Black effect
  Hi,I'm programming a simple fade-to-black effect, and I need some help getting it a little more efficient.Right now I'm just drawing a varying-opacity black quad that fills the screen.So here's my pseudo-code:pushMatrix()loadIdentity()setColor(0,0,0,alpha)drawQuad(0,0,window_width,window_height)popMatrix()Is there anyway to do it without having to push and pop the matrices?Thanks a lot for your help  -Cuppo   
  removing the push and pop matrices really isn't going to affect the speed of that code.   ;  It's not going to affect the speed?my actual code looks more like:matrixMode(PROJECTION)pushMatrix()loadIdentity()loadOrthoGraphic(0,1,0,1)matrixMode(MODE)pushMatrix()loadIdentity()setColor(0,0,0,alpha)drawQuad(0,0,1,1)popMatrix()matrixMode(PROJECTION)popMatrix()It seems like a lot of unneccesary code. Is there any opengl command to just fill the viewport with a color? I've tried using glClear() but that doesn't support blending.Thanks a lot  -Cuppo   ;Quote:Original post by CuppoJavaIt's not going to affect the speed?Have you profiled it? Until you have, then assume 'no'.   ;  I don't know much about OpenGL, but using Direct3D you can specify post transform type coordinates - that is, coordinates in screen space (X,Y,Z,W) to save tranforming them. Most video cards don't support clipping of these sorts of polygons so only use them for polygons on screen. Perhaps OpenGL has similar functionality - then you'd save the transform (and matrix setting) cost, but I'm afraid you're stuck with the fill-rate... on most consoles, stripping these according to VRAM page boundaries gives you substantial performance increases, but you can't get that info for PCs :-(;Quote:Original post by RompaI don't know much about OpenGL, but using Direct3D you can specify post transform type coordinates - that is, coordinates in screen space (X,Y,Z,W) to save tranforming them. Most video cards don't support clipping of these sorts of polygons so only use them for polygons on screen. Perhaps OpenGL has similar functionality - then you'd save the transform (and matrix setting) cost, but I'm afraid you're stuck with the fill-rate... on most consoles, stripping these according to VRAM page boundaries gives you substantial performance increases, but you can't get that info for PCs :-(In opengl too - you can setup a simple 2D quad and directly draw it over the 3D scene. Very basic opengl code should look like:  glBegin(GL_QUADS);    glVertex2f(top, left);    glVertex2f(top, right);    glVertex2f(bottom, right);    glVertex2f(left, left);  glEnd();Ouch. My GL is rusty. You also have to set the color and the transparency of the quad. Anyway, profiling is the way to know whether you code is slow or not. Regards,   ;Quote:Original post by Emmanuel DelogetQuote:Original post by RompaI don't know much about OpenGL, but using Direct3D you can specify post transform type coordinates - that is, coordinates in screen space (X,Y,Z,W) to save tranforming them. Most video cards don't support clipping of these sorts of polygons so only use them for polygons on screen. Perhaps OpenGL has similar functionality - then you'd save the transform (and matrix setting) cost, but I'm afraid you're stuck with the fill-rate... on most consoles, stripping these according to VRAM page boundaries gives you substantial performance increases, but you can't get that info for PCs :-(In opengl too - you can setup a simple 2D quad and directly draw it over the 3D scene. Very basic opengl code should look like:Thats not the same thing - those verts still pass though the matrix pipeline so you still need the ortho setup that the OP has. IIRC there isn't an equivilent of D3D's screen space coords.The matrix overhead will be epsilon anyway. Any any full game will have some kind of 2d drawing (HUD, menus, etc.) anyway which will need the 2d setup.   ;  Thanks for your replies.You're right about profiling it. I turned on and off the matrix popping and noticed no visible performance decrease. I'll just leave it alone until it becomes a problem then.  -Cuppo   