Reputation: 283345
Why are those lines appearing in my shape?
I'm initializing OpenGL like this:
glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glDisable(GL_COLOR_MATERIAL);
glEnable(GL_BLEND);
glEnable(GL_POLYGON_SMOOTH);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0, 0, 0, 0);
And drawing the shape like this:
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 0, 0);
glBegin(GL_POLYGON);
glVertex2f(-5, -5); // bottom left
glVertex2f(5, -5); // bottom right...
glVertex2f(6, 0);
glVertex2f(5, 5);
glVertex2f(-5, 5);
glEnd();
Doesn't matter if it's clockwise or CCW.
Upvotes: 1
Views: 4230
Reputation: 2174
I think disabling GL_POLYGON_SMOOTH would fix that, but you'd lose the antialiasing. FSAA would work as an alternative, but it'd be slower.
Edit: looking around, there are a lot of examples out there using glBlendFunc( GL_SRC_ALPHA_SATURATE, GL_ONE );
Upvotes: 4