Jump to content
  • Advertisement
Sign in to follow this  

OpenGL No Lighting on certain polygons

This topic is 5404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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(); }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!