Added logic to allow switching the Qt GUI video driver while program is running with out needing a restart... although a restart is still probably the safest.
This commit is contained in:
parent
4be5045fc7
commit
18c7c95ef3
|
@ -747,6 +747,11 @@ void ConsoleVideoConfDialog_t::driverChanged(int index)
|
||||||
g_config->save ();
|
g_config->save ();
|
||||||
|
|
||||||
printf("Note: A restart of the application is needed for video driver change to take effect...\n");
|
printf("Note: A restart of the application is needed for video driver change to take effect...\n");
|
||||||
|
|
||||||
|
if ( consoleWindow )
|
||||||
|
{
|
||||||
|
consoleWindow->loadVideoDriver( driver );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ConsoleVideoConfDialog_t::scalerChanged(int index)
|
void ConsoleVideoConfDialog_t::scalerChanged(int index)
|
||||||
|
|
|
@ -103,20 +103,6 @@ ConsoleViewGL_t::ConsoleViewGL_t(QWidget *parent)
|
||||||
|
|
||||||
ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
ConsoleViewGL_t::~ConsoleViewGL_t(void)
|
||||||
{
|
{
|
||||||
// Make sure the context is current and then explicitly
|
|
||||||
// destroy all underlying OpenGL resources.
|
|
||||||
makeCurrent();
|
|
||||||
|
|
||||||
// Free GL texture
|
|
||||||
if (gltexture)
|
|
||||||
{
|
|
||||||
//printf("Destroying GL Texture\n");
|
|
||||||
glDeleteTextures(1, &gltexture);
|
|
||||||
gltexture=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
doneCurrent();
|
|
||||||
|
|
||||||
if ( localBuf )
|
if ( localBuf )
|
||||||
{
|
{
|
||||||
free( localBuf ); localBuf = NULL;
|
free( localBuf ); localBuf = NULL;
|
||||||
|
@ -160,15 +146,36 @@ void ConsoleViewGL_t::buildTextures(void)
|
||||||
|
|
||||||
void ConsoleViewGL_t::initializeGL(void)
|
void ConsoleViewGL_t::initializeGL(void)
|
||||||
{
|
{
|
||||||
|
//printf("initializeGL\n");
|
||||||
|
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
// Set up the rendering context, load shaders and other resources, etc.:
|
// Set up the rendering context, load shaders and other resources, etc.:
|
||||||
//QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions();
|
//QOpenGLFunctions *gl = QOpenGLContext::currentContext()->functions();
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
//printf("GL Init!\n");
|
//printf("GL Init!\n");
|
||||||
|
|
||||||
buildTextures();
|
buildTextures();
|
||||||
|
|
||||||
|
connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ConsoleViewGL_t::cleanupGL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleViewGL_t::cleanupGL(void)
|
||||||
|
{
|
||||||
|
//printf("cleanupGL\n");
|
||||||
|
// Make sure the context is current and then explicitly
|
||||||
|
// destroy all underlying OpenGL resources.
|
||||||
|
makeCurrent();
|
||||||
|
|
||||||
|
// Free GL texture
|
||||||
|
if (gltexture)
|
||||||
|
{
|
||||||
|
//printf("Destroying GL Texture\n");
|
||||||
|
glDeleteTextures(1, &gltexture);
|
||||||
|
gltexture=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleViewGL_t::resizeGL(int w, int h)
|
void ConsoleViewGL_t::resizeGL(int w, int h)
|
||||||
|
|
|
@ -69,5 +69,6 @@ class ConsoleViewGL_t : public QOpenGLWidget, protected QOpenGLFunctions
|
||||||
uint32_t localBufSize;
|
uint32_t localBufSize;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void cleanupGL(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ ConsoleViewSDL_t::ConsoleViewSDL_t(QWidget *parent)
|
||||||
setMinimumWidth( 256 );
|
setMinimumWidth( 256 );
|
||||||
setMinimumHeight( 224 );
|
setMinimumHeight( 224 );
|
||||||
setFocusPolicy(Qt::StrongFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
view_width = GL_NES_WIDTH;
|
view_width = GL_NES_WIDTH;
|
||||||
view_height = GL_NES_HEIGHT;
|
view_height = GL_NES_HEIGHT;
|
||||||
|
@ -103,6 +104,7 @@ ConsoleViewSDL_t::~ConsoleViewSDL_t(void)
|
||||||
{
|
{
|
||||||
free( localBuf ); localBuf = NULL;
|
free( localBuf ); localBuf = NULL;
|
||||||
}
|
}
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleViewSDL_t::setLinearFilterEnable( bool ena )
|
void ConsoleViewSDL_t::setLinearFilterEnable( bool ena )
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
|
@ -555,6 +556,7 @@ void consoleWin_t::createMainMenu(void)
|
||||||
QMenu *subMenu;
|
QMenu *subMenu;
|
||||||
QActionGroup *group;
|
QActionGroup *group;
|
||||||
int useNativeMenuBar;
|
int useNativeMenuBar;
|
||||||
|
//QShortcut *shortcut;
|
||||||
QStyle *style;
|
QStyle *style;
|
||||||
|
|
||||||
style = this->style();
|
style = this->style();
|
||||||
|
@ -572,13 +574,16 @@ void consoleWin_t::createMainMenu(void)
|
||||||
fileMenu = menubar->addMenu(tr("&File"));
|
fileMenu = menubar->addMenu(tr("&File"));
|
||||||
|
|
||||||
// File -> Open ROM
|
// File -> Open ROM
|
||||||
openROM = new QAction(tr("&Open ROM"), this);
|
openROM = new QAction(tr("&Open ROM\tCtrl+O"), this);
|
||||||
openROM->setShortcuts(QKeySequence::Open);
|
openROM->setShortcuts(QKeySequence::Open);
|
||||||
openROM->setStatusTip(tr("Open ROM File"));
|
openROM->setStatusTip(tr("Open ROM File"));
|
||||||
//openROM->setIcon( QIcon(":icons/rom.png") );
|
//openROM->setIcon( QIcon(":icons/rom.png") );
|
||||||
//openROM->setIcon( style->standardIcon( QStyle::SP_FileIcon ) );
|
//openROM->setIcon( style->standardIcon( QStyle::SP_FileIcon ) );
|
||||||
openROM->setIcon( style->standardIcon( QStyle::SP_FileDialogStart ) );
|
openROM->setIcon( style->standardIcon( QStyle::SP_FileDialogStart ) );
|
||||||
connect(openROM, SIGNAL(triggered()), this, SLOT(openROMFile(void)) );
|
connect(openROM, SIGNAL(triggered()), this, SLOT(openROMFile(void)) );
|
||||||
|
|
||||||
|
//shortcut = new QShortcut( QKeySequence::Open, this );
|
||||||
|
//connect(shortcut, SIGNAL(activated()), this, SLOT(openROMFile(void)) );
|
||||||
|
|
||||||
fileMenu->addAction(openROM);
|
fileMenu->addAction(openROM);
|
||||||
|
|
||||||
|
@ -1282,6 +1287,56 @@ void consoleWin_t::createMainMenu(void)
|
||||||
helpMenu->addAction(act);
|
helpMenu->addAction(act);
|
||||||
};
|
};
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
int consoleWin_t::loadVideoDriver( int driverId )
|
||||||
|
{
|
||||||
|
if ( driverId )
|
||||||
|
{ // SDL Driver
|
||||||
|
if ( viewport_SDL != NULL )
|
||||||
|
{ // Already Loaded
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( viewport_GL != NULL )
|
||||||
|
{
|
||||||
|
if ( viewport_GL == centralWidget() )
|
||||||
|
{
|
||||||
|
takeCentralWidget();
|
||||||
|
}
|
||||||
|
delete viewport_GL;
|
||||||
|
|
||||||
|
viewport_GL = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
viewport_SDL = new ConsoleViewSDL_t(this);
|
||||||
|
|
||||||
|
setCentralWidget(viewport_SDL);
|
||||||
|
|
||||||
|
viewport_SDL->init();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // OpenGL Driver
|
||||||
|
if ( viewport_GL != NULL )
|
||||||
|
{ // Already Loaded
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( viewport_SDL != NULL )
|
||||||
|
{
|
||||||
|
if ( viewport_SDL == centralWidget() )
|
||||||
|
{
|
||||||
|
takeCentralWidget();
|
||||||
|
}
|
||||||
|
delete viewport_SDL;
|
||||||
|
|
||||||
|
viewport_SDL = NULL;
|
||||||
|
}
|
||||||
|
viewport_GL = new ConsoleViewGL_t(this);
|
||||||
|
|
||||||
|
setCentralWidget(viewport_GL);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
void consoleWin_t::clearRomList(void)
|
void consoleWin_t::clearRomList(void)
|
||||||
{
|
{
|
||||||
std::list <std::string*>::iterator it;
|
std::list <std::string*>::iterator it;
|
||||||
|
|
|
@ -113,6 +113,8 @@ class consoleWin_t : public QMainWindow
|
||||||
int getMaxSchedPriority(void);
|
int getMaxSchedPriority(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int loadVideoDriver( int driverId );
|
||||||
|
|
||||||
emulatorThread_t *emulatorThread;
|
emulatorThread_t *emulatorThread;
|
||||||
|
|
||||||
void addRecentRom( const char *rom );
|
void addRecentRom( const char *rom );
|
||||||
|
|
Loading…
Reference in New Issue