Question

I am using OpenGL with C++ (but without shaders and GLSL) and drawing spheres (the pool ball) and cylinders (the cue stick) using the glu library functions to draw them. I am using glBindTexture() to bind the texture and loading the texture using the SOIL library.

As you can see from the screenshots there are jagged edges to both the cylinder and the sphere. Calling the following glHint() How do I get rid of the jagged edges. The gluSphere() has 25 stacks and slices, and the gluCylinder() has 100 stacks and slices. Increasing the stacks and slices does not improve the image quality.

Using freeglut for the rest of the drawing

glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); //Smooth polygons
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //Best perspective corrections
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); //Smooth points
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); //Smooth lines

Screenshot

Was it helpful?

Solution

First of all your question is related to aliasing term, this is what is happen when tringles and some other primitives (these are very basic objects which create whole scene) are rasterized (based on geometric description some pixels on the screen are colored or not). Try to look for "How to turn on antialiasing" - here is many usefull informations about this and some related topics: http://www.glprogramming.com/red/chapter06.html. In your case it will be probably glEnable for GL_POLYGON_SMOOTH and GL_BLEND for sure. eg.

glEnable (GL_POLYGON_SMOOTH);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);

If you plan to use lines there will be GL_LINE_SMOOTH and GL_LINE_SMOOTH_HINT.

For future projects try to not use so complex models if they are far from viewer (making as many slices for sphere), this will cause loss of performance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top