Added 3D emulation.

This commit is contained in:
masscat 2007-04-17 16:54:06 +00:00
parent 450b8aadb4
commit 08e5e7e605
1 changed files with 60 additions and 5 deletions

View File

@ -27,11 +27,16 @@
#include "globals.h" #include "globals.h"
#include "../debug.h" #include "../debug.h"
#ifdef GTKGLEXT_AVAILABLE
#include "../opengl_collector_3Demu.h"
#include "gdk_3Demu.h"
#endif
#include "DeSmuME.xpm" #include "DeSmuME.xpm"
#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) #define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20)
#define FPS_LIMITER_FRAME_PERIOD 20 #define FPS_LIMITER_FRAME_PERIOD 8
static SDL_sem *fps_limiter_semaphore; static SDL_sem *fps_limiter_semaphore;
/************************ CONFIG FILE *****************************/ /************************ CONFIG FILE *****************************/
@ -66,7 +71,11 @@ NULL
}; };
GPU3DInterface *core3DList[] = { GPU3DInterface *core3DList[] = {
&gpu3DNull &gpu3DNull
#ifdef GTKGLEXT_AVAILABLE
,
&gpu3D_opengl_collector
#endif
}; };
@ -79,15 +88,19 @@ struct screen_render_config {
struct configured_features { struct configured_features {
struct screen_render_config screen; struct screen_render_config screen;
int disable_sound; int disable_sound;
int disable_3d;
const char *nds_file; const char *nds_file;
}; };
static void static void
init_configured_features( struct configured_features *config) { init_configured_features( struct configured_features *config) {
config->disable_sound = 0; config->disable_sound = 0;
config->screen.opengl = 0; config->screen.opengl = 0;
config->screen.soft_colour = 0; config->screen.soft_colour = 0;
config->disable_3d = 0;
config->nds_file = NULL; config->nds_file = NULL;
} }
@ -100,11 +113,15 @@ fill_configured_features( struct configured_features *config,
for ( i = 1; i < argc && good_args; i++) { for ( i = 1; i < argc && good_args; i++) {
if ( strcmp( argv[i], "--help") == 0) { if ( strcmp( argv[i], "--help") == 0) {
printf( "USAGE: %s <nds-file>\n", argv[0]); printf( "USAGE: %s [OPTIONS] [nds-file]\n", argv[0]);
printf( "OPTIONS:\n"); printf( "OPTIONS:\n");
#ifdef GTKGLEXT_AVAILABLE #ifdef GTKGLEXT_AVAILABLE
printf( " --opengl-2d Enables using openGl for screen rendering\n"); printf( " --opengl-2d Enables using OpenGL for screen rendering\n");
printf( " --soft-convert Use software colour conversion during openGL rendering\n"); printf( " --soft-convert Use software colour conversion during OpenGL\n");
printf( " screen rendering. May produce better or worse\n");
printf( " frame rates depending on hardware.\n");
printf( "\n");
printf( " --disable-3d Disables the 3D emulation\n");
printf( "\n"); printf( "\n");
#endif #endif
printf( " --disable-sound Disables the sound emulation\n"); printf( " --disable-sound Disables the sound emulation\n");
@ -122,6 +139,9 @@ fill_configured_features( struct configured_features *config,
else if ( strcmp( argv[i], "--soft-convert") == 0) { else if ( strcmp( argv[i], "--soft-convert") == 0) {
config->screen.soft_colour = 1; config->screen.soft_colour = 1;
} }
else if ( strcmp( argv[i], "--disable-3d") == 0) {
config->disable_3d = 1;
}
#endif #endif
else { else {
if ( config->nds_file == NULL) { if ( config->nds_file == NULL) {
@ -1686,6 +1706,9 @@ common_gtk_main( struct configured_features *my_config) {
gtk_widget_realize ( top_screen_widget); gtk_widget_realize ( top_screen_widget);
glcontext = gtk_widget_get_gl_context( top_screen_widget); glcontext = gtk_widget_get_gl_context( top_screen_widget);
/*g_print("Window is direct? %d\n",
gdk_gl_context_is_direct( glcontext));*/
/* /*
*create the bottom screen drawing area. *create the bottom screen drawing area.
*/ */
@ -1776,6 +1799,38 @@ common_gtk_main( struct configured_features *my_config) {
return 1; return 1;
} }
/*
* Set the 3D emulation to use
*/
{
int use_null_3d = my_config->disable_3d;
#ifdef GTKGLEXT_AVAILABLE
if ( !use_null_3d) {
/* setup the gdk 3D emulation */
if ( init_opengl_gdk_3Demu()) {
NDS_3D_SetDriver ( 1);
if (!gpu3D->NDS_3D_Init ()) {
fprintf( stderr, "Failed to initialise openGL 3D emulation; "
"removing 3D support\n");
use_null_3d = 1;
}
}
else {
fprintf( stderr, "Failed to setup openGL 3D emulation; "
"removing 3D support\n");
use_null_3d = 1;
}
}
#endif
if ( use_null_3d) {
NDS_3D_SetDriver ( 0);
gpu3D->NDS_3D_Init();
}
}
/* Vérifie la ligne de commandes */ /* Vérifie la ligne de commandes */
if( my_config->nds_file != NULL) if( my_config->nds_file != NULL)