Jake
2003.10.14, 08:43 PM
I am trying to add a nice little scoreboard with your club info and hole to my game, so I decided to first blend a quad (90% opaque, just enough so you can see the terrain behind it), and the write some text. It turns out because I am blending, I need to draw the frame before I add the quad, so, what I am trying to do is just reverse my translate and rotate statements , so I can position the quad in front of all the polygons. Now everything is working just fine, the quad is in the correct part of the screen, with the correct texture, BUT the lighting is all screwed up (when I look out, its REALLY dark, when I look down its 100% bright). I am really confused, I pinpointed it to these lines...
glTranslatef( -cx, -cy, -cz );
glRotatef(-yrot,0.0f,1.0f,0.0f);
glRotatef(-xrot,1.0f,0.0f,0.0f);
If I comment those out, it works, if I leave them in, it screws up. Heres the rest of the relevant code in my drawRect method ( I deleted my own game code, and just left the drawling code)
- (void) drawRect:(NSRect)rect
{
glClear( GL_DEPTH_BUFFER_BIT );
glLoadIdentity(); // Reset the current modelview matrix
glTranslatef(0.0f,0.0f,-4.0f);
glBindTexture( GL_TEXTURE_2D, 0);
glColor3f( 1.0f,0.2f,0.1f );
glDisable( GL_LIGHTING );
glRasterPos2f( 0 , 0 );
// buffer = [clubs[currentClub].name cString];
[ self glPrint:@"Active OpenGL Text With NeHe - "];
glEnable( GL_LIGHTING );
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glTranslatef( cx, cy, cz );
[golfer render: -time3 x: -clubx-3 y: -(cluby+0.18) z: -clubz xr: 0.0 yr: -yrot zr: zrot ];
[currentLevel renderLevel];
glTranslatef( -cx, -cy, -cz );
glRotatef(-yrot,0.0f,1.0f,0.0f);
glRotatef(-xrot,1.0f,0.0f,0.0f);
[ [ self openGLContext ] flushBuffer ];
}
Any ideas? I'm stumped.
glTranslatef( -cx, -cy, -cz );
glRotatef(-yrot,0.0f,1.0f,0.0f);
glRotatef(-xrot,1.0f,0.0f,0.0f);
If I comment those out, it works, if I leave them in, it screws up. Heres the rest of the relevant code in my drawRect method ( I deleted my own game code, and just left the drawling code)
- (void) drawRect:(NSRect)rect
{
glClear( GL_DEPTH_BUFFER_BIT );
glLoadIdentity(); // Reset the current modelview matrix
glTranslatef(0.0f,0.0f,-4.0f);
glBindTexture( GL_TEXTURE_2D, 0);
glColor3f( 1.0f,0.2f,0.1f );
glDisable( GL_LIGHTING );
glRasterPos2f( 0 , 0 );
// buffer = [clubs[currentClub].name cString];
[ self glPrint:@"Active OpenGL Text With NeHe - "];
glEnable( GL_LIGHTING );
glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f);
glTranslatef( cx, cy, cz );
[golfer render: -time3 x: -clubx-3 y: -(cluby+0.18) z: -clubz xr: 0.0 yr: -yrot zr: zrot ];
[currentLevel renderLevel];
glTranslatef( -cx, -cy, -cz );
glRotatef(-yrot,0.0f,1.0f,0.0f);
glRotatef(-xrot,1.0f,0.0f,0.0f);
[ [ self openGLContext ] flushBuffer ];
}
Any ideas? I'm stumped.