Added logic to watch for screen change events coming from main window and notify OpenGL widget to recalculate screen pixel ratio and texture sizes.
This commit is contained in:
parent
0053a52929
commit
bcdfa2a834
|
@ -72,12 +72,12 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
||||||
setMinimumHeight( 224 );
|
setMinimumHeight( 224 );
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
QScreen *screen = QGuiApplication::primaryScreen();
|
QScreen *screen = window()->screen();
|
||||||
|
|
||||||
if ( screen != NULL )
|
if ( screen != NULL )
|
||||||
{
|
{
|
||||||
devPixRatio = screen->devicePixelRatio();
|
devPixRatio = screen->devicePixelRatio();
|
||||||
//printf("Ratio: %f \n", screen->devicePixelRatio() );
|
//printf("GL Ratio: %f \n", screen->devicePixelRatio() );
|
||||||
}
|
}
|
||||||
localBufSize = (4 * GL_NES_WIDTH) * (4 * GL_NES_HEIGHT) * sizeof(uint32_t);
|
localBufSize = (4 * GL_NES_WIDTH) * (4 * GL_NES_HEIGHT) * sizeof(uint32_t);
|
||||||
|
|
||||||
|
@ -116,6 +116,26 @@ ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConsoleViewGL_t::screenChanged( QScreen *screen )
|
||||||
|
{
|
||||||
|
int w,h;
|
||||||
|
|
||||||
|
devPixRatio = screen->devicePixelRatio();
|
||||||
|
|
||||||
|
w = (int)(devPixRatio * width() );
|
||||||
|
h = (int)(devPixRatio * height() );
|
||||||
|
|
||||||
|
view_width = w;
|
||||||
|
view_height = h;
|
||||||
|
|
||||||
|
gui_draw_area_width = w;
|
||||||
|
gui_draw_area_height = h;
|
||||||
|
|
||||||
|
buildTextures();
|
||||||
|
|
||||||
|
//printf("GL Ratio: %f %ix%i\n", screen->devicePixelRatio(), w, h );
|
||||||
|
}
|
||||||
|
|
||||||
int ConsoleViewGL_t::init( void )
|
int ConsoleViewGL_t::init( void )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <QScreen>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
|
|
||||||
|
@ -36,6 +37,8 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
void getAspectXY( double &x, double &y );
|
void getAspectXY( double &x, double &y );
|
||||||
double getAspectRatio(void);
|
double getAspectRatio(void);
|
||||||
|
|
||||||
|
void screenChanged(QScreen *scr);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeGL(void);
|
void initializeGL(void);
|
||||||
void resizeGL(int w, int h);
|
void resizeGL(int w, int h);
|
||||||
|
|
|
@ -221,6 +221,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
|
||||||
// Create AVI Recording Disk Thread
|
// Create AVI Recording Disk Thread
|
||||||
aviDiskThread = new AviRecordDiskThread_t(this);
|
aviDiskThread = new AviRecordDiskThread_t(this);
|
||||||
|
|
||||||
|
connect( this->window()->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(winScreenChanged(QScreen*)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleWin_t::~consoleWin_t(void)
|
consoleWin_t::~consoleWin_t(void)
|
||||||
|
@ -334,6 +335,15 @@ void consoleWin_t::videoReset(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void consoleWin_t::winScreenChanged(QScreen *scr)
|
||||||
|
{
|
||||||
|
//printf("Screen Changed: %p\n", scr );
|
||||||
|
if ( viewport_GL != NULL )
|
||||||
|
{
|
||||||
|
viewport_GL->screenChanged( scr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QSize consoleWin_t::calcRequiredSize(void)
|
QSize consoleWin_t::calcRequiredSize(void)
|
||||||
{
|
{
|
||||||
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );
|
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );
|
||||||
|
|
|
@ -405,6 +405,7 @@ class consoleWin_t : public QMainWindow
|
||||||
void wavRecordStart(void);
|
void wavRecordStart(void);
|
||||||
void wavRecordAsStart(void);
|
void wavRecordAsStart(void);
|
||||||
void wavRecordStop(void);
|
void wavRecordStop(void);
|
||||||
|
void winScreenChanged( QScreen *scr );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue