I woulld like to know how to turn on aliasing and turn off aliasing after the aliasing is done in each frame.
What I am trying is to draw a compass card in to a predefined location that contains other images. I only want to blend the compass card and don’t want to affect any other images on the screen. But what I am getting is a diagonal line across the screen and the aliasing is affecting all other models on the screen.
//turn on the aliasing = during every frame
glShadeModel(GL_FLAT);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_POLYGON_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
First off all I think you have your terminology mixed up. I believe you realy mean anti-aliasing and not aliasing!
I see a few problems in your code.
[li]You load your ortho matrix into the modelview matrix and not into your projection matrix. While this will still work it is conventional to load a projection matrix (e.g. ortho matrix) into the GL_PROJECTION matrix.[]You just draw a square polygon that is larger than what you specified in your ortho call so it should fill the whole screen. Then you explicitly draw a diagonal line across the screen. This is why you get it! Not all implementation must support lines wider than 1 pixel. You specify 50. Make sure to check the maximum line with with glGetInteger.[]Using POLYGON_SMOOTH might cause seams between adjacent polygons (at least it did for me I think). You probably are better of initializing a multisampled OpenGL context and enabling/disable multisampling on demand.
thanks for the reply, I changed my ortho so that it is greater than the square. On the square I am drawing a diagonal line, when there is no aliasing, there is only one diagonal line, with anti-aliasing, there is one shaded line diagonaly from the other two corners, which I am not drawing. This line is annoying
As Trenki says using POLYGON_SMOOTH might cause the seam between adjacent polygons to become visible. You may end up with two triangles as a result of the triangulation of your polygon. Can you use GL_QUAD rather that GL_POLYGON in your call to glBegin()? This may help.