Skip to content

Commit

Permalink
Fix for multiple QExposeEvent under Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
TReed0803 committed Jan 18, 2015
1 parent ccc0bc2 commit f243e87
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 2_3DRendering/window.cpp
Expand Up @@ -2,6 +2,7 @@
#include <QDebug>
#include <QString>
#include <QOpenGLShaderProgram>
#include <QExposeEvent>
#include "qvertex.h"

// Front Verticies
Expand Down Expand Up @@ -143,6 +144,20 @@ void Window::update()
QOpenGLWindow::update();
}

void Window::exposeEvent(QExposeEvent *ev)
{
if (ev->region() != m_cachedRegion)
{
m_cachedRegion = ev->region();
QOpenGLWindow::exposeEvent(ev);
}
else
{
ev->ignore();
}

}

/*******************************************************************************
* Private Helpers
******************************************************************************/
Expand Down
7 changes: 7 additions & 0 deletions 2_3DRendering/window.h
Expand Up @@ -8,6 +8,7 @@
#include <QMatrix4x4>
#include "qtransform3d.h"

class QExposeEvent;
class QOpenGLShaderProgram;

class Window : public QOpenGLWindow,
Expand All @@ -25,6 +26,9 @@ protected slots:
void teardownGL();
void update();

protected:
void exposeEvent(QExposeEvent *ev);

private:
// OpenGL State Information
QOpenGLBuffer m_vertex;
Expand All @@ -37,6 +41,9 @@ protected slots:
QMatrix4x4 m_projection;
QTransform3D m_transform;

// Fix for Windows
QRegion m_cachedRegion;

// Private Helpers
void printVersionInformation();
};
Expand Down

0 comments on commit f243e87

Please sign in to comment.