Jump to content
  • Advertisement
Sign in to follow this  
GLnewBee

OpenGL Scissors Rendering problems

This topic is 4066 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 am struggling with a OpenGL scissors problem. My source code is below. I am trying to draw a 2 dimensional rectangular display with three independent sqaure scissor sections inside the rectangle. Thus I am using the glScissor function to do this. Within each sqaure is a bitmap that I am rotating. All of this works on my PC. But as soon as I run the code on any other PC, my problems start: The first scissor section is perfect, but the other two are scrambled...the rendering has gone wrong (purple stripes) Has any one got an idea what it could be? Is it a OpenGL driver issue? A video screen card issue? Or something in my code? Thanx! GLint width,height; float ratio; width = (OpenGLAPPanelCombined->Width+1)/3; height = (OpenGLAPPanelCombined->Height); ratio = (float)width/height; glEnable(GL_SCISSOR_TEST); //Set the Position glScissor(0, 0, width, height); glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,-5.0f); glRotatef(pSensorVectorCalc->roll[SpotSampleNr],0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.8f, 1.8f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.8f, 1.8f, 0.0f); // Back Face glEnd(); zrot[0]+= 1.0f; EditDispRoll->Text = IntToStr((int)pSensorVectorCalc->roll[SpotSampleNr]); glDisable(GL_SCISSOR_TEST); //Set the Position glEnable(GL_SCISSOR_TEST); glScissor(width, 0, width, height); glViewport(width, 0, width, height); glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,-5.0f); glRotatef(pSensorVectorCalc->pitch[SpotSampleNr],0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D, texture[1]); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.8f, 1.8f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.8f, 1.8f, 0.0f); // Back Face glEnd(); zrot[1]+= 1.0f; EditDispPitch->Text = IntToStr((int)pSensorVectorCalc->pitch[SpotSampleNr]); glDisable(GL_SCISSOR_TEST); //Set the Position glEnable(GL_SCISSOR_TEST); glScissor(width*2, 0, width, height); glViewport(width*2, 0, width, height); glLoadIdentity(); // Reset The View glTranslatef(0.0f,0.0f,-5.0f); glRotatef(-1*pSensorVectorCalc->yaw[SpotSampleNr],0.0f,0.0f,1.0f); glBindTexture(GL_TEXTURE_2D, texture[2]); glBegin(GL_QUADS); // Front Face glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.8f, -1.8f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.8f, 1.8f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.8f, 1.8f, 0.0f); // Back Face glEnd(); glDisable(GL_SCISSOR_TEST); zrot[2]+=-1.0f; EditDispYaw->Text = IntToStr((int)pSensorVectorCalc->yaw[SpotSampleNr]);

Share this post


Link to post
Share on other sites
Advertisement
One thing I see is that your Clear command will only affect the first part of your rendering. Clear is only done in the scissored part. You should clear before enabling scissor test or set the scissor rect to the whole area.

You could clear each viewport, but it will probably be slower.

Share this post


Link to post
Share on other sites
Hi Zongo

Thanx for the input! I have tried to clear the screen and depth buffer before I enabled the scissor test as you said but it did not work. Could it not be a screen card issue? Does all screen cards support the scissoring method? How could I test for that?

Thanx for the help

Share this post


Link to post
Share on other sites
Scissoring is some basic operation of the GPU and exists since OpenGL 1.0 I think and should be supported everywhere, so it's most probably that something else conflicts with it.

Make sure you don't leak a state from one frame to another, you may want to disable scissoring just before your Clear.

ColorMask/DephtMask also influence Clear (they are set as TRUE by default, so if you did not touch them, it's not the problem).

I do not see anything from your snippet otherwise.

Share this post


Link to post
Share on other sites
Ok sorry my fault...the problem is solved. glClear wasn't called before the scissor test as I thought. Now that it is called first, it works!!!

Thanx again for the help!

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!