1
Graphics / [1.6]glScissors Screen flashing
« on: June 27, 2011, 09:28:06 am »
First of all.. I'm sorry if this doesn't belong here..
glScissors causes the entire screen to flash.
Draw code:
StartClipping simply calls the glScissors with the appropriate params.
The m_clipRectArea gets update whenever the widget moves or is resized.
Here's the weird thing:
Image of flickering:
Any clue what's wrong and/or how to fix it?
glScissors causes the entire screen to flash.
Draw code:
Code: [Select]
void Widget::Draw() const
{
if(!m_visible)
return;
s_gui->GetWindow().Draw(m_shape);
//also draw children if any
for(WidgetList::const_iterator it = m_widgets.begin(); it != m_widgets.end(); it++) {
//don't draw outside parent's rect
StartClipping();
it->second->Draw();
StopClipping();
}
}
StartClipping simply calls the glScissors with the appropriate params.
Code: [Select]
void Widget::StartClipping() const
{
if(!s_gui)
return;
glEnable(GL_SCISSOR_TEST);
glScissor(m_clipRect.x, m_clipRect.y, m_clipRect.w, m_clipRect.h);
}
void Widget::StopClipping() const
{
if(!s_gui)
return;
glDisable(GL_SCISSOR_TEST);
}
The m_clipRectArea gets update whenever the widget moves or is resized.
Here's the weird thing:
Code: [Select]
void Widget::ResizeClipArea( uint32 newWidth, uint32 newHeight )
{
Rect prect;
if (m_parent) {
prect = m_parent->GetRect();
}
double width = s_gui->GetWindow().GetView().GetHalfSize().x*2;
double height = s_gui->GetWindow().GetView().GetHalfSize().y*2;
double xprc = newWidth/width;
double yprc = newHeight/height;
double wprc = newWidth/width;
double hprc = newHeight/height;
m_clipRect = m_rect;
m_clipRect.x = int32(m_clipRect.x * xprc);
m_clipRect.y = int32(m_clipRect.y * yprc);
m_clipRect.w = uint32(m_clipRect.w * wprc);
m_clipRect.h = uint32(m_clipRect.h * hprc);
/* Without this commented block.. it doesn't flash.
* This clips the clipRect if it's bigger than the parent's rect.
if(m_clipRect.x < prect.x)
m_clipRect.x = prect.x;
if(m_clipRect.w > prect.w)
m_clipRect.w = prect.w;
if(m_clipRect.y < prect.y)
m_clipRect.y = prect.y;
if(m_clipRect.h > prect.h)
m_clipRect.h = prect.h;
*/
m_clipRect.y = newHeight - (m_clipRect.y + m_clipRect.h);
if(m_clipRect.y < 0)
m_clipRect.y = 0;
if((uint32)m_clipRect.h > newHeight)
m_clipRect.h = newHeight;
if(m_clipRect.x < 0)
m_clipRect.x = 0;
if((uint32)m_clipRect.w > newWidth)
m_clipRect.w = newWidth;
}
Image of flickering:
Any clue what's wrong and/or how to fix it?