Added vsync timer logic to Qt OpenGL video driver.
This commit is contained in:
parent
01358407fd
commit
4fa0d0651a
|
@ -86,6 +86,12 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
//setAttribute(Qt::WA_OpaquePaintEvent);
|
//setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
||||||
|
drawTimer = new QTimer(this);
|
||||||
|
drawTimer->setInterval(14);
|
||||||
|
drawTimer->setSingleShot(true);
|
||||||
|
drawTimer->setTimerType(Qt::PreciseTimer);
|
||||||
|
connect(drawTimer, &QTimer::timeout, this, &ConsoleViewGL_t::onDrawSignal);
|
||||||
|
|
||||||
localBufSize = (4 * GL_NES_WIDTH) * (4 * GL_NES_HEIGHT) * sizeof(uint32_t);
|
localBufSize = (4 * GL_NES_WIDTH) * (4 * GL_NES_HEIGHT) * sizeof(uint32_t);
|
||||||
|
|
||||||
localBuf = (uint32_t*)malloc( localBufSize );
|
localBuf = (uint32_t*)malloc( localBufSize );
|
||||||
|
@ -137,6 +143,8 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
||||||
ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
||||||
{
|
{
|
||||||
//printf("Destroying GL Viewport\n");
|
//printf("Destroying GL Viewport\n");
|
||||||
|
drawTimer->stop();
|
||||||
|
delete drawTimer;
|
||||||
|
|
||||||
if ( localBuf )
|
if ( localBuf )
|
||||||
{
|
{
|
||||||
|
@ -566,6 +574,22 @@ void ConsoleViewGL_t::getNormalizedCursorPos( double &x, double &y )
|
||||||
void ConsoleViewGL_t::renderFinished(void)
|
void ConsoleViewGL_t::renderFinished(void)
|
||||||
{
|
{
|
||||||
videoBufferSwapMark();
|
videoBufferSwapMark();
|
||||||
|
|
||||||
|
// Schedule draw timing inline with vsync
|
||||||
|
drawTimer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleViewGL_t::queueRedraw(void)
|
||||||
|
{
|
||||||
|
if (!drawTimer->isActive())
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleViewGL_t::onDrawSignal(void)
|
||||||
|
{
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleViewGL_t::paintGL(void)
|
void ConsoleViewGL_t::paintGL(void)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions, public
|
||||||
|
|
||||||
int init(void);
|
int init(void);
|
||||||
void reset(void);
|
void reset(void);
|
||||||
void queueRedraw(void){ update(); };
|
void queueRedraw(void);
|
||||||
int driver(void){ return VIDEO_DRIVER_OPENGL; };
|
int driver(void){ return VIDEO_DRIVER_OPENGL; };
|
||||||
|
|
||||||
void transfer2LocalBuffer(void);
|
void transfer2LocalBuffer(void);
|
||||||
|
@ -90,6 +90,7 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions, public
|
||||||
unsigned int textureType;
|
unsigned int textureType;
|
||||||
unsigned int mouseButtonMask;
|
unsigned int mouseButtonMask;
|
||||||
QColor *bgColor;
|
QColor *bgColor;
|
||||||
|
QTimer *drawTimer;
|
||||||
|
|
||||||
uint32_t *localBuf;
|
uint32_t *localBuf;
|
||||||
uint32_t localBufSize;
|
uint32_t localBufSize;
|
||||||
|
@ -97,5 +98,6 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions, public
|
||||||
private slots:
|
private slots:
|
||||||
void cleanupGL(void);
|
void cleanupGL(void);
|
||||||
void renderFinished(void);
|
void renderFinished(void);
|
||||||
|
void onDrawSignal();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue