Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

stencil buffer working with draw to bitmap?

7 views
Skip to first unread message

Peter Meier

unread,
Nov 5, 2002, 10:22:48 AM11/5/02
to
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...@iwb.tum.de
http://www.iwb.tum.de


Jerker Olofsson

unread,
Nov 5, 2002, 10:55:07 AM11/5/02
to
Peter Meier wrote:
>
> 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
>

<snip>

Try switching from 24bpp to 32bpp..

Peter Meier

unread,
Nov 5, 2002, 12:00:47 PM11/5/02
to
Hello, thanks a lot for the reply, but I just now found the error.
Unfortunately I know what I dit to fix it, but I do not know why it works now.
Apparently there must have been some openGL calls in some lib, that screwed up
my stencil function. I just repeated the call at another place and now it
works.

See ya, Peter

Jerker Olofsson schrieb:

--

0 new messages