began integration of GTK into the SDL tree
see gui.cpp at r1601 for demonstration of how this SHOULD work currently, fceuX is creating its own new window instead of using GTKs window added flag GTK_GUI (in code for now, will add to scons build later) added line to sconstruct for GTK libraries (commented by default)
This commit is contained in:
parent
7af0329bf4
commit
86123d257e
|
@ -57,6 +57,9 @@ else:
|
||||||
if not conf.CheckLib('z', autoadd=1):
|
if not conf.CheckLib('z', autoadd=1):
|
||||||
print 'Did not find libz or z.lib, exiting!'
|
print 'Did not find libz or z.lib, exiting!'
|
||||||
Exit(1)
|
Exit(1)
|
||||||
|
### TODO: clean this up
|
||||||
|
## Uncomment below for experimental (broken) GTK support
|
||||||
|
#env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
|
||||||
|
|
||||||
### Lua platform defines
|
### Lua platform defines
|
||||||
### Applies to all files even though only lua needs it, but should be ok
|
### Applies to all files even though only lua needs it, but should be ok
|
||||||
|
|
|
@ -3,40 +3,57 @@
|
||||||
|
|
||||||
#include<SDL/SDL.h>
|
#include<SDL/SDL.h>
|
||||||
|
|
||||||
#define WIDTH 600
|
#include "../common/configSys.h"
|
||||||
#define HEIGHT 600
|
#include "sdl.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
|
//#define WIDTH 600
|
||||||
|
//#define HEIGHT 600
|
||||||
|
|
||||||
|
|
||||||
|
extern Config *g_config;
|
||||||
|
|
||||||
|
|
||||||
|
//SDL_Surface* screen = NULL;
|
||||||
|
//SDL_Surface* hello = NULL;
|
||||||
|
|
||||||
|
|
||||||
GtkWidget* MainWindow;
|
|
||||||
SDL_Surface* screen = NULL;
|
|
||||||
SDL_Surface* hello = NULL;
|
|
||||||
|
|
||||||
gint mainLoop(gpointer data)
|
gint mainLoop(gpointer data)
|
||||||
{
|
{
|
||||||
SDL_UpdateRect(screen, 0, 0, WIDTH, HEIGHT);
|
//SDL_UpdateRect(screen, 0, 0, xres, yres);
|
||||||
// TODO: integrate main SDL loop here
|
// TODO: integrate main SDL loop here
|
||||||
|
|
||||||
|
// test render
|
||||||
|
//SDL_BlitSurface (hello, NULL, screen, NULL);
|
||||||
|
|
||||||
SDL_BlitSurface (hello, NULL, screen, NULL);
|
//SDL_Flip( screen );
|
||||||
|
DoFun(0);
|
||||||
|
|
||||||
SDL_Flip( screen );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
|
gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
|
||||||
{
|
{
|
||||||
screen = SDL_SetVideoMode(event->width, event->height, 0, 0);
|
//???
|
||||||
|
//s_screen = SDL_SetVideoMode(event->width, event->height, 0, 0);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int InitGTKSubsystem(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
GtkWidget* MainWindow;
|
||||||
|
int xres, yres;
|
||||||
|
|
||||||
|
g_config->getOption("SDL.XResolution", &xres);
|
||||||
|
g_config->getOption("SDL.YResolution", &yres);
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_window_set_title(GTK_WINDOW(MainWindow), "fceuX GTK GUI - WIP");
|
gtk_window_set_title(GTK_WINDOW(MainWindow), "fceuX GTK GUI - WIP");
|
||||||
gtk_widget_set_usize(MainWindow, WIDTH, HEIGHT);
|
gtk_widget_set_usize(MainWindow, xres, yres);
|
||||||
gtk_widget_realize(MainWindow);
|
gtk_widget_realize(MainWindow);
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
|
@ -51,10 +68,7 @@ int main(int argc, char** argv)
|
||||||
gtk_container_add (GTK_CONTAINER(MainWindow), socket);
|
gtk_container_add (GTK_CONTAINER(MainWindow), socket);
|
||||||
|
|
||||||
gtk_widget_realize (socket);
|
gtk_widget_realize (socket);
|
||||||
|
|
||||||
|
|
||||||
// Hack to get SDL to use GTK window
|
|
||||||
// broken as fuck?
|
|
||||||
char SDL_windowhack[24];
|
char SDL_windowhack[24];
|
||||||
sprintf(SDL_windowhack, "SDL_WINDOWID=%ld", (long int)gtk_socket_get_id (GTK_SOCKET(socket)));
|
sprintf(SDL_windowhack, "SDL_WINDOWID=%ld", (long int)gtk_socket_get_id (GTK_SOCKET(socket)));
|
||||||
putenv(SDL_windowhack);
|
putenv(SDL_windowhack);
|
||||||
|
@ -67,28 +81,25 @@ int main(int argc, char** argv)
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, 0);
|
|
||||||
|
|
||||||
|
|
||||||
hello = SDL_LoadBMP( "hello.bmp" );
|
|
||||||
|
|
||||||
SDL_BlitSurface (hello, NULL, screen, NULL);
|
|
||||||
|
|
||||||
SDL_Flip( screen );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//screen = SDL_SetVideoMode(xres, yres, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
//hello = SDL_LoadBMP( "hello.bmp" );
|
||||||
|
|
||||||
|
|
||||||
// signal handlers
|
// signal handlers
|
||||||
g_signal_connect(G_OBJECT(MainWindow), "delete-event", gtk_main_quit, NULL);
|
g_signal_connect(G_OBJECT(MainWindow), "delete-event", gtk_main_quit, NULL);
|
||||||
gtk_idle_add(mainLoop, MainWindow);
|
//gtk_idle_add(mainLoop, MainWindow);
|
||||||
|
|
||||||
gtk_widget_show_all(MainWindow);
|
gtk_widget_show_all(MainWindow);
|
||||||
|
|
||||||
gtk_main();
|
// TODO: we're not going to want to use gtk_main here so we can control
|
||||||
SDL_Quit();
|
// the event loop and use SDL events rather than GTK events
|
||||||
|
//gtk_main();
|
||||||
|
//SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
extern Config *g_config;
|
extern Config *g_config;
|
||||||
|
|
||||||
// STATIC GLOBALS
|
// STATIC GLOBALS
|
||||||
static SDL_Surface *s_screen;
|
extern SDL_Surface *s_screen;
|
||||||
|
|
||||||
static SDL_Surface *s_BlitBuf; // Buffer when using hardware-accelerated blits.
|
static SDL_Surface *s_BlitBuf; // Buffer when using hardware-accelerated blits.
|
||||||
static SDL_Surface *s_IconSurface = NULL;
|
static SDL_Surface *s_IconSurface = NULL;
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
|
#ifndef __FCEU_SDL_VIDEO_H
|
||||||
|
#define __FCEU_SDL_VIDEO_H
|
||||||
uint32 PtoV(uint16 x, uint16 y);
|
uint32 PtoV(uint16 x, uint16 y);
|
||||||
bool FCEUD_ShouldDrawInputAids();
|
bool FCEUD_ShouldDrawInputAids();
|
||||||
|
|
||||||
|
static SDL_Surface *s_screen;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
//#define GTK_GUI
|
||||||
|
#ifdef GTK_GUI
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include "gui.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "throttle.h"
|
#include "throttle.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -678,6 +684,11 @@ SDL_GL_LoadLibrary(0);
|
||||||
// load the hotkeys from the config life
|
// load the hotkeys from the config life
|
||||||
setHotKeys();
|
setHotKeys();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef GTK_GUI
|
||||||
|
InitGTKSubsystem(argc, argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
// load the specified game
|
// load the specified game
|
||||||
error = LoadGame(argv[romIndex]);
|
error = LoadGame(argv[romIndex]);
|
||||||
if(error != 1) {
|
if(error != 1) {
|
||||||
|
@ -726,11 +737,17 @@ SDL_GL_LoadLibrary(0);
|
||||||
FCEU_LoadLuaCode(fname.c_str());
|
FCEU_LoadLuaCode(fname.c_str());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
//TODO: Work this bullshit out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// loop playing the game
|
// loop playing the game
|
||||||
while(GameInfo) {
|
while(GameInfo) {
|
||||||
DoFun(frameskip);
|
DoFun(frameskip);
|
||||||
|
#ifdef GTK_GUI
|
||||||
|
while(gtk_events_pending())
|
||||||
|
gtk_main_iteration_do(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
CloseGame();
|
CloseGame();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
|
#ifndef __FCEU_SDL_H
|
||||||
|
#define __FCEU_SDL_H
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "dface.h"
|
#include "dface.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
|
static void DoFun(int frameskip);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue