PDA

View Full Version : Flash points and lines?



helen1234
11-04-2002, 05:54 PM
Hi,

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?

helen

vladk
11-04-2002, 08:03 PM
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.

helen1234
11-06-2002, 09:46 PM
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?
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilOp(GL_KEEP, GL_ZERO, GL_REPLACE);
DrawWall();

glStencilFunc(GL_EQUAL, 1, 1);
glStencilMask(GL_FALSE);
//glDisable(GL_DEPTH_TEST);
DrawWindows();

glDisable(GL_STENCIL_TEST);

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?

thanks!

helen

xyzhelen
11-07-2002, 04:50 AM
Hi,

Here is another way.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST);
glDepthMask(1);

DrawHouse();

glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 3, 0xff);
glStencilOp(GL_KEEP, GL_REPLACE, GL_ZERO);

DrawWall();

glDisable(GL_DEPTH_TEST);
glDepthMask(0);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_GREATER, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

DrawWindows();

But the windows are still in front of the house when they are rotated.

How to do?

thanks!

helen