diff --git a/src/drivers/Qt/GameViewerGL.cpp b/src/drivers/Qt/GameViewerGL.cpp index 8434d0a2..79df9e9e 100644 --- a/src/drivers/Qt/GameViewerGL.cpp +++ b/src/drivers/Qt/GameViewerGL.cpp @@ -20,6 +20,7 @@ gameViewGL_t::gameViewGL_t(QWidget *parent) use_sw_pix_remap = 0; remap_pixBuf = NULL; remap_pixPtr = NULL; + devPixRatio = 1.0f; } @@ -49,8 +50,9 @@ gameViewGL_t::~gameViewGL_t(void) } } -int gameViewGL_t::init(void) +int gameViewGL_t::init( double devPixRatioInput ) { + devPixRatio = devPixRatioInput; return 0; } @@ -151,6 +153,8 @@ void gameViewGL_t::initializeGL(void) void gameViewGL_t::resizeGL(int w, int h) { + w = (int)( devPixRatio * w ); + h = (int)( devPixRatio * h ); printf("GL Resize: %i x %i \n", w, h ); glViewport(0, 0, w, h); diff --git a/src/drivers/Qt/GameViewerGL.h b/src/drivers/Qt/GameViewerGL.h index 205b9681..45776c05 100644 --- a/src/drivers/Qt/GameViewerGL.h +++ b/src/drivers/Qt/GameViewerGL.h @@ -14,7 +14,7 @@ class gameViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions gameViewGL_t(QWidget *parent = 0); ~gameViewGL_t(void); - int init(void); + int init( double devPixRatio = 1.0f ); protected: void initializeGL(void); @@ -25,6 +25,7 @@ class gameViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions void calcPixRemap(void); void doRemap(void); + double devPixRatio; int texture_width; int texture_height; int view_width; diff --git a/src/drivers/Qt/keyscan.cpp b/src/drivers/Qt/keyscan.cpp index 3dfd1f22..389ac66a 100644 --- a/src/drivers/Qt/keyscan.cpp +++ b/src/drivers/Qt/keyscan.cpp @@ -2,7 +2,7 @@ // #include -#include +#include #include "Qt/keyscan.h" diff --git a/src/drivers/Qt/keyscan.h b/src/drivers/Qt/keyscan.h index 0273471c..2499709f 100644 --- a/src/drivers/Qt/keyscan.h +++ b/src/drivers/Qt/keyscan.h @@ -45,7 +45,7 @@ #include #include -#include +#include SDL_Keycode convQtKey2SDLKeyCode( Qt::Key q ); diff --git a/src/drivers/Qt/main.cpp b/src/drivers/Qt/main.cpp index 4379b0ad..ec133a41 100644 --- a/src/drivers/Qt/main.cpp +++ b/src/drivers/Qt/main.cpp @@ -1,19 +1,29 @@ #include +#include #include "Qt/GameApp.h" #include "Qt/fceuWrapper.h" int main( int argc, char *argv[] ) { + double devPixRatio = 1.0; QApplication app(argc, argv); gameWin_t win; + QScreen *screen = QGuiApplication::primaryScreen(); + + if ( screen != NULL ) + { + devPixRatio = screen->devicePixelRatio(); + printf("Ratio: %f \n", screen->devicePixelRatio() ); + } + fceuWrapperInit( argc, argv ); - win.resize( 512, 512 ); + //win.resize( 512, 512 ); win.show(); - win.viewport->init(); + win.viewport->init( devPixRatio ); return app.exec(); }