Hello folks. I’ve run into one problem which I can’t fully understand. First a snapshot of my code:
//enable states
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(crosshairLineVAO);
glEnable(GL_LINE_SMOOTH);
glLineWidth(4.0f);
glDrawArrays(GL_LINES, 0, 6);
glDisable(GL_LINE_SMOOTH);
glBindVertexArray(crosshairEndVAO);
glEnable(GL_POINT_SMOOTH);
glPointSize(10.0f);
glDrawArrays(GL_POINTS, 0, 3);
glDisable(GL_POINT_SMOOTH);
glBindVertexArray(0);
glDisable(GL_BLEND);
///use this to correct error
glBegin(GL_POINTS);
glVertex3f(0,20,0);
glEnd();
///
//disable states
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST);
Here I render a crosshair for my camera. Everything is really fine if you use this code and all subsequent rendering is correct. So the result of it all looks like this (note that crosshair is under surface and only Y axis is visible):
You can clearly see the white square point I rendered separately. Now that’s the problem because it’s just some dummy point which is there only to render my surface correctly. What happens if I remove it is this:
The surface renders this way every second render call, so it actually blinks between good and bad version.
What I believe is the problem whit:
glDisable(GL_POINT_SMOOTH);
When I don’t apply smoothing at all, the surface renders correctly, if I enable it the surface makes this strange thing, but why when it should be disabled whit disabling the state? It looks like that glDisable is applied only when next point is rendered.
Well and the second question is why this even happens. My surface is rendered as triangle strip through shader and without rendering that crosshair everything works correctly so it must be definitely error in this piece of code. What are these strange shapes that renders instead of triangles? it’s like one side and some curve over it - like smoothing was applied to one point of that triangle…