diff --git a/src/drivers/Qt/ConsoleViewerGL.cpp b/src/drivers/Qt/ConsoleViewerGL.cpp index d271ac98..b4b19b4a 100644 --- a/src/drivers/Qt/ConsoleViewerGL.cpp +++ b/src/drivers/Qt/ConsoleViewerGL.cpp @@ -30,6 +30,14 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent) devPixRatio = screen->devicePixelRatio(); //printf("Ratio: %f \n", screen->devicePixelRatio() ); } + localBufSize = GL_NES_WIDTH * GL_NES_HEIGHT * sizeof(uint32_t); + + localBuf = (uint32_t*)malloc( localBufSize ); + + if ( localBuf ) + { + memset( localBuf, 0, localBufSize ); + } } ConsoleViewGL_t::~ConsoleViewGL_t(void) @@ -47,6 +55,11 @@ ConsoleViewGL_t::~ConsoleViewGL_t(void) } doneCurrent(); + + if ( localBuf ) + { + free( localBuf ); localBuf = NULL; + } } int ConsoleViewGL_t::init( void ) @@ -109,6 +122,11 @@ void ConsoleViewGL_t::resizeGL(int w, int h) buildTextures(); } +void ConsoleViewGL_t::transfer2LocalBuffer(void) +{ + memcpy( localBuf, nes_shm->pixbuf, localBufSize ); +} + void ConsoleViewGL_t::paintGL(void) { int texture_width = nes_shm->ncol; @@ -149,7 +167,7 @@ void ConsoleViewGL_t::paintGL(void) glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, GL_NES_WIDTH, GL_NES_HEIGHT, - GL_BGRA, GL_UNSIGNED_BYTE, nes_shm->pixbuf ); + GL_BGRA, GL_UNSIGNED_BYTE, localBuf ); glBegin(GL_QUADS); glTexCoord2f( l, b); // Bottom left of picture. diff --git a/src/drivers/Qt/ConsoleViewerGL.h b/src/drivers/Qt/ConsoleViewerGL.h index 8d8e9270..b45ddcb4 100644 --- a/src/drivers/Qt/ConsoleViewerGL.h +++ b/src/drivers/Qt/ConsoleViewerGL.h @@ -3,6 +3,8 @@ #pragma once +#include + #include #include @@ -16,8 +18,10 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions int init( void ); + void transfer2LocalBuffer(void); + protected: - void initializeGL(void); + void initializeGL(void); void resizeGL(int w, int h); void paintGL(void); @@ -31,6 +35,9 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions GLuint gltexture; bool linearFilter; + uint32_t *localBuf; + uint32_t localBufSize; + private slots: }; diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 41997c0f..d1377c41 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -295,7 +295,10 @@ void consoleWin_t::update(void) { nes_shm->blitUpdated = 0; - viewport->repaint(); + viewport->transfer2LocalBuffer(); + + //viewport->repaint(); + viewport->update(); } return;