fixes missing defines on windows with no configure

gl moved in gdk_gl.*
This commit is contained in:
damdoum 2007-02-07 12:06:54 +00:00
parent 5face33a2a
commit 88161637c9
9 changed files with 290 additions and 148 deletions

View File

@ -1,7 +1,7 @@
bin_PROGRAMS = desmume-glade
desmume_glade_SOURCES = \
callbacks.c callbacks.h callbacks_IO.c callbacks_IO.h desmume.c desmume.h \
globals.h keyval_names.c main.c printscreen.c \
globals.h keyval_names.c main.c printscreen.c gdk_gl.c gdk_gl.h \
dTools/callbacks_1_ioregs.c dTools/callbacks_2_memview.c \
dTools/callbacks_3_palview.c dTools/callbacks_dtools.h \
dTools/dTools_display.h \

View File

@ -22,11 +22,9 @@
#include "callbacks_IO.h"
// comment for GL :D
#undef HAVE_LIBGDKGLEXT_X11_1_0
static u16 Cur_Keypad = 0;
int ScreenCoeff_Size=1;
float fScreenCoeff_Size=1.0;
gboolean ScreenRotate=FALSE;
gboolean Boost=FALSE;
int BoostFS=20;
@ -112,7 +110,6 @@ void decode_screen () {
pixel++;
}
}
#ifndef HAVE_LIBGDKGLEXT_X11_1_0
#define LOOP(a,b,c,d,e,f) \
L=W*ScreenCoeff_Size; \
BL=L*sizeof(u32); \
@ -129,14 +126,6 @@ void decode_screen () {
rgb32 += L; \
} \
}
#else
#define LOOP(a,b,c,d,e,f) \
for (a; b; c) { \
for (d; e; f) { \
rgb32 = image[y][x]; rgb32++; \
} \
}
#endif
/* load pixels in buffer accordingly */
if (ScreenRotate) {
W=RAW_H; H=RAW_W;
@ -149,14 +138,19 @@ void decode_screen () {
}
#ifndef HAVE_LIBGDKGLEXT_X11_1_0
// they are empty if no opengl
void init_GL_capabilities(GtkWidget * widget) {}
// else see gdk_gl.c / gdk_gl.h
BOOL my_gl_Begin (int screen) { return FALSE; }
void my_gl_End (int screen) {}
void init_GL_capabilities() {}
void init_GL(GtkWidget * widget, int screen) {}
void reshape (GtkWidget * widget) {}
void reshape (GtkWidget * widget, int screen) {}
gboolean screen (GtkWidget * widget, int off) {
int H,W,L;
if (off==0)
decode_screen();
if (ScreenRotate) {
W=RAW_H; H=RAW_W;
} else {
@ -171,122 +165,6 @@ gboolean screen (GtkWidget * widget, int off) {
GDK_RGB_DITHER_NONE,((guchar*)on_screen_image32)+off,L);
return TRUE;
}
#else /* if HAVE_LIBGDKGLEXT_X11_1_0 */
void init_GL_capabilities(GtkWidget * widget) {
GdkGLConfig * my_glConfig;
my_glConfig = gdk_gl_config_new_by_mode (
GDK_GL_MODE_RGB
| GDK_GL_MODE_DEPTH
| GDK_GL_MODE_DOUBLE
);
if (!gtk_widget_set_gl_capability(
widget,
my_glConfig,
NULL,
TRUE,
GDK_GL_RGBA_TYPE)) {
printf ("gtk_widget_set_gl_capability\n");
gtk_main_quit();
}
}
GLuint Textures[1];
void init_GL(GtkWidget * widget, int screen) {
GdkGLContext *my_glContext = gtk_widget_get_gl_context (widget);
GdkGLDrawable *my_glDrawable = gtk_widget_get_gl_drawable (widget);
if (!gdk_gl_drawable_gl_begin(my_glDrawable, my_glContext))
return;
/* Set the background black */
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &Textures[0]);
/*
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
*/
// beautiful quad
glBegin(GL_QUADS);
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
glColor3ub(128,255,0); glVertex2d(-0.75, 0.75);
glColor3ub(0,255,128); glVertex2d( 0.75, 0.75);
glColor3ub(0,0,255); glVertex2d( 0.75,-0.75);
glEnd();
glFlush ();
if (gdk_gl_drawable_is_double_buffered (my_glDrawable))
gdk_gl_drawable_swap_buffers (my_glDrawable);
gdk_gl_drawable_gl_end(my_glDrawable);
}
void reshape (GtkWidget * widget) {
GdkGLContext *my_glContext = gtk_widget_get_gl_context (widget);
GdkGLDrawable *my_glDrawable = gtk_widget_get_gl_drawable (widget);
if (!gdk_gl_drawable_gl_begin (my_glDrawable, my_glContext)) return;
glViewport (0, 0, widget->allocation.width, widget->allocation.height);
gdk_gl_drawable_gl_end (my_glDrawable);
}
gboolean screen (GtkWidget * widget, int screen) {
int H,W,off;
GdkGLContext *my_glContext = gtk_widget_get_gl_context (widget);
GdkGLDrawable *my_glDrawable = gtk_widget_get_gl_drawable (widget);
if (!gdk_gl_drawable_gl_begin(my_glDrawable, my_glContext))
return TRUE;
glLoadIdentity();
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// colorful quads so that there's something to see in case of pb
glBegin(GL_QUADS);
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
glColor3ub(128,255,0); glVertex2d(-0.75, 0.75);
glColor3ub(0,255,128); glVertex2d( 0.75, 0.75);
glColor3ub(0,0,255); glVertex2d( 0.75,-0.75);
glColor3ub(255,255,255);
glEnd();
off = (screen)?RAW_OFFSET:0;
if (ScreenRotate) {
glRotatef(90.0, 0.0, 0.0, 1.0);
}
glBindTexture(GL_TEXTURE_2D, Textures[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4,
256, 256, 0, GL_RGBA,
GL_UNSIGNED_SHORT_1_5_5_5_REV,
// GL_UNSIGNED_SHORT_5_5_5_1,
GPU_screen+off);
glBegin(GL_QUADS);
// texcoords 0.75 means 192, 1 means 256
glTexCoord2f(0.0, 0.00); glVertex2d(-1.0, 1.0);
glTexCoord2f(0.0, 0.75); glVertex2d(-1.0,-1.0);
glTexCoord2f(1.0, 0.75); glVertex2d( 1.0,-1.0);
glTexCoord2f(1.0, 0.00); glVertex2d( 1.0, 1.0);
glEnd();
glFlush ();
if (gdk_gl_drawable_is_double_buffered (my_glDrawable))
gdk_gl_drawable_swap_buffers (my_glDrawable);
gdk_gl_drawable_gl_end(my_glDrawable);
return TRUE;
}
#endif /* if HAVE_LIBGDKGLEXT_X11_1_0 */
@ -300,9 +178,6 @@ void on_wDraw_Sub_realize (GtkWidget *widget, gpointer user_data) {
}
gboolean on_wDraw_Main_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
#ifndef HAVE_LIBGDKGLEXT_X11_1_0
decode_screen();
#endif
return screen(widget, 0);
}
gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
@ -310,10 +185,10 @@ gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event
}
gboolean on_wDraw_Main_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) {
reshape(widget); return TRUE;
reshape(widget, 0); return TRUE;
}
gboolean on_wDraw_Sub_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) {
reshape(widget); return TRUE;
reshape(widget, 1); return TRUE;
}

