Added logic to the Qt GUI Video Config Window to allow for the image pixel scaling to be numerically set. Also added a square pixel option to allow for the X and Y scales to either be set separately or tied together. This addresses issue #205.
This commit is contained in:
parent
2c7c87e3c8
commit
8f336bf8d3
|
@ -9,6 +9,7 @@
|
|||
#include "Qt/fceuWrapper.h"
|
||||
#include "Qt/ConsoleWindow.h"
|
||||
#include "Qt/ConsoleVideoConf.h"
|
||||
#include "Qt/nes_shm.h"
|
||||
|
||||
//----------------------------------------------------
|
||||
ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
||||
|
@ -84,23 +85,89 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
|
|||
// Show FPS Checkbox
|
||||
showFPS_cbx = new QCheckBox( tr("Show FPS") );
|
||||
|
||||
// Square Pixels
|
||||
sqrPixCbx = new QCheckBox( tr("Square Pixels") );
|
||||
|
||||
setCheckBoxFromProperty( new_PPU_ena , "SDL.NewPPU");
|
||||
setCheckBoxFromProperty( frmskipcbx , "SDL.Frameskip");
|
||||
setCheckBoxFromProperty( sprtLimCbx , "SDL.DisableSpriteLimit");
|
||||
setCheckBoxFromProperty( clipSidesCbx , "SDL.ClipSides");
|
||||
setCheckBoxFromProperty( showFPS_cbx , "SDL.ShowFPS");
|
||||
|
||||
if ( consoleWindow )
|
||||
{
|
||||
if ( consoleWindow->viewport_GL )
|
||||
{
|
||||
sqrPixCbx->setChecked( consoleWindow->viewport_GL->getSqrPixelOpt() );
|
||||
}
|
||||
else if ( consoleWindow->viewport_SDL )
|
||||
{
|
||||
sqrPixCbx->setChecked( consoleWindow->viewport_SDL->getSqrPixelOpt() );
|
||||
}
|
||||
}
|
||||
|
||||
connect(new_PPU_ena , SIGNAL(stateChanged(int)), this, SLOT(use_new_PPU_changed(int)) );
|
||||
connect(frmskipcbx , SIGNAL(stateChanged(int)), this, SLOT(frameskip_changed(int)) );
|
||||
connect(sprtLimCbx , SIGNAL(stateChanged(int)), this, SLOT(useSpriteLimitChanged(int)) );
|
||||
connect(clipSidesCbx, SIGNAL(stateChanged(int)), this, SLOT(clipSidesChanged(int)) );
|
||||
connect(showFPS_cbx , SIGNAL(stateChanged(int)), this, SLOT(showFPSChanged(int)) );
|
||||
connect(sqrPixCbx , SIGNAL(stateChanged(int)), this, SLOT(sqrPixChanged(int)) );
|
||||
|
||||
main_vbox->addWidget( new_PPU_ena );
|
||||
main_vbox->addWidget( frmskipcbx );
|
||||
main_vbox->addWidget( sprtLimCbx );
|
||||
main_vbox->addWidget( clipSidesCbx);
|
||||
main_vbox->addWidget( showFPS_cbx );
|
||||
main_vbox->addWidget( sqrPixCbx );
|
||||
|
||||
xScaleBox = new QDoubleSpinBox(this);
|
||||
yScaleBox = new QDoubleSpinBox(this);
|
||||
|
||||
xScaleBox->setRange( 1.0, 16.0 );
|
||||
yScaleBox->setRange( 1.0, 16.0 );
|
||||
|
||||
xScaleBox->setSingleStep( 0.10 );
|
||||
yScaleBox->setSingleStep( 0.10 );
|
||||
|
||||
if ( consoleWindow )
|
||||
{
|
||||
if ( consoleWindow->viewport_GL )
|
||||
{
|
||||
xScaleBox->setValue( consoleWindow->viewport_GL->getScaleX() );
|
||||
yScaleBox->setValue( consoleWindow->viewport_GL->getScaleY() );
|
||||
}
|
||||
else if ( consoleWindow->viewport_SDL )
|
||||
{
|
||||
xScaleBox->setValue( consoleWindow->viewport_SDL->getScaleX() );
|
||||
yScaleBox->setValue( consoleWindow->viewport_SDL->getScaleY() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( sqrPixCbx->isChecked() )
|
||||
{
|
||||
xScaleLabel = new QLabel( tr("Scale:") );
|
||||
}
|
||||
else
|
||||
{
|
||||
xScaleLabel = new QLabel( tr("X Scale:") );
|
||||
}
|
||||
yScaleLabel = new QLabel( tr("Y Scale:") );
|
||||
|
||||
hbox1 = new QHBoxLayout();
|
||||
hbox1->addWidget( xScaleLabel );
|
||||
hbox1->addWidget( xScaleBox );
|
||||
main_vbox->addLayout( hbox1 );
|
||||
|
||||
hbox1 = new QHBoxLayout();
|
||||
hbox1->addWidget( yScaleLabel );
|
||||
hbox1->addWidget( yScaleBox );
|
||||
main_vbox->addLayout( hbox1 );
|
||||
|
||||
if ( sqrPixCbx->isChecked() )
|
||||
{
|
||||
yScaleLabel->hide();
|
||||
yScaleBox->hide();
|
||||
}
|
||||
|
||||
hbox1 = new QHBoxLayout();
|
||||
|
||||
|
@ -241,6 +308,26 @@ void ConsoleVideoConfDialog_t::showFPSChanged( int value )
|
|||
fceuWrapperUnLock();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ConsoleVideoConfDialog_t::sqrPixChanged( int value )
|
||||
{
|
||||
//printf("Value:%i \n", value );
|
||||
int useSqrPix = (value != Qt::Unchecked);
|
||||
|
||||
if ( useSqrPix )
|
||||
{
|
||||
xScaleLabel->setText( tr("Scale:") );
|
||||
yScaleLabel->hide();
|
||||
yScaleBox->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
xScaleLabel->setText( tr("X Scale:") );
|
||||
yScaleLabel->show();
|
||||
yScaleBox->show();
|
||||
}
|
||||
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ConsoleVideoConfDialog_t::driverChanged(int index)
|
||||
{
|
||||
int driver;
|
||||
|
@ -272,8 +359,71 @@ void ConsoleVideoConfDialog_t::regionChanged(int index)
|
|||
fceuWrapperUnLock();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
QSize ConsoleVideoConfDialog_t::calcNewScreenSize(void)
|
||||
{
|
||||
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );
|
||||
|
||||
if ( consoleWindow )
|
||||
{
|
||||
QSize w, v;
|
||||
double xscale, yscale;
|
||||
int texture_width = nes_shm->ncol;
|
||||
int texture_height = nes_shm->nrow;
|
||||
int l=0, r=texture_width;
|
||||
int t=0, b=texture_height;
|
||||
int dw=0, dh=0, rw, rh;
|
||||
|
||||
w = consoleWindow->size();
|
||||
|
||||
if ( consoleWindow->viewport_GL )
|
||||
{
|
||||
v = consoleWindow->viewport_GL->size();
|
||||
}
|
||||
else if ( consoleWindow->viewport_SDL )
|
||||
{
|
||||
v = consoleWindow->viewport_SDL->size();
|
||||
}
|
||||
|
||||
dw = w.width() - v.width();
|
||||
dh = w.height() - v.height();
|
||||
|
||||
if ( sqrPixCbx->isChecked() )
|
||||
{
|
||||
yscale = xscale = xScaleBox->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = xScaleBox->value();
|
||||
yscale = yScaleBox->value();
|
||||
}
|
||||
rw=(int)((r-l)*xscale);
|
||||
rh=(int)((b-t)*yscale);
|
||||
|
||||
out.setWidth( rw + dw );
|
||||
out.setHeight( rh + dh );
|
||||
}
|
||||
return out;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ConsoleVideoConfDialog_t::applyChanges( void )
|
||||
{
|
||||
resetVideo();
|
||||
|
||||
if ( consoleWindow )
|
||||
{
|
||||
QSize s = calcNewScreenSize();
|
||||
|
||||
if ( consoleWindow->viewport_GL )
|
||||
{
|
||||
consoleWindow->viewport_GL->setSqrPixelOpt( sqrPixCbx->isChecked() );
|
||||
}
|
||||
if ( consoleWindow->viewport_SDL )
|
||||
{
|
||||
consoleWindow->viewport_SDL->setSqrPixelOpt( sqrPixCbx->isChecked() );
|
||||
}
|
||||
|
||||
consoleWindow->resize( s );
|
||||
}
|
||||
|
||||
}
|
||||
//----------------------------------------------------
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QSlider>
|
||||
#include <QFrame>
|
||||
#include <QGroupBox>
|
||||
#include <QDoubleSpinBox>
|
||||
|
||||
class ConsoleVideoConfDialog_t : public QDialog
|
||||
{
|
||||
|
@ -35,18 +36,25 @@ class ConsoleVideoConfDialog_t : public QDialog
|
|||
QCheckBox *sprtLimCbx;
|
||||
QCheckBox *clipSidesCbx;
|
||||
QCheckBox *showFPS_cbx;
|
||||
QCheckBox *sqrPixCbx;
|
||||
QDoubleSpinBox *xScaleBox;
|
||||
QDoubleSpinBox *yScaleBox;
|
||||
QLabel *xScaleLabel;
|
||||
QLabel *yScaleLabel;
|
||||
|
||||
void setCheckBoxFromProperty( QCheckBox *cbx, const char *property );
|
||||
void setComboBoxFromProperty( QComboBox *cbx, const char *property );
|
||||
//void setSliderFromProperty( QSlider *slider, QLabel *lbl, const char *property );
|
||||
|
||||
void resetVideo(void);
|
||||
QSize calcNewScreenSize(void);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
|
||||
private slots:
|
||||
void openGL_linearFilterChanged( int value );
|
||||
void sqrPixChanged( int value );
|
||||
void use_new_PPU_changed( int value );
|
||||
void frameskip_changed( int value );
|
||||
void useSpriteLimitChanged( int value );
|
||||
|
|
|
@ -23,13 +23,19 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
|||
gltexture = 0;
|
||||
devPixRatio = 1.0f;
|
||||
linearFilter = false;
|
||||
sqrPixels = true;
|
||||
xscale = 2.0;
|
||||
yscale = 2.0;
|
||||
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
setMinimumWidth( GL_NES_WIDTH );
|
||||
setMinimumHeight( GL_NES_HEIGHT );
|
||||
|
||||
if ( screen != NULL )
|
||||
{
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
|
||||
if ( screen != NULL )
|
||||
{
|
||||
devPixRatio = screen->devicePixelRatio();
|
||||
//printf("Ratio: %f \n", screen->devicePixelRatio() );
|
||||
//printf("Ratio: %f \n", screen->devicePixelRatio() );
|
||||
}
|
||||
localBufSize = GL_NES_WIDTH * GL_NES_HEIGHT * sizeof(uint32_t);
|
||||
|
||||
|
@ -155,16 +161,19 @@ void ConsoleViewGL_t::paintGL(void)
|
|||
int l=0, r=texture_width;
|
||||
int t=0, b=texture_height;
|
||||
|
||||
float xscale = (float)view_width / (float)texture_width;
|
||||
float yscale = (float)view_height / (float)texture_height;
|
||||
xscale = (float)view_width / (float)texture_width;
|
||||
yscale = (float)view_height / (float)texture_height;
|
||||
|
||||
if (xscale < yscale )
|
||||
if ( sqrPixels )
|
||||
{
|
||||
yscale = xscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = yscale;
|
||||
if (xscale < yscale )
|
||||
{
|
||||
yscale = xscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = yscale;
|
||||
}
|
||||
}
|
||||
int rw=(int)((r-l)*xscale);
|
||||
int rh=(int)((b-t)*yscale);
|
||||
|
|
|
@ -22,6 +22,11 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
|
||||
void setLinearFilterEnable( bool ena );
|
||||
|
||||
bool getSqrPixelOpt(void){ return sqrPixels; };
|
||||
void setSqrPixelOpt( bool val ){ sqrPixels = val; return; };
|
||||
double getScaleX(void){ return xscale; };
|
||||
double getScaleY(void){ return yscale; };
|
||||
|
||||
protected:
|
||||
void initializeGL(void);
|
||||
void resizeGL(int w, int h);
|
||||
|
@ -32,10 +37,13 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
void doRemap(void);
|
||||
|
||||
double devPixRatio;
|
||||
double xscale;
|
||||
double yscale;
|
||||
int view_width;
|
||||
int view_height;
|
||||
GLuint gltexture;
|
||||
bool linearFilter;
|
||||
bool sqrPixels;
|
||||
|
||||
uint32_t *localBuf;
|
||||
uint32_t localBufSize;
|
||||
|
|
|
@ -22,6 +22,9 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
|||
setAutoFillBackground(true);
|
||||
setPalette(pal);
|
||||
|
||||
setMinimumWidth( GL_NES_WIDTH );
|
||||
setMinimumHeight( GL_NES_HEIGHT );
|
||||
|
||||
view_width = GL_NES_WIDTH;
|
||||
view_height = GL_NES_HEIGHT;
|
||||
|
||||
|
@ -30,6 +33,8 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
|||
rh = view_height;
|
||||
sdlRendW = 0;
|
||||
sdlRendH = 0;
|
||||
xscale = 2.0;
|
||||
yscale = 2.0;
|
||||
|
||||
devPixRatio = 1.0f;
|
||||
sdlWindow = NULL;
|
||||
|
@ -47,6 +52,7 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
|||
memset( localBuf, 0, localBufSize );
|
||||
}
|
||||
|
||||
sqrPixels = true;
|
||||
linearFilter = false;
|
||||
|
||||
if ( g_config )
|
||||
|
@ -213,16 +219,19 @@ void ConsoleViewSDL_t::render(void)
|
|||
nesHeight = nes_shm->nrow;
|
||||
}
|
||||
//printf(" %i x %i \n", nesWidth, nesHeight );
|
||||
float xscale = (float)view_width / (float)nesWidth;
|
||||
float yscale = (float)view_height / (float)nesHeight;
|
||||
xscale = (float)view_width / (float)nesWidth;
|
||||
yscale = (float)view_height / (float)nesHeight;
|
||||
|
||||
if (xscale < yscale )
|
||||
if ( sqrPixels )
|
||||
{
|
||||
yscale = xscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = yscale;
|
||||
if (xscale < yscale )
|
||||
{
|
||||
yscale = xscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
xscale = yscale;
|
||||
}
|
||||
}
|
||||
|
||||
rw=(int)(nesWidth*xscale);
|
||||
|
|
|
@ -25,25 +25,33 @@ class ConsoleViewSDL_t : public QWidget
|
|||
|
||||
void setLinearFilterEnable( bool ena );
|
||||
|
||||
bool getSqrPixelOpt(void){ return sqrPixels; };
|
||||
void setSqrPixelOpt( bool val ){ sqrPixels = val; return; };
|
||||
double getScaleX(void){ return xscale; };
|
||||
double getScaleY(void){ return yscale; };
|
||||
|
||||
protected:
|
||||
|
||||
//void paintEvent(QPaintEvent *event);
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
int view_width;
|
||||
int view_height;
|
||||
int view_width;
|
||||
int view_height;
|
||||
|
||||
double devPixRatio;
|
||||
int rw;
|
||||
int rh;
|
||||
int sx;
|
||||
int sy;
|
||||
int sdlRendW;
|
||||
int sdlRendH;
|
||||
double devPixRatio;
|
||||
double xscale;
|
||||
double yscale;
|
||||
int rw;
|
||||
int rh;
|
||||
int sx;
|
||||
int sy;
|
||||
int sdlRendW;
|
||||
int sdlRendH;
|
||||
|
||||
bool vsyncEnabled;
|
||||
bool linearFilter;
|
||||
bool vsyncEnabled;
|
||||
bool linearFilter;
|
||||
bool sqrPixels;
|
||||
|
||||
uint32_t *localBuf;
|
||||
uint32_t *localBuf;
|
||||
uint32_t localBufSize;
|
||||
|
||||
SDL_Window *sdlWindow;
|
||||
|
|
|
@ -183,6 +183,10 @@ int InitVideo(FCEUGI *gi)
|
|||
// check to see if we are showing FPS
|
||||
FCEUI_SetShowFPS(show_fps);
|
||||
|
||||
nes_shm->ncol = NWIDTH;
|
||||
nes_shm->nrow = s_tlines;
|
||||
nes_shm->pitch = GL_NES_WIDTH * 4;
|
||||
|
||||
#ifdef LSB_FIRST
|
||||
rmask = 0x00FF0000;
|
||||
gmask = 0x0000FF00;
|
||||
|
|
Loading…
Reference in New Issue