No Lighting on certain polygons
Hi. I'm writing a small game (Tetris-clone), but I'm having som problems with lighting on certain polygons. I've written a small class to handle fonts, which is based on a single texture that holds all characters. Writing a character on screen i simply a matter of drawing a Quad and then selecting the right texture coordinates. However, when I do this OpenGL refuses to apply lighting to these polygons. Other polygons work just fine. I can't find anything wrong with the code (other than not working or being finished). Ideas?
This is how a draw text and a textured polygon. The polygon is nicely lit and is working fine. The Font->DrawText(... method is further down the thread.
float t2 = LogoEval_1->Evaluate();
Logo_Light->SetLight(0, 0, 2,
t2, t2, t2,
t2/5.0f, t2/5.0f, t2/5.0f,
t2/8.0f, t2/8.0f, t2/8.0f);
Logo_Light->CallLight();
glPushMatrix();
glRotatef(180, 0, 1, 0);
glTranslatef(-7.0f, 4.5f, -12.0f);
Font->DrawText("One Player");
glTranslatef(0,-2,0);
Font->DrawText("Two Players");
glTranslatef(0,-2,0);
Font->DrawText("High Scores");
glTranslatef(0,-2,0);
Font->DrawText("About");
glPopMatrix();
Logo_Texture->Activate();
glPushMatrix();
glTranslatef(-0.5f,-0.5f, t2);
glBegin(GL_QUADS);
glTexCoord2i(1,0);
glVertex3f( 0, 0, 1);
glTexCoord2i(0,0);
glVertex3f( 1, 0, 1);
glTexCoord2i(0,1);
glVertex3f(1, 1, 1);
glTexCoord2i(1,1);
glVertex3f(0, 1, 1);
glEnd();
glPopMatrix();
____________________________________________________________
void PAP_Font::DrawText(const string Text){
if (_Texture == NULL) return;
_Texture->Activate();
glPushMatrix();
PAP_Character * c;
for (unsigned int i = 0; i < Text.size(); i++){
// Space character
if (Text == 32) glTranslatef(Characters[87 - 33]->Width, 0, 0);
if (Text < 33) continue;
c = Characters[Text - 33];
if (c == NULL) continue;
glBegin(GL_QUADS);
glNormal3f(0.0f,0.0f,1.0f);
glTexCoord2f(c->st_UpLeft_X, 1.0f - c->st_UpLeft_Y);
glVertex3f(0.0f, c->Height, 0.0f);
glTexCoord2f(c->st_DownRight_X, 1.0f - c->st_UpLeft_Y);
glVertex3f(c->Width, c->Height, 0.0f);
glTexCoord2f(c->st_DownRight_X, 1.0f - c->st_DownRight_Y);
glVertex3f(c->Width, 0.0f, 0.0f);
glTexCoord2f(c->st_UpLeft_X, 1.0f - c->st_DownRight_Y);
glVertex3f(0.0f, 0.0f, 0.0f);
glEnd();
glTranslatef(c->Width, 0.0f ,0.0f);
}
glPopMatrix();
}
Are you sure that the light is in front of the polygon? If this is not the case it won't be lit anyhow.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement