http://bugs.winehq.org/show_bug.cgi?id=9609
--- Comment #24 from Stefan Dösinger stefandoesinger@gmx.at 2009-04-26 15:52:38 --- David_A on IRC wanted to look at the same function, perhaps get in sync with him before you two do the same work independently.
Basically you have to set the format from the extension in the GL pixel format template in utils.c, and set the GL_STENCIL_ATTACHMENT_EXT to the same renderbuffer or texture in context_attach_depth_stencil_fbo in context.c
There are a few things that make it slightly(not much) more complicated:
*) We want to be able to fall back to the current stencil-free operation if the extension is not supported. So have a fallback that uses the stencil-free gl format in the InitPixelFormats function(or a similar name) in utils.c
*) There is no way to set a stencil attachment != the depth attachment on most drivers(that just means no stencil fbos without that extension. With the extension they have the same ID, so things are fine)
*) Avoid comparing the format against D24S8 in context_attach_depth_stencil_fbo. Instead, create a new pixel format flag and check for the flag in this function. Using this flag you can easily fall back to the stencil-free behavior if the extension is not supported.