Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Lighting problem with textures

This topic is 6114 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

My lighting is fine until I add textures. Then I get this effect where is kind of fades in and out. Anyone know the function that would cause this? I''ll post what I think is the relevant code. //lighting Variables float ambientLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; float diffuseLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; //Light Position float lightPosition[] = { 0.0f, 0.5f, 1.0f, 0.0f }; //Material Variables float matAmbient[] = { 0.2f, 0.2f, 0.2f, 0.0f }; float matDiff[] = { 0.0f, 0.0f, 0.0f, 1.0f }; float matSpecular[] = { 0.5f, 0.5f, 1.0f, 1.0f}; glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, matAmbient); glMaterialfv(GL_FRONT, GL_SPECULAR, matSpecular); glMaterialf(GL_FRONT, GL_SHININESS, 15.0f); glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glEnable(GL_LIGHT0); //texture sequence glEnable(GL_TEXTURE_2D); // enable 2D texturing // load our bitmap file bitmapData = LoadBitmapFile("usflag.bmp", &bitmapInfoHeader); glGenTextures(2, &textures[0]); // generate texture object glBindTexture(GL_TEXTURE_2D, textures[0]); // enable our texture object glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); // generate the texture image glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmapInfoHeader.biWidth, bitmapInfoHeader.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmapData);

Share this post

Link to post
Share on other sites

I had this same problem before. You need to make sure your normals are set usings glNormal3f(x,y,z);

Pop me an email

"In Windows, the only thing opposing safe mode would be... Unsafe mode....??"
- Me

"hmm, I know the slogans "will work for food" and "will work for free", but "will pay for work I do" seems just a bit sick "
- MirekCz

"I want to do this huge ass multiplayer first person space sim rpg strategy game!!"

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!