add rasterizer to gtk-glade, make it default renderer for cli,gtk,glade

This commit is contained in:
matusz 2009-03-29 17:51:26 +00:00
parent 443c3529d3
commit 1fb75500a0
4 changed files with 70 additions and 192 deletions

View File

@ -143,7 +143,7 @@ init_config( struct my_config *config) {
config->cflash_disk_image_file = NULL; config->cflash_disk_image_file = NULL;
config->engine_3d = 0; config->engine_3d = 1;
#ifdef INCLUDE_OPENGL_2D #ifdef INCLUDE_OPENGL_2D
config->opengl_2d = 0; config->opengl_2d = 0;

View File

@ -1,254 +1,129 @@
/* -*- Mode: C; c-basic-offset: 4 -*- /* -*- Mode: C; c-basic-offset: 4 -*-
* libglade - a library for building interfaces from XML files at runtime * libglade - a library for building interfaces from XML files at runtime
* Copyright (C) 1998-2002 James Henstridge <james@daa.com.au> * Copyright (C) 1998-2002 James Henstridge <james@daa.com.au>
* *
* glade-xml.c: implementation of core public interface functions * glade-xml.c: implementation of core public interface functions
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include "globals.h" #include "globals.h"
#include <glade/glade-xml.h> #include <glade/glade-xml.h>
#include <glade/glade-init.h> #include <glade/glade-init.h>
#include <glade/glade-build.h> #include <glade/glade-build.h>
#include <gmodule.h> #include <gmodule.h>
typedef struct _GladeXMLPrivate nopriv_GladeXMLPrivate; typedef struct _GladeXMLPrivate nopriv_GladeXMLPrivate;
struct _GladeXMLPrivate { struct _GladeXMLPrivate {
GladeInterface *tree; /* the tree for this GladeXML */
GladeInterface *tree; /* the tree for this GladeXML */ GtkTooltips *tooltips; /* if not NULL, holds all tooltip info */
GHashTable *name_hash;
GtkTooltips *tooltips; /* if not NULL, holds all tooltip info */ GHashTable *signals;
GtkWindow *toplevel;
GHashTable *name_hash; GtkAccelGroup *accel_group;
GtkWidget *focus_widget;
GHashTable *signals; GtkWidget *default_widget;
GList *deferred_props;
GtkWindow *toplevel;
GtkAccelGroup *accel_group;
GtkWidget *focus_widget;
GtkWidget *default_widget;
GList *deferred_props;
}; };
typedef struct _GladeSignalData GladeSignalData; typedef struct _GladeSignalData GladeSignalData;
struct _GladeSignalData { struct _GladeSignalData {
GObject *signal_object;
GObject *signal_object; char *signal_name;
char *connect_object; /* or NULL if there is none */
char *signal_name; gboolean signal_after;
char *connect_object; /* or NULL if there is none */
gboolean signal_after;
}; };
static void static void
autoconnect_foreach_StringObject(const char *signal_handler,
autoconnect_foreach_StringObject(const char *signal_handler, GList *signals, GList * signals, GModule * allsymbols)
GModule *allsymbols)
{ {
GCallback func;
GCallback func; if (!g_module_symbol(allsymbols, signal_handler, (void **) &func))
g_warning(_("could not find signal handler '%s'."),
signal_handler);
else
for (; signals != NULL; signals = signals->next) {
GladeSignalData *data = (GladeSignalData *) signals->data;
if (data->connect_object) {
GladeXML *self =
glade_get_widget_tree(GTK_WIDGET(data->signal_object));
char format[] = "%_\0\0";
if (sscanf(data->connect_object, "%%%c:", &format[1])) {
// this should solve 64bit problems but now memory gets
// (it should get) deallocated when program is destroyed
gpointer argument = g_malloc(sizeof(callback_arg));
sscanf(data->connect_object + 3, format, argument);
if (!g_module_symbol(allsymbols, signal_handler, (void **)&func)) // printf ("%f \n",obj);
if (data->signal_after)
g_signal_connect_after(data->signal_object, data->signal_name, func, argument);
else
g_signal_connect(data->signal_object, data->signal_name, func, argument);
} else {
g_warning(_("could not find signal handler '%s'."), signal_handler); GObject *other = (GObject *) g_hash_table_lookup(
self->priv->name_hash,
data->connect_object);
g_signal_connect_object(data->signal_object, data->signal_name, func, other,
(GConnectFlags) ((data->signal_after ? G_CONNECT_AFTER : 0) | G_CONNECT_SWAPPED));
}
else } else {
for (; signals != NULL; signals = signals->next) {
GladeSignalData *data = (GladeSignalData *) signals->data;
if (data->connect_object) {
GladeXML *self = glade_get_widget_tree(
GTK_WIDGET(data->signal_object));
char format[]="%_\0\0";
if (sscanf(data->connect_object,"%%%c:", &format[1])) {
// this should solve 64bit problems but now memory gets
// (it should get) deallocated when program is destroyed
gpointer argument = g_malloc(sizeof(callback_arg));
sscanf(data->connect_object+3,format, argument);
// printf ("%f \n",obj);
if (data->signal_after)
g_signal_connect_after(data->signal_object, data->signal_name,
func, argument);
else
g_signal_connect(data->signal_object, data->signal_name,
func, argument);
} else {
GObject *other = (GObject *) g_hash_table_lookup(self->priv->name_hash,
data->connect_object);
g_signal_connect_object(data->signal_object, data->signal_name,
func, other, (GConnectFlags) ((data->signal_after ? G_CONNECT_AFTER : 0)
| G_CONNECT_SWAPPED));
}
} else {
/* the signal_data argument is just a string, but may
* be helpful for someone */
if (data->signal_after)
g_signal_connect_after(data->signal_object,
data->signal_name, func, NULL);
else
g_signal_connect(data->signal_object, data->signal_name,
func, NULL);
}
}
/* the signal_data argument is just a string, but may
* be helpful for someone */
if (data->signal_after)
g_signal_connect_after(data->signal_object, data->signal_name, func, NULL);
else
g_signal_connect(data->signal_object, data->signal_name, func, NULL);
}
}
} }
/** /**
* glade_xml_signal_autoconnect_StringObject: * glade_xml_signal_autoconnect_StringObject:
* @self: the GladeXML object. * @self: the GladeXML object.
* *
* This function is a variation of glade_xml_signal_connect. It uses * This function is a variation of glade_xml_signal_connect. It uses
* gmodule's introspective features (by openning the module %NULL) to * gmodule's introspective features (by openning the module %NULL) to
* look at the application's symbol table. From here it tries to match * look at the application's symbol table. From here it tries to match
* the signal handler names given in the interface description with * the signal handler names given in the interface description with
* symbols in the application and connects the signals. * symbols in the application and connects the signals.
* *
* Note that this function will not work correctly if gmodule is not * Note that this function will not work correctly if gmodule is not
* supported on the platform. * supported on the platform.
*/ */
void void glade_xml_signal_autoconnect_StringObject(GladeXML * self)
glade_xml_signal_autoconnect_StringObject (GladeXML *self)
{ {
GModule *allsymbols; GModule *allsymbols;
nopriv_GladeXMLPrivate *priv;
nopriv_GladeXMLPrivate * priv;
g_return_if_fail(self != NULL); g_return_if_fail(self != NULL);
if (!g_module_supported()) if (!g_module_supported())
g_error("glade_xml_signal_autoconnect requires working gmodule");
g_error("glade_xml_signal_autoconnect requires working gmodule");
/* get a handle on the main executable -- use this to find symbols */ /* get a handle on the main executable -- use this to find symbols */
allsymbols = g_module_open(NULL, (GModuleFlags) 0); allsymbols = g_module_open(NULL, (GModuleFlags) 0);
priv = (nopriv_GladeXMLPrivate *) self->priv;
priv = (nopriv_GladeXMLPrivate *)self->priv; g_hash_table_foreach(priv->signals,
(GHFunc) autoconnect_foreach_StringObject,
g_hash_table_foreach(priv->signals, (GHFunc)autoconnect_foreach_StringObject, allsymbols);
allsymbols);
} }

