diff --git a/desmume/src/gtk-glade/callbacks.c b/desmume/src/gtk-glade/callbacks.c
index 637453ac0..e92092d49 100755
--- a/desmume/src/gtk-glade/callbacks.c
+++ b/desmume/src/gtk-glade/callbacks.c
@@ -24,6 +24,7 @@
/* globals */
int Frameskip = 0;
+gboolean ScreenRightForce=FALSE;
gboolean ScreenRight=FALSE;
gboolean ScreenGap=FALSE;
gboolean ScreenInvert=FALSE;
@@ -48,20 +49,23 @@ void enable_rom_features() {
void MAINWINDOW_RESIZE() {
GtkWidget * spacer1 = glade_xml_get_widget(xml, "misc_sep3");
GtkWidget * spacer2 = glade_xml_get_widget(xml, "misc_sep4");
- int dim = 66 * ScreenCoeff_Size[0];
+ int dim1,dim2;
BOOL rotate = (ScreenRotate==90.0 || ScreenRotate==270.0 );
- /* sees whether we want a gap */
- if (!ScreenGap) dim = -1;
- if (ScreenRight && rotate) {
- gtk_widget_set_usize(spacer1, dim, -1);
- } else if (!ScreenRight && !rotate) {
- gtk_widget_set_usize(spacer2, -1, dim);
- } else {
- gtk_widget_set_usize(spacer1, -1, -1);
- gtk_widget_set_usize(spacer2, -1, -1);
- }
+ dim1 = dim2 = 66 * ScreenCoeff_Size[0];
+ /* sees whether we want a gap */
+ if (!ScreenGap) dim1 = dim2 = -1;
+ if (ScreenRight == rotate) {
+ if (ScreenRight)
+ dim2 = -1;
+ else
+ dim1 = -1;
+ } else {
+ dim1 = dim2 = -1;
+ }
+ gtk_widget_set_usize(spacer1, dim1, -1);
+ gtk_widget_set_usize(spacer2, -1, dim2);
gtk_window_resize ((GtkWindow*)pWindow,1,1);
}
@@ -203,21 +207,25 @@ void gtk_table_reattach(GtkTable * table, GtkWidget * w,
void rightscreen(BOOL apply) {
GtkWidget *chk = glade_xml_get_widget(xml, "wvb_2_Sub");
- GtkTable *table = glade_xml_get_widget(xml, "table_layout");
+ GtkTable *table = (GtkTable *)glade_xml_get_widget(xml, "table_layout");
- if (apply) {
+ ScreenRight = apply || ScreenRightForce;
+ if (ScreenRight) {
/* we want to change the layout, lower screen goes right */
gtk_table_reattach(table, pDrawingArea2,
3,4, 0,1, 0,0, 0,0);
gtk_table_reattach(table, chk,
4,5, 0,1, 0,0, 0,0);
- } else if (!ScreenRight) {
+ } else {
/* we want to change the layout, lower screen goes down */
gtk_table_reattach(table, pDrawingArea2,
1,2, 2,3, 0,0, 0,0);
gtk_table_reattach(table, chk,
0,1, 2,3, 0,0, 0,0);
+ ScreenRight = FALSE;
}
+
+ gtk_widget_queue_resize (GTK_WIDGET (table));
/* pack the window */
MAINWINDOW_RESIZE();
@@ -322,8 +330,8 @@ void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data) {
}
void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data) {
- ScreenRight=gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
- rightscreen(ScreenRight);
+ ScreenRightForce=gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
+ rightscreen(ScreenRightForce);
}
void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) {
diff --git a/desmume/src/gtk-glade/callbacks_IO.c b/desmume/src/gtk-glade/callbacks_IO.c
index 932d8e568..2e45a2070 100755
--- a/desmume/src/gtk-glade/callbacks_IO.c
+++ b/desmume/src/gtk-glade/callbacks_IO.c
@@ -81,8 +81,8 @@ void black_screen () {
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, int screen) {}
+void init_GL(GtkWidget * widget, ...) {}
+void reshape (GtkWidget * widget, ...) {}
int has_pix_col_map=0;
u32 pix_col_map[0x8000];
diff --git a/desmume/src/gtk-glade/gdk_gl.c b/desmume/src/gtk-glade/gdk_gl.c
index fe07a49a7..54c4058db 100755
--- a/desmume/src/gtk-glade/gdk_gl.c
+++ b/desmume/src/gtk-glade/gdk_gl.c
@@ -24,17 +24,17 @@
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
-GLuint Textures[1];
+GLuint Textures[2];
GdkGLConfig *my_glConfig=NULL;
-GdkGLContext *my_glContext=NULL;
+GdkGLContext *my_glContext[3]={NULL,NULL,NULL};
GdkGLDrawable *my_glDrawable[3]={NULL,NULL,NULL};
GtkWidget *pDrawingTexArea;
INLINE void my_gl_Identity() {
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
}
INLINE void my_gl_DrawBeautifulQuad() {
@@ -50,22 +50,22 @@ INLINE void my_gl_DrawBeautifulQuad() {
}
BOOL my_gl_Begin (int screen) {
- return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext);
+ return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext[screen]);
}
void my_gl_End (int screen) {
if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen]))
gdk_gl_drawable_swap_buffers (my_glDrawable[screen]);
else
- glFlush ();
+ glFlush();
gdk_gl_drawable_gl_end(my_glDrawable[screen]);
}
-void init_GL(GtkWidget * widget, int screen) {
+void init_GL(GtkWidget * widget, int screen, int share_num) {
// init GL capability
if (!gtk_widget_set_gl_capability(
widget, my_glConfig,
- NULL, TRUE,
+ &my_glContext[share_num], TRUE,
GDK_GL_RGBA_TYPE)) {
printf ("gtk_widget_set_gl_capability\n");
exit(1);
@@ -76,22 +76,26 @@ void init_GL(GtkWidget * widget, int screen) {
while (gtk_events_pending()) gtk_main_iteration();
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, 1.0f);
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
- // generated ONE texture (display)
- glEnable(GL_TEXTURE_2D);
- glGenTextures(1, &Textures[0]);
-
- my_gl_End(screen);
+ if (screen == share_num) {
+ my_glContext[screen] = gtk_widget_get_gl_context(widget);
+ } else {
+ my_glContext[screen] = my_glContext[share_num];
+ return;
}
+
+ 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();
+
+ // generate ONE texture (display)
+ glEnable(GL_TEXTURE_2D);
+ glGenTextures(2, Textures);
+
+ my_gl_End(screen);
reshape(widget, screen);
}
@@ -102,9 +106,11 @@ void init_GL_capabilities() {
| GDK_GL_MODE_DOUBLE
);
// initialize 1st drawing area
- init_GL(pDrawingArea,0);
+ init_GL(pDrawingArea,0,0);
// initialize 2nd drawing area (sharing context)
- init_GL(pDrawingArea2,1);
+ init_GL(pDrawingArea2,1,0);
+
+ init_GL(pDrawingAreaTex,2,2);
}
void reshape (GtkWidget * widget, int screen) {
@@ -145,12 +151,34 @@ void my_gl_ScreenTexApply(int screen) {
glEnd();
}
+void other_screen (GtkWidget * widget, int screen) {
+ if (!my_gl_Begin(screen)) return TRUE;
+
+ my_gl_Identity();
+ glClear( GL_COLOR_BUFFER_BIT );
+
+ 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();
+ my_gl_End(screen);
+}
+
gboolean screen (GtkWidget * widget, int viewportscreen) {
int H,W,screen;
+
+ if (viewportscreen > 1) {
+ other_screen(widget,viewportscreen);
+ return TRUE;
+ }
+
// we take care to draw the right thing the right place
// we need to rearrange widgets not to use this trick
screen = (ScreenInvert)?1-viewportscreen:viewportscreen;
// screen = viewportscreen;
+
if (!my_gl_Begin(viewportscreen)) return TRUE;
glLoadIdentity();
@@ -163,13 +191,13 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
// draw screen
my_gl_Texture2D();
- if (viewportscreen==0) my_gl_ScreenTex();
+ if (viewportscreen==0) {
+ my_gl_ScreenTex();
+ }
my_gl_ScreenTexApply(screen);
}
-
my_gl_End(viewportscreen);
return TRUE;
}
#endif /* if HAVE_LIBGDKGLEXT_X11_1_0 */
-
diff --git a/desmume/src/gtk-glade/gdk_gl.h b/desmume/src/gtk-glade/gdk_gl.h
index c20304157..efc4d4aa6 100755
--- a/desmume/src/gtk-glade/gdk_gl.h
+++ b/desmume/src/gtk-glade/gdk_gl.h
@@ -34,6 +34,6 @@ BOOL my_gl_Begin (int screen);
void my_gl_End (int screen);
void init_GL_capabilities();
-void init_GL(GtkWidget * widget, int screen);
+void init_GL(GtkWidget * widget, int screen, int share_num);
void reshape (GtkWidget * widget, int screen);
gboolean screen (GtkWidget * widget, int off);
diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/desmume/src/gtk-glade/glade/DeSmuMe.glade
index 17685bd95..96d960c5b 100755
--- a/desmume/src/gtk-glade/glade/DeSmuMe.glade
+++ b/desmume/src/gtk-glade/glade/DeSmuMe.glade
@@ -1271,6 +1271,25 @@
+
+
+
+ False
+ 256
+ 192
+ GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK
+
+
+
+
+ 3
+ 4
+ 2
+ 3
+
+
+
+
0
diff --git a/desmume/src/gtk-glade/globals.h b/desmume/src/gtk-glade/globals.h
index c8c57aabd..f8cae7914 100755
--- a/desmume/src/gtk-glade/globals.h
+++ b/desmume/src/gtk-glade/globals.h
@@ -105,8 +105,7 @@ u16 Keypad_Temp[NB_KEYS];
/* main.c */
GtkWidget * pWindow;
-GtkWidget * pDrawingArea;
-GtkWidget * pDrawingArea2;
+GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex;
GladeXML * xml, * xml_tools;
typedef void (*VoidFunPtr)();
diff --git a/desmume/src/gtk-glade/main.c b/desmume/src/gtk-glade/main.c
index d07c40d8a..ada42bd6a 100755
--- a/desmume/src/gtk-glade/main.c
+++ b/desmume/src/gtk-glade/main.c
@@ -26,8 +26,7 @@
#include "globals.h"
GtkWidget * pWindow;
-GtkWidget * pDrawingArea;
-GtkWidget * pDrawingArea2;
+GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex;
GladeXML * xml, * xml_tools;
SoundInterface_struct *SNDCoreList[] = {
@@ -252,6 +251,8 @@ int main(int argc, char *argv[]) {
pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main");
pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub");
+ pDrawingAreaTex = glade_xml_get_widget(xml, "wDraw_Tex");
+
/* connect the signals in the interface */
glade_xml_signal_autoconnect_StringObject(xml);
glade_xml_signal_autoconnect_StringObject(xml_tools);
@@ -276,6 +277,7 @@ int main(int argc, char *argv[]) {
gtk_widget_show(pDrawingArea);
gtk_widget_show(pDrawingArea2);
+ //gtk_widget_show(pDrawingAreaTex);
/* start event loop */
gtk_main();