added functional GTK2/SDL framework

currently seperate from all fceux code but will soon be integrated into fceux 
in order to create an integrated UI on the linux build
This commit is contained in:
punkrockguy318 2009-12-17 06:19:08 +00:00
parent efaa3ebb4d
commit 7af0329bf4
4 changed files with 116 additions and 18 deletions

4
src/drivers/sdl/build_gui.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
# builds the gtk2 gui test app
# requires gtk2 libraries
g++ `pkg-config --cflags --libs gtk+-2.0` -lSDL gui.cpp -o gui

94
src/drivers/sdl/gui.cpp Normal file
View File

@ -0,0 +1,94 @@
#include<gtk/gtk.h>
#include<gdk/gdkx.h>
#include<SDL/SDL.h>
#define WIDTH 600
#define HEIGHT 600
GtkWidget* MainWindow;
SDL_Surface* screen = NULL;
SDL_Surface* hello = NULL;
gint mainLoop(gpointer data)
{
SDL_UpdateRect(screen, 0, 0, WIDTH, HEIGHT);
// TODO: integrate main SDL loop here
SDL_BlitSurface (hello, NULL, screen, NULL);
SDL_Flip( screen );
return TRUE;
}
gint configureEvent (GtkWidget* widget, GdkEventConfigure* event)
{
screen = SDL_SetVideoMode(event->width, event->height, 0, 0);
return TRUE;
}
int main(int argc, char** argv)
{
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_realize(MainWindow);
// event handlers
gtk_widget_add_events(MainWindow, GDK_BUTTON_PRESS_MASK);
gtk_signal_connect(GTK_OBJECT(MainWindow), "configure_event",
GTK_SIGNAL_FUNC(configureEvent), 0);
GtkWidget* socket = gtk_socket_new();
gtk_widget_show (socket) ;
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);
// init SDL
if ( SDL_Init(SDL_INIT_VIDEO) < 0 )
{
fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError());
gtk_main_quit();
}
screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, 0);
hello = SDL_LoadBMP( "hello.bmp" );
SDL_BlitSurface (hello, NULL, screen, NULL);
SDL_Flip( screen );
// signal handlers
g_signal_connect(G_OBJECT(MainWindow), "delete-event", gtk_main_quit, NULL);
gtk_idle_add(mainLoop, MainWindow);
gtk_widget_show_all(MainWindow);
gtk_main();
SDL_Quit();
return 0;
}

BIN
src/drivers/sdl/hello.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 833 KiB

View File

@ -68,7 +68,6 @@ static int noconfig;
char *DriverUsage="\
--pal {0|1} Uses PAL timing.\n\
--gamegenie {0|1} Enables emulated Game Genie.\n\
--nospritelim {0|1} Disables the 8 sprites per scanline limitation.\n\
--newppu {0|1} Enables the new PPU core. (WARNING: May break savestates)\n\
--frameskip x Sets # of frames to skip per emulated frame.\n\
--xres x Sets horizontal resolution to x for full screen mode.\n\
@ -80,29 +79,13 @@ char *DriverUsage="\
--(x/y)stretch {0|1} Stretches to fill surface on x/y axis (OpenGL only).\n\
--bpp {8|16|32} Sets bits per pixel.\n\
--opengl {0|1} Enables OpenGL support.\n\
--doublebuf {0|1} Enables SDL double-buffering if x is nonzero.\n\
--fullscreen {0|1} Enables full screen mode.\n\
--clipsides {0|1} Clips left and rightmost 8 columns of pixels.\n\
--noframe {0|1} Hides title bar and window decorations.\n\
--slstart {0-239} Sets the first drawn emulated scanline.\n\
--special {1-4} Use special video scaling filters\n\
(1 = hq2x 2 = Scale2x 3 = hq3x 4 = Scale3x)\n\
--slend {0-239} Sets the last drawn emulated scanline.\n\
--ntsccolor {0|1} Emulates an NTSC TV's colors.\n\
--hue x Sets hue for NTSC color emulation.\n\
--tint x Sets tint for NTSC color emulation.\n\
--palette f Loads a custom global palette from file f.\n\
--sound {0|1} Enables sound.\n\
--soundrate x Sets sound playback rate to x Hz.\n\
--soundq {0|1} Enables high sound quality.\n\
--soundbufsize x Sets sound buffer size to x ms.\n\
--volume {0-150} Sets volume.\n\
--trianglevol {0-256} Sets Triangle volume.\n\
--square1vol {0-256} Sets Square 1 volume.\n\
--square2vol {0-256} Sets Square 2 volume.\n\
--noisevol {0-256} Sets Noise volume.\n\
--pcmvol {0-256} Sets PCM volume.\n\
--lowpass {0|1} Enables low-pass filter if x is nonzero.\n\
--soundrecord f Records sound to file f.\n\
--input(1,2) d Set the input device for input 1 or 2.\n\
Devices: gamepad zapper powerpad.0 powerpad.1 arkanoid\n\
@ -126,7 +109,24 @@ char *DriverUsage="\
--netkey s, -k s Uses key 's' to create a unique session for the game loaded.\n\
--players x, -l x Sets the number of local players.\n\
*/
// these should be moved to the man file
// --nospritelim {0|1} Disables the 8 sprites per scanline limitation.\n\
//--trianglevol {0-256} Sets Triangle volume.\n\
//--square1vol {0-256} Sets Square 1 volume.\n\
//--square2vol {0-256} Sets Square 2 volume.\n\
//--noisevol {0-256} Sets Noise volume.\n\
//--pcmvol {0-256} Sets PCM volume.\n\
//--lowpass {0|1} Enables low-pass filter if x is nonzero.\n\
//--doublebuf {0|1} Enables SDL double-buffering if x is nonzero.\n\
//--slend {0-239} Sets the last drawn emulated scanline.\n\
//--ntsccolor {0|1} Emulates an NTSC TV's colors.\n\
//--hue x Sets hue for NTSC color emulation.\n\
//--tint x Sets tint for NTSC color emulation.\n\
//--soundrate x Sets sound playback rate to x Hz.\n\
//--soundq {0|1} Enables high sound quality.\n\
//--soundbufsize x Sets sound buffer size to x ms.\n\
//--slstart {0-239} Sets the first drawn emulated scanline.\n\
//--clipsides {0|1} Clips left and rightmost 8 columns of pixels.\n\
// global configuration object
Config *g_config;