Jump to content
  • Advertisement
Sign in to follow this  
Slug

Problem with stencil buffer

This topic is 4894 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i got some problem when trying to do a dissolve effect with stencil buffer. The problem is, after drawing the first frame with any dissolve pattern in pDissolvePattern (an array of float, the size of the number of pixel on the screen), it seem that i cannot change it(the pattern) anymore. And then, only the first scene is draw... Here the code: //----------------------------------------------------------------------------- // Name : RenderScene() // Desc : Draw the GL game on the screen //----------------------------------------------------------------------------- void CQuest::RenderScene() { // Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //2D Stuff glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT); glMatrixMode(GL_MODELVIEW); // Disable Lightning and depth test glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); // Set the viewport the whole window glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);// Make our viewport the whole window glEnable(GL_STENCIL_TEST); glStencilFunc(GL_NEVER, 1, 1); glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); //glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDrawPixels(SCREEN_WIDTH, SCREEN_HEIGHT, GL_STENCIL_INDEX, GL_FLOAT, pDissolvePattern); glStencilMask(GL_FALSE); glStencilFunc(GL_EQUAL, 0, 1); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); DrawScene1(); glStencilFunc(GL_EQUAL, 1, 1); DrawScene2(); glDisable(GL_STENCIL_TEST); UpdateDissolvePatern(); //swap the drawing buffer with the display one SwapBuffers(g_hDC); } Can somebody tell me what's wrong???

Share this post


Link to post
Share on other sites
Advertisement
I've fix the problem, that was stupid, but , the new problem is, WHY WRITING TO
STENCIL BUFFER WITH DRAWPIXEL IS SO SLOW??? It make my app run from 60 fps to 1.

Share this post


Link to post
Share on other sites
because its probably not a native thing for the graphics card todo, so it has to internally jiggle things around.

glDrawPixels() is generally slow for most tasks and is best avoided as much as you can

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!