I want to draw a wall with red color and a window with white color on the wall.
But when they are rotated, there are some flash points and lines with red color on the white window.
That is because part of two geometries are drawed on the same pixel/point on a plane.
How to draw some different objects with different colors on a plane in 3D without flash points/lines?
This happens when two planes are too close and Z-buffer is not precise enough. The problem is pretty application-specific. For your example, if your are using a wall and a window, it is common that windows are “inside” walls. In this case you might want to draw the wall first using stencil buffer, and draw the window wherever wall didn’t left a mark in stencil buffer.
Thanks for your help.
I try it using stencil buffer many times. But all of them can’t solve my problem.
This is one of them. What’s wrong?
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_ZERO, GL_REPLACE);
glStencilFunc(GL_EQUAL, 1, 1);
Flash is not here, if I use glDisable(GL_DEPTH_TEST). But it’s not good way because windows are always in front of the wall when they are rotated.
Flash is still here without glDisable(GL_DEPTH_TEST).
In fact, I want to draw some geometries on the same plane, not only windows on a wall. Maybe many objects overlay each other.
How can I do?
Here is another way.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 3, 0xff);
glStencilOp(GL_KEEP, GL_REPLACE, GL_ZERO);
glStencilFunc(GL_GREATER, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
But the windows are still in front of the house when they are rotated.
How to do?