Hello out there, please help,
I am writing a windows service-application (no visible window), that
renders a scene with opengl and writes pictures out. Rendered things
come out, but the stencil buffer does not work. I am rendering a 3D
scene and then drawing a background with drawpixels. Drawpixels should
not draw where any 3d things are drawn. This method works well with
PFD_DRAW_TO_WINDOW and doublebuffering. In the bitmap setup drawpixels
draws everywhere (overwriting the rendered scene). I take the picture by
using glReadPixels. Thanks for helping, Peter
Here my pfd setup:
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure
1, // Version of this
structure
PFD_DRAW_TO_BITMAP | // Draw to bitmap
PFD_SUPPORT_OPENGL |
PFD_SUPPORT_GDI,
PFD_TYPE_RGBA, // RGBA Color mode
m_BitsPerPixel, // Want 24bit
color
0,0,0,0,0,0, // Color bits ignored
0,0, // No alpha buffer
0,0,0,0,0, // Shift bits ignored
16, // Size of depth buffer
16, //16-bit stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // Draw in main plane
0, // reserved
0,0,0 // layer masks ignored
};
Here my stencil setup:
glEnable(GL_STENCIL_TEST | GL_DEPTH_TEST);
//if zbuffertest is passed then write 1 to stencil buffer
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
// Clear out the color, stencil & depth buffers
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
//renderfirst setting stencil
//stencil test is always passed
glStencilFunc(GL_ALWAYS, 1, 1);
render3D();
//drawvideo where stencil isn't set to 1
glStencilFunc (GL_NOTEQUAL, 1, 1);
//video changes projection setup, we safe current projection
glMatrixMode(GL_PROJECTION);
glPushMatrix();
render2D();
//return to 3D Projection
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
--
Dipl.-Ing. Peter Meier
Phone: +49 (0)89 289 15570
Fax: +49 (0)89 289 15555
Institut für Werkzeugmaschinen und Betriebswissenschaften (iwb)
Prof. Dr.-Ing. M. Zäh
Prof. Dr.-Ing. G. Reinhart
TU Muenchen
peter.me...@iwb.tum.de
http://www.iwb.tum.de