Solved MAC OpenGL scaling issue. Turns out it was related to the retina

screen having a 2x device to framebuffer scaling.
This commit is contained in:
mjbudd77 2020-06-29 23:24:41 -04:00
parent c6b46bfcc1
commit 41b54b9813
5 changed files with 21 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -2,7 +2,7 @@
//
#include <QtCore>
#include <SDL2/SDL.h>
#include <SDL.h>
#include "Qt/keyscan.h"

View File

@ -45,7 +45,7 @@
#include <QtCore>
#include <QKeyEvent>
#include <SDL2/SDL.h>
#include <SDL.h>
SDL_Keycode convQtKey2SDLKeyCode( Qt::Key q );

View File

@ -1,19 +1,29 @@
#include <QApplication>
#include <QScreen>
#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();
}