Jump to content
  • Advertisement
Sign in to follow this  
juanmanuelsanchez

OpenGL Weird shadows in opengl

This topic is 4254 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 all. Im new to 3d programing, Im starting to build an engine the thing is that I got the model to load and the texture but I have problems to see it correctly. I have missing faces and shadows in the map, now the thing is that I know that those faces are there because I can see them when I move the camera. here is an example: Free Image Hosting at www.ImageShack.us This is are my initial settings in the engine:
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
   glShadeModel(GL_SMOOTH);                           // Enable Smooth Shading
   glClearColor(0.0, 0.0, 0.0, 0.0);              // Black Background
   glClearDepth(1.0f);                                // Depth Buffer Setup
   glDepthFunc(GL_LEQUAL);                            // The Type Of Depth Testing To Do
   glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
   glEnable(GL_COLOR_MATERIAL);						  glClearColor(0.0, 0.0, 0.0, 0.0);

Texturing:
  glGenTextures(1, (GLuint *) &texc->texnum);
     glBindTexture(GL_TEXTURE_2D, texc->texnum);
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
                  texc->image->xsize, texc->image->ysize, 0,
                  GL_RGB, GL_UNSIGNED_BYTE, texc->image->pixmap);
     GLint param = GL_LINEAR;// : GL_NEAREST;
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, param);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, param);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

What could be caussing it? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure what you mean by shadows, but the missing faces could be a culling issue. Try glDisable(GL_CULL_FACE); and if things start looking normal then your polys are being wrongly culled. This is usually because the winding order (order in which the vertices is specified) is wrong. Bad exporters or malformed models can cause this.

It could also be a depth buffer problem. You seem to have set the depth testing state ok, but your actual display might be lacking a depth buffer. Try glGet(GL_DEPTH_BUFFER_BITS) and if it returns 0 then have a close look at your display creation and check you're requesting a display with 16bits or greater depth buffer.

Share this post


Link to post
Share on other sites
It looks like there's no depth testing. Make sure you have a depth buffer and use glEnable( GL_DEPTH_TEST );

Share this post


Link to post
Share on other sites
great ! the glEnable( GL_DEPTH_TEST ) solved the missing faces problem, I still have the weird "shadow" (is the black thing you can see in the top right part of the image).

BTW are you sure the fnction glGet(GL_DEPTH_BUFFER_BITS) exist? I dont seem to get it work.

Share this post


Link to post
Share on other sites
Is it always affecting polys in the distance? It could be your far clip plane. Look for your projection matrix setup (probably gluPerspective) and push the far plane (last param) further out.

(I don't have my docs handy, I think the exact glGet command should be glGetIntegerv(GL_DEPTH_BITS, &outInt);

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.

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!