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):
|
||||
print 'Did not find libz or z.lib, exiting!'
|
||||
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
|
||||
### Applies to all files even though only lua needs it, but should be ok
|
||||
|
|
|
@ -3,40 +3,57 @@
|
|||
|
||||
#include<SDL/SDL.h>
|
||||
|
||||
#define WIDTH 600
|
||||
#define HEIGHT 600
|
||||
#include "../common/configSys.h"
|
||||
#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)
|
||||
{
|
||||
SDL_UpdateRect(screen, 0, 0, WIDTH, HEIGHT);
|
||||
//SDL_UpdateRect(screen, 0, 0, xres, yres);
|
||||
// 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
MainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
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);
|
||||
|
||||
// event handlers
|
||||
|
@ -51,10 +68,7 @@ int main(int argc, char** argv)
|
|||
gtk_container_add (GTK_CONTAINER(MainWindow), socket);
|
||||
|
||||
gtk_widget_realize (socket);
|
||||
|
||||
|
||||
// Hack to get SDL to use GTK window
|
||||
// broken as fuck?
|
||||
|
||||
char SDL_windowhack[24];
|
||||
sprintf(SDL_windowhack, "SDL_WINDOWID=%ld", (long int)gtk_socket_get_id (GTK_SOCKET(socket)));
|
||||
putenv(SDL_windowhack);
|
||||
|
@ -67,28 +81,25 @@ int main(int argc, char** argv)
|
|||
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
|
||||
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_main();
|
||||
SDL_Quit();
|
||||
// TODO: we're not going to want to use gtk_main here so we can control
|
||||
// the event loop and use SDL events rather than GTK events
|
||||
//gtk_main();
|
||||
//SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
extern Config *g_config;
|
||||
|
||||
// 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_IconSurface = NULL;
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
#ifndef __FCEU_SDL_VIDEO_H
|
||||
#define __FCEU_SDL_VIDEO_H
|
||||
uint32 PtoV(uint16 x, uint16 y);
|
||||
bool FCEUD_ShouldDrawInputAids();
|
||||
|
||||
static SDL_Surface *s_screen;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
#include <math.h>
|
||||
|
||||
|
||||
//#define GTK_GUI
|
||||
#ifdef GTK_GUI
|
||||
#include <gtk/gtk.h>
|
||||
#include "gui.cpp"
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "throttle.h"
|
||||
#include "config.h"
|
||||
|
@ -678,6 +684,11 @@ SDL_GL_LoadLibrary(0);
|
|||
// load the hotkeys from the config life
|
||||
setHotKeys();
|
||||
|
||||
|
||||
#ifdef GTK_GUI
|
||||
InitGTKSubsystem(argc, argv);
|
||||
#endif
|
||||
|
||||
// load the specified game
|
||||
error = LoadGame(argv[romIndex]);
|
||||
if(error != 1) {
|
||||
|
@ -726,11 +737,17 @@ SDL_GL_LoadLibrary(0);
|
|||
FCEU_LoadLuaCode(fname.c_str());
|
||||
}*/
|
||||
|
||||
//TODO: Work this bullshit out
|
||||
|
||||
|
||||
|
||||
// loop playing the game
|
||||
while(GameInfo) {
|
||||
DoFun(frameskip);
|
||||
#ifdef GTK_GUI
|
||||
while(gtk_events_pending())
|
||||
gtk_main_iteration_do(FALSE);
|
||||
#endif
|
||||
}
|
||||
CloseGame();
|
||||
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
#ifndef __FCEU_SDL_H
|
||||
#define __FCEU_SDL_H
|
||||
|
||||
#include <SDL.h>
|
||||
#include "main.h"
|
||||
#include "dface.h"
|
||||
#include "input.h"
|
||||
|
||||
static void DoFun(int frameskip);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue