Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

Cylinder artefact

This topic is 5166 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 am experiencing artefacts with cylinders in my code. Please look at the images attached and if you have any ideas let me know. Thanks.

Share this post

Link to post
Share on other sites
Looks like you don't have depth testing enabled. Try adding this command in your GL initialization routine:




Share this post

Link to post
Share on other sites
Thanks for the reply. I have enables depth testing. Here is my code.

glClearColor(0.0, 0.0, 0.0, 0.0); // Set the background color
glEnable(GL_DEPTH_TEST); // Enable depth testing.
glEnable(GL_CULL_FACE); // Enable culling.
glFrontFace(GL_CCW); // Enable counter clockwise culling.
glEnable(GL_LIGHTING); // Enable lighting.
float specularLight[] = {1.0f, 1.0f, 1.0f, 1.0f};
float diffuseLight[] = {1.0f, 1.0f, 1.0f, 1.0f};
float ambientLight[] = {0.0f, 0.0f, 0.0f, 1.0f};
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);

// Render RSRnodes
RSRnodes::iterator i;
for (i = nodes.begin(); i != nodes.end(); i++)
std::cout << "Currently rendering RSRnode with ID = " << i->second->getID() << std::endl << std::flush;

Share this post

Link to post
Share on other sites
It doesn't look like a no-depth-testing problem, since there is clearly some correctly depth sorted geometry (quite a bit of it in fact). Instead I would expect either a lack of depth buffer precision (16 bit) and/or too large a depth range. Assuming you're using plain Win32 calls, check your depth buffer precision by calling DescribePixelFormat(hdc, pixelFormat, &pfd); after you've called ChoosePixelFormat and print out the cDepthBits member of pfd. Also, what does your glFrustum/gluPerspective call look like?


Share this post

Link to post
Share on other sites
The z buffering was the problem. Thanks for your help guys.

I had

gluPerspective(45.0, (float)width / (float)height, 0.1, 1000.0);

just tweak the near and far plane and was fine.

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!