View File

@ -22,9 +22,6 @@
#include "globals.h"
void init_GL_capabilities(GtkWidget * widget);
/* INPUT BUTTONS / KEYBOARD */
G_MODULE_EXPORT gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
G_MODULE_EXPORT gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data);

162
desmume/src/gtk-glade/gdk_gl.c Executable file
View File

@ -0,0 +1,162 @@
/* gdk_gl.c - this file is part of DeSmuME
*
* Copyright (C) 2007 Damien Nozay (damdoum)
* Author: damdoum at users.sourceforge.net
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gdk_gl.h"
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
GLuint Textures[1];
GdkGLConfig *my_glConfig=NULL;
GdkGLContext *my_glContext=NULL;
GdkGLDrawable *my_glDrawable[3]={NULL,NULL,NULL};
GtkWidget *pDrawingTexArea;
INLINE void my_gl_Identity() {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
}
INLINE void my_gl_DrawBeautifulQuad() {
// beautiful quad
glBegin(GL_QUADS);
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
glColor3ub(128,255,0); glVertex2d(-0.75, 0.75);
glColor3ub(0,255,128); glVertex2d( 0.75, 0.75);
glColor3ub(0,0,255); glVertex2d( 0.75,-0.75);
glEnd();
glColor3ub(255,255,255);
}
BOOL my_gl_Begin (int screen) {
return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext);
}
void my_gl_End (int screen) {
glFlush ();
if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen]))
gdk_gl_drawable_swap_buffers (my_glDrawable[screen]);
gdk_gl_drawable_gl_end(my_glDrawable[screen]);
}
void init_GL(GtkWidget * widget, int screen) {
// init GL capability
if (!gtk_widget_set_gl_capability(
widget, my_glConfig,
NULL, TRUE,
GDK_GL_RGBA_TYPE)) {
printf ("gtk_widget_set_gl_capability\n");
exit(1);
}
// realize so that we get a GdkWindow
gtk_widget_realize(widget);
// make sure we realize
gtk_events_pending();
my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget);
// shared context
if (my_glContext == NULL) {
// not initialized !
my_glContext = gtk_widget_get_gl_context(widget);
if (!my_gl_Begin(screen)) return;
/* Set the background black */
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
my_gl_DrawBeautifulQuad();
// generated ONE texture (display)
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &Textures[0]);
my_gl_End(screen);
}
reshape(widget, screen);
}
void init_GL_capabilities() {
my_glConfig = gdk_gl_config_new_by_mode (
GDK_GL_MODE_RGB
| GDK_GL_MODE_DEPTH
| GDK_GL_MODE_DOUBLE
);
// initialize 1st drawing area
init_GL(pDrawingArea,0);
// initialize 2nd drawing area (sharing context)
init_GL(pDrawingArea2,1);
}
void reshape (GtkWidget * widget, int screen) {
if (my_glDrawable[screen] == NULL ||
!my_gl_Begin(screen)) return;
glViewport (0, 0, widget->allocation.width, widget->allocation.height);
my_gl_End(screen);
}
INLINE void my_gl_Texture2D() {
glBindTexture(GL_TEXTURE_2D, Textures[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
INLINE void my_gl_ScreenTex() {
glTexImage2D(GL_TEXTURE_2D, 0, 4,
256, 512, 0, GL_RGBA,
GL_UNSIGNED_SHORT_1_5_5_5_REV,
// GL_UNSIGNED_SHORT_5_5_5_1,
GPU_screen);
}
void my_gl_ScreenTexApply(int screen) {
float off = (screen)?0.375:0;
glBegin(GL_QUADS);
// texcoords 0.375 means 192, 1 means 256
glTexCoord2f(0.0, off+0.000); glVertex2d(-1.0, 1.0);
glTexCoord2f(0.0, off+0.375); glVertex2d(-1.0,-1.0);
glTexCoord2f(1.0, off+0.375); glVertex2d( 1.0,-1.0);
glTexCoord2f(1.0, off+0.000); glVertex2d( 1.0, 1.0);
glEnd();
}
gboolean screen (GtkWidget * widget, int screen) {
int H,W;
if (!my_gl_Begin(screen)) return TRUE;
glLoadIdentity();
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
my_gl_DrawBeautifulQuad();
// rotate
if (ScreenRotate) glRotatef(90.0, 0.0, 0.0, 1.0);
// draw screen
my_gl_Texture2D();
if (screen==0) my_gl_ScreenTex();
my_gl_ScreenTexApply(screen);
my_gl_End(screen);
return TRUE;
}
#endif /* if HAVE_LIBGDKGLEXT_X11_1_0 */

30
desmume/src/gtk-glade/gdk_gl.h Executable file
View File

@ -0,0 +1,30 @@
/* gdk_gl.h - this file is part of DeSmuME
*
* Copyright (C) 2007 Damien Nozay (damdoum)
* Author: damdoum at users.sourceforge.net
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "globals.h"
BOOL my_gl_Begin (int screen);
void my_gl_End (int screen);
void init_GL_capabilities();
void init_GL(GtkWidget * widget, int screen);
void reshape (GtkWidget * widget, int screen);
gboolean screen (GtkWidget * widget, int off);

View File

@ -581,7 +581,7 @@
<child>
<widget class="GtkRadioMenuItem" id="size1x">
<property name="visible">True</property>
<property name="label" translatable="yes">1,0x</property>
<property name="label" translatable="yes">1x</property>
<property name="use_underline">True</property>
<property name="active">True</property>
<signal name="activate" handler="on_size1x_activate" last_modification_time="Mon, 01 Jan 2007 20:14:20 GMT"/>
@ -597,7 +597,6 @@
<signal name="activate" handler="on_size2x_activate" last_modification_time="Mon, 01 Jan 2007 20:14:20 GMT"/>
</widget>
</child>
<child>
<widget class="GtkRadioMenuItem" id="size3x">
<property name="visible">True</property>
@ -1055,7 +1054,6 @@
<property name="visible">False</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK</property>
<signal name="configure_event" handler="on_wDraw_Main_configure_event" last_modification_time="Mon, 05 Feb 2007 00:49:24 GMT"/>
<signal name="realize" handler="on_wDraw_Main_realize" after="yes" last_modification_time="Tue, 02 Jan 2007 10:27:08 GMT"/>
<signal name="expose_event" handler="on_wDraw_Main_expose_event" last_modification_time="Tue, 02 Jan 2007 10:27:18 GMT"/>
</widget>
<packing>
@ -1220,7 +1218,6 @@
<property name="visible">False</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
<signal name="configure_event" handler="on_wDraw_Sub_configure_event" last_modification_time="Mon, 05 Feb 2007 00:49:24 GMT"/>
<signal name="realize" handler="on_wDraw_Sub_realize" after="yes" last_modification_time="Tue, 02 Jan 2007 10:27:45 GMT"/>
<signal name="expose_event" handler="on_wDraw_Sub_expose_event" last_modification_time="Tue, 02 Jan 2007 10:27:52 GMT"/>
<signal name="button_press_event" handler="on_wDraw_Sub_button_press_event" last_modification_time="Tue, 02 Jan 2007 10:28:11 GMT"/>
<signal name="button_release_event" handler="on_wDraw_Sub_button_release_event" last_modification_time="Tue, 02 Jan 2007 10:28:18 GMT"/>

View File

@ -526,4 +526,73 @@ ARM7 cpu</property>
</child>
</widget>
<widget class="GtkDialog" id="wtool_4_TexView">
<property name="visible">True</property>
<property name="title" translatable="yes">Texture viewer</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<signal name="close" handler="gtk_widget_hide" last_modification_time="Tue, 06 Feb 2007 12:13:16 GMT"/>
<signal name="response" handler="gtk_widget_hide" last_modification_time="Tue, 06 Feb 2007 12:13:24 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area6">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="closebutton3">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkDrawingArea" id="wTexDrawArea">
<property name="width_request">256</property>
<property name="height_request">256</property>
<property name="events">GDK_EXPOSURE_MASK</property>
<signal name="configure_event" handler="on_wTexDrawArea_configure_event" last_modification_time="Tue, 06 Feb 2007 12:14:11 GMT"/>
<signal name="expose_event" handler="on_wTexDrawArea_expose_event" last_modification_time="Tue, 06 Feb 2007 12:14:34 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -35,6 +35,18 @@
//#include <SDL/SDL.h>
// more portable
#include "SDL.h"
// fix gtk-glade on windows with no configure
#ifndef DATADIR
#define DATADIR " "
#endif
#ifndef GLADEUI_UNINSTALLED_DIR
#define GLADEUI_UNINSTALLED_DIR "glade/"
#endif
// comment for GL :D
#undef HAVE_LIBGDKGLEXT_X11_1_0
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
#include <GL/gl.h>
#include <gdk/gdkgl.h>
@ -55,6 +67,7 @@
#include "../types.h"
#include "../saves.h"
#include "desmume.h"
#include "gdk_gl.h"
int Frameskip;
u16 Keypad_Temp[NB_KEYS];

View File

@ -223,6 +223,7 @@ int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
gtk_gl_init(&argc, &argv);
register_gl_fun(my_gl_Begin,my_gl_End);
#endif
if(argc == 2) commandLine_File = argv[1];
@ -251,14 +252,12 @@ int main(int argc, char *argv[]) {
pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main");
pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub");
init_GL_capabilities(pDrawingArea);
init_GL_capabilities(pDrawingArea2);
/* connect the signals in the interface */
glade_xml_signal_autoconnect(xml);
glade_xml_signal_autoconnect(xml_tools);
init_GL_capabilities();
/* Vérifie la ligne de commandes */
if(commandLine_File) {
if(desmume_open(commandLine_File) >= 0) {