View File

@ -25,6 +25,7 @@
#include "dTools/callbacks_dtools.h" #include "dTools/callbacks_dtools.h"
#include "globals.h" #include "globals.h"
#include "keyval_names.h" #include "keyval_names.h"
#include "rasterize.h"
#ifdef GDB_STUB #ifdef GDB_STUB
#include "../gdbstub.h" #include "../gdbstub.h"
@ -54,7 +55,8 @@ NULL
}; };
GPU3DInterface *core3DList[] = { GPU3DInterface *core3DList[] = {
&gpu3DNull &gpu3DNull,
&gpu3DRasterize
#ifdef GTKGLEXT_AVAILABLE #ifdef GTKGLEXT_AVAILABLE
, ,
&gpu3Dgl &gpu3Dgl
@ -71,7 +73,7 @@ struct configured_features {
int load_slot; int load_slot;
int software_colour_convert; int software_colour_convert;
int opengl_2d; int opengl_2d;
int disable_3d; int engine_3d;
int disable_limiter; int disable_limiter;
u16 arm9_gdb_port; u16 arm9_gdb_port;
@ -91,7 +93,7 @@ init_configured_features( struct configured_features *config) {
config->software_colour_convert = 0; config->software_colour_convert = 0;
config->opengl_2d = 0; config->opengl_2d = 0;
config->disable_3d = 0; config->engine_3d = 1;
config->disable_limiter = 0; config->disable_limiter = 0;
@ -122,7 +124,8 @@ fill_configured_features( struct configured_features *config,
\n\ \n\
--3d-engine=ENGINE Selects 3D rendering engine\n\ --3d-engine=ENGINE Selects 3D rendering engine\n\
0 = disabled\n\ 0 = disabled\n\
1 = gtkglext off-screen 3d opengl\n\n")); 1 = internal desmume rasterizer\n\
2 = gtkglext off-screen 3d opengl\n\n"));
#endif #endif
g_print( _("\ g_print( _("\
--disable-limiter Disables the 60 fps limiter\n\ --disable-limiter Disables the 60 fps limiter\n\
@ -169,7 +172,7 @@ fill_configured_features( struct configured_features *config,
int engine = strtoul( &argv[i][12], &end_char, 10); int engine = strtoul( &argv[i][12], &end_char, 10);
if ( engine == 0 || engine == 1) { if ( engine == 0 || engine == 1) {
config->disable_3d = !engine; config->engine_3d = engine;
} }
else { else {
g_printerr( _("Only 0(disabled) or 1(gtkglext off-screen 3d) are currently supported\n")); g_printerr( _("Only 0(disabled) or 1(gtkglext off-screen 3d) are currently supported\n"));
@ -526,7 +529,7 @@ common_gtk_glade_main( struct configured_features *my_config) {
gtk_widget_show(pDrawingArea2); gtk_widget_show(pDrawingArea2);
{ {
int use_null_3d = my_config->disable_3d; int use_null_3d = !my_config->engine_3d;
#ifdef GTKGLEXT_AVAILABLE #ifdef GTKGLEXT_AVAILABLE
if ( !use_null_3d) { if ( !use_null_3d) {

View File

@ -160,7 +160,7 @@ init_configured_features( struct configured_features *config)
config->opengl_2d = 0; config->opengl_2d = 0;
config->soft_colour = 0; config->soft_colour = 0;
config->engine_3d = 0; config->engine_3d = 1;
config->disable_limiter = 0; config->disable_limiter = 0;