OpenGL GL_POLYGON_SMOOTH 2D anti-aliasing creating tris from ATVs

UPDATE:

I installed it when installing the NVIDIA control panel, if I remove it, it works correctly.

When you rotate the quad in OpenGL, the edges become jagged.

If I call glEnable (GL_POLYGON_SMOOTH), the edges become smooth, but OpenGL then draws a white diagonal line across all my images, as if it were creating a trisout of my squares.

Here's what it looks like: GL_POLYGON_SMOOTH

Is there a way to disable this line, or can I get anti-aliasing in another simple way? I tried GL_MULTISAMPLE, but nothing happened.

My code also has:

glShadeModel(GL_SMOOTH); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
+6
source share
1 answer

Ok, I will write this as an answer, let me know if this works after checking.

GL_TRIANGLE_FAN: if an application defines a sequence of vertices v, OpenGL displays a triangle using v 0, v 1 and v 2; another triangle using v 0, v 2 and v 3; another triangle using v 0, v 3 and v 4; etc. If an application defines n vertices, OpenGL displays n-2 connected triangles.

So, to draw a unit quad centered around the origin,

 glBegin(GL_TRIANGLE_FAN); glTexCoord2f(0f, 0f); glVertex3f(-halfWidth, -halfHeight, 0f); glTexCoord2f(0f, 1f); glVertex3f(-halfWidth, halfHeight, 0f); glTexCoord2f(1f, 1f); glVertex3f(halfWidth, halfHeight, 0f); glTexCoord2f(1f, 0f); glVertex3f(halfWidth, -halfHeight, 0f); glEnd(); 

Now you can put the very same transformations around this one that you used around your ATV! Hope this helps!

+3
source

Source: https://habr.com/ru/post/908631/


All Articles