Fixed OpenGL display for mesa drivers

This commit is contained in:
bgk 2009-03-07 08:23:25 +00:00
parent f099e3ba71
commit d94765205a
2 changed files with 28 additions and 15 deletions

View File

@ -48,6 +48,12 @@ void ScreenAreaGl::on_realize()
{
Gtk::DrawingArea::on_realize();
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
glViewport(0, 0, get_width(), get_height());
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@ -57,6 +63,8 @@ void ScreenAreaGl::on_realize()
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0, 1.0);
glwindow->gl_end();
}
void ScreenAreaGl::vDrawPixels(u8 * _puiData)
@ -77,21 +85,28 @@ void ScreenAreaGl::vDrawBlackScreen()
void ScreenAreaGl::vOnWidgetResize()
{
m_dScaleFactor = min<double>(get_height() / (double)m_iScaledHeight, get_width() / (double)m_iScaledWidth);
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return;
glViewport(0, 0, get_width(), get_height());
m_dAreaTop = 1 - m_dScaleFactor * m_iScaledHeight / (double)get_height();
m_dAreaLeft = 1 - m_dScaleFactor * m_iScaledWidth / (double)get_width();
glwindow->gl_end();
m_dScaleFactor = min<double>(get_height() / (double)m_iScaledHeight, get_width() / (double)m_iScaledWidth);
m_dAreaTop = (1 - m_dScaleFactor * m_iScaledHeight / (double)get_height()) / 2;
m_dAreaLeft = (1 - m_dScaleFactor * m_iScaledWidth / (double)get_width()) / 2;
}
bool ScreenAreaGl::on_expose_event(GdkEventExpose * _pstEvent)
{
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
glRasterPos2f(-1.0f + m_dAreaLeft, 1.0f - m_dAreaTop);
glPixelZoom(m_dScaleFactor, -m_dScaleFactor);
glRasterPos2f(m_dAreaLeft, m_dAreaTop);
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_iScaledWidth + 1);
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
if (!glwindow->gl_begin(get_gl_context()))
return false;

View File

@ -218,8 +218,6 @@ void ScreenArea::vUpdateSize()
m_iScaledWidth = m_iFilterScale * m_iWidth;
m_iScaledHeight = m_iFilterScale * m_iHeight;
vOnWidgetResize();
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32));