• Advertisement
Sign in to follow this  

glScissor issues

This topic is 3002 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

I am trying to use glScissor with glViewport but i am having some problems My code looks a little bit like this:
glEnable(scissor)
glViewport(dimmension1)
glScissor(dimmension1)
-- Draw a Quad Here
glViewport(dimmension0)
glScissor(dimmension0)
glDisable(scissor)
dimmension0 - my window original size dimmension1 - my scissor box size Now the problem is that my quad is really small, that's because the viewport gets smaller stretching the image. I tried only to move the viewport and leave its weight and height the same as before, but my quad won't get rendered.
glEnable(scissor)
glViewport(posx,posy,windowWtg, windowHgt)
glScissor(dimmension1)
-- Draw a Quad Here
glViewport(0,0,windowWtg, windowHgt)
glScissor(dimmension0)
glDisable(scissor)
So, do you guys have any ideeas? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
If you don't want your quad to become smaller, you have to adjust the projection matrix.

The projection matrix defined the view volume, which is mapped to the viewport. So if the viewport becomes smaller without changing the view volume, the same image will be rendered in a smaller viewport. So to compensate, you make the view volume smaller as well. The net effect is that the object's size on the screen remians the same.

Share this post


Link to post
Share on other sites
I played around all the day with glScissor and i finally managed to get something working.Not all good. but at least there is something good.

My question now is, if i intersect two scissor boxes, sc1 and sc2, that have the same dimensions, what part of sc2 will be visible?Only the one that is in the sc1 or the whole box?

Because i'm having an issue here.
Please take a look:


void CEngineGL::glPushMask ( RECT rcRect )
{
m_vRectGL.push_back (rcRect);
glScissor( rcRect.left, m_iResY-rcRect.top-rcRect.bottom, rcRect.right, rcRect.bottom );
glEnable( GL_SCISSOR_TEST );
}

void CEngineGL::glPopMask ()
{
if ( m_vRectGL.size() > 0 )
m_vRectGL.pop_back ();

if ( m_vRectGL.size() == 0 )
{
int t_iVec[4];
glGetIntegerv( GL_SCISSOR_BOX, t_iVec );
glScissor( t_iVec[0], t_iVec[1], t_iVec[2], t_iVec[3] );
glDisable( GL_SCISSOR_TEST );
}
else
{
RECT &rcRect = m_vRectGL.back();
glScissor( rcRect.left, m_iResY-rcRect.top-rcRect.bottom, rcRect.right, rcRect.bottom );
glEnable( GL_SCISSOR_TEST );
}
}






This is my code for doing scissoring.
Now using these code this way:


RECT rcRect;
SetRect( &rcRect, 100, 100, 500, 500 );
p_glCore->glPushMask ( rcRect );
{
p_glCore->glClearScene ( GL_COLOR_BUFFER_BIT, GL_XRGB(0,1,0) );

SetRect( &rcRect, 250, 250, 500, 500 );
p_glCore->glPushMask ( rcRect );
{
p_glCore->glClearScene ( GL_COLOR_BUFFER_BIT,
GL_XRGB(0,0,0) );
p_glWindow->glOnRender (Vector2D(500,600), 0.0f);
}
p_glCore->glPopMask ();
p_glCursor->glOnRender ( p_glEngine->glGetMouse(), 0.0f );
}
p_glCore->glPopMask ();





Results in something like this:
[picture]http://img340.imageshack.us/i/31753929.jpg/[/picture]

As you may noticve in the image, the cursor draws only withing the first scissor box, as it should, and that pink little rectangle also draws well withing the 2nd scissor box, but the 2nd scissor box won't fit into the first scissor box.

-- Made Some modifications and everything works well right now.
--By the way, for those who need help in the future


void CEngineGL::glPushMask ( RECT rcRect )
{
if (m_vRectGL.size() > 0 )
{
RECT pr = m_vRectGL.back();
if ( rcRect.left < pr.left )
{
rcRect.right -= (pr.left-rcRect.left);
rcRect.left = pr.left;
if ( rcRect.right < 0 )
rcRect.right = 0;
}
if ( rcRect.top < pr.top )
{
rcRect.bottom -= (pr.top-rcRect.top);
rcRect.top = pr.top;
if ( rcRect.bottom < 0 )
rcRect.bottom = 0;
}
if ( rcRect.right + rcRect.left > pr.right + pr.left )
{
rcRect.right -= (rcRect.right + rcRect.left)-(pr.right + pr.left);
if ( rcRect.right < 0 )
rcRect.right = 0;
}
if ( rcRect.bottom + rcRect.top > pr.bottom + pr.top )
{
rcRect.bottom -= (rcRect.bottom + rcRect.top)-(pr.bottom + pr.top);
if ( rcRect.bottom < 0 )
rcRect.bottom = 0;
}
}
m_vRectGL.push_back (rcRect);
glScissor( rcRect.left, m_iResY-rcRect.top-rcRect.bottom, rcRect.right, rcRect.bottom );
glEnable( GL_SCISSOR_TEST );
}

void CEngineGL::glPopMask ()
{
if ( m_vRectGL.size() > 0 )
m_vRectGL.pop_back ();

if ( m_vRectGL.size() == 0 )
{
int t_iVec[4];
glGetIntegerv( GL_SCISSOR_BOX, t_iVec );
glScissor( t_iVec[0], t_iVec[1], t_iVec[2], t_iVec[3] );
glDisable( GL_SCISSOR_TEST );
}
else
{
RECT &rcRect = m_vRectGL.back();
glScissor( rcRect.left, m_iResY-rcRect.top-rcRect.bottom, rcRect.right, rcRect.bottom );
glEnable( GL_SCISSOR_TEST );
}
}
//m_vRectGL is declared as std::vector<RECT> m_vRectGL;





[Edited by - xilup on December 5, 2009 11:30:33 AM]

Share this post


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

  • Advertisement