Question

I need to do smoothing in OpenGL. I find this code

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
glShadeModel(GL_SMOOTH); 

glHint(GL_POLYGON_SMOOTH_HINT, GL_FASTEST); 
glEnable(GL_POLYGON_SMOOTH);

glDisable( GL_DEPTH_TEST ); 
glEnable( GL_ALPHA_TEST ); 

Smoothing is work in this case, but i don't need transparency. I think this 2 rows are responsible for transparency:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

But if i delete this strings - smoothing doesn't work. What i need to leave for smoothing? I need only smoothing in my project, don't need blend...

Was it helpful?

Solution

Well, smoothing works using transparency, the edges are not either colored or not but they are ... well ... transparent. Take a look at these images:

smoothed line unsmoothed line

As you can see, the right line is not smoothed, it's pixels are either totally opaque or totally transparent. The left line is smoothed, it's outer pixels are transparent.

You may have a look into forcing Anti-Aliasing in your program, AA is a Hardware/Driver feature that just manages the smoothing of edges (and, depending on the type of AA, other things). Remember that this isn't a feature of OpenGL, but of the hardware, driver and operating system. In general you request something like AA when you create your OpenGL-Context.

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