diff --git a/desmume/src/GPU.c b/desmume/src/GPU.c index 9150e8f50..fee2c77a9 100644 --- a/desmume/src/GPU.c +++ b/desmume/src/GPU.c @@ -1624,6 +1624,8 @@ void GPU_ligne(NDS_Screen * screen, u16 l) // FIXME !!! /* capture */ +#if 0 +// to be done with opengl capcnt = &gpu->dispCapCnt.bits; if (capcnt->Capture_Enable) { @@ -1713,16 +1715,25 @@ void GPU_ligne(NDS_Screen * screen, u16 l) break; } } +#endif /* end of capture */ +#ifndef HAVE_LIBGDKGLEXT_X11_1_0 +// damdoum : +// brightness done with opengl +// test are ok (gfx_test_brightness) +// now, if we are going to support 3D, this becomes dead code +// because it is obvious we'll use openGL / mesa3D + +#ifdef BRIGHT_TABLES + calc_bright_colors(); +#endif + // Apply final brightness adjust (MASTER_BRIGHT) // Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS) /* Mightymax> it should be more effective if the windowmanager applies brightness when drawing */ /* it will most likly take acceleration, while we are stuck here with CPU power */ -#ifdef BRIGHT_TABLES - calc_bright_colors(); -#endif switch (gpu->masterBright.bits.Mode) { // Disabled @@ -1829,4 +1840,5 @@ void GPU_ligne(NDS_Screen * screen, u16 l) case 3: break; } +#endif } diff --git a/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c b/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c index da338df20..63c107d48 100755 --- a/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c +++ b/desmume/src/gtk-glade/dTools/callbacks_4_tileview.c @@ -106,19 +106,40 @@ static void refresh() { // this little thing doesnt display properly // nothing drawn... - + // seems that is the context is not shared there is a pb switching context +/* if (!my_gl_Begin(gl_context_num)) return; + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); my_gl_DrawBeautifulQuad(); my_gl_End(gl_context_num); return; +*/ if (!my_gl_Begin(gl_context_num)) return; + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + glEnable(GL_TEXTURE_2D); glGenTextures(1, &Textures); //proxy glBindTexture(GL_TEXTURE_2D, Textures); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + 256, 256, 0, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0); + glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0); + glEnd(); + + glDeleteTextures(1, &Textures); + + my_gl_End(gl_context_num); + return; + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); @@ -169,10 +190,10 @@ static void refresh() { } glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0); - glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0); - glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0); - glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0); + glTexCoord2f(0.0, 0.0); glVertex2d(-0.5, 0.5); + glTexCoord2f(0.0, 1.0); glVertex2d(-0.5,-0.5); + glTexCoord2f(1.0, 1.0); glVertex2d( 0.5,-0.5); + glTexCoord2f(1.0, 0.0); glVertex2d( 0.5, 0.5); glEnd(); glDeleteTextures(1, &Textures); @@ -190,7 +211,7 @@ static void initialize() { combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory"); init_combo_memory(combo, mem_addr); - gl_context_num = init_GL_free(wPaint); + gl_context_num = init_GL_free_s(wPaint,0); gtk_widget_show(wPaint); init=TRUE; } diff --git a/desmume/src/gtk-glade/gdk_gl.c b/desmume/src/gtk-glade/gdk_gl.c index 7e753ba58..c30ebc3ec 100755 --- a/desmume/src/gtk-glade/gdk_gl.c +++ b/desmume/src/gtk-glade/gdk_gl.c @@ -88,7 +88,7 @@ void my_gl_Clear(int screen) { if (!my_gl_Begin(screen)) return; /* Set the background black */ - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClearDepth(1.0); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); @@ -135,23 +135,27 @@ void init_GL(GtkWidget * widget, int screen, int share_num) { } int init_GL_free_s(GtkWidget * widget, int share_num) { - int r = free_gl_drawable; free_gl_drawable++; + int r = free_gl_drawable; my_glContext[r]=NULL; + my_glDrawable[r]=NULL; init_GL(widget, r, share_num); + free_gl_drawable++; return r; } int init_GL_free(GtkWidget * widget) { - int r = free_gl_drawable; free_gl_drawable++; + int r = free_gl_drawable; my_glContext[r]=NULL; + my_glDrawable[r]=NULL; init_GL(widget, r, r); + free_gl_drawable++; return r; } void init_GL_capabilities() { my_glConfig = gdk_gl_config_new_by_mode ( - GDK_GL_MODE_RGB + GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE ); @@ -198,9 +202,9 @@ void my_gl_Texture2D() { } void my_gl_ScreenTex() { -// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, // pause effect - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, +// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 512, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, // GL_UNSIGNED_SHORT_5_5_5_1, @@ -224,6 +228,9 @@ void my_gl_ScreenTexApply(int screen) { gboolean screen (GtkWidget * widget, int viewportscreen) { int H,W,screen; + GPU * gpu; + float bright_color = 0.0f; // blend with black + float bright_alpha = 0.0f; // don't blend // we take care to draw the right thing the right place // we need to rearrange widgets not to use this trick @@ -232,32 +239,62 @@ gboolean screen (GtkWidget * widget, int viewportscreen) { if (!my_gl_Begin(viewportscreen)) return TRUE; -// glLoadIdentity(); + glLoadIdentity(); + + // clear screen + glClearColor(0.0f,0.0f,0.0f,0.0f); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable(GL_TEXTURE_2D); -// glEnable(GL_BLEND); -// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); if (desmume_running()) { - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glColor4ub(255,255,255,255); + + // master bright + gpu = ((screen)?SubScreen:MainScreen).gpu; + switch (gpu->masterBright.bits.Mode) + { + case 1: // Bright up : blend with white + bright_color = 1.0f; + // no break; + case 2: // Bright down : blend with black + bright_alpha = 1.0f; // blending max + if (!gpu->masterBright.bits.FactorEx) + bright_alpha = gpu->masterBright.bits.Factor / 16.0; + break; + // Disabled 0, Reserved 3 + default: break; + } // rotate glRotatef(ScreenRotate, 0.0, 0.0, 1.0); - // draw screen + // create the texture for both display my_gl_Texture2D(); if (viewportscreen==0) { my_gl_ScreenTex(); } } else { - // background color black - glClearColor(0.0f, 0.0f, 0.0f, 0.5f); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - glColor4f(0.5f,0.5f,0.5f,0.5f); + // pause + // fake master bright up 50% + bright_color = 0.0f; + bright_alpha = 0.5f; } + // make sure current color is ok + glColor4ub(255,255,255,255); + // apply part of the texture my_gl_ScreenTexApply(screen); glDisable(GL_TEXTURE_2D); -// glDisable(GL_BLEND); + + // master bright (bis) + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(bright_color,bright_color,bright_color,bright_alpha); + glBegin(GL_QUADS); + glVertex2d(-1.0, 1.0); + glVertex2d( 1.0, 1.0); + glVertex2d( 1.0,-1.0); + glVertex2d(-1.0,-1.0); + glEnd(); + glDisable(GL_BLEND); + my_gl_End(viewportscreen); return TRUE; } diff --git a/desmume/src/gtk-glade/main.c b/desmume/src/gtk-glade/main.c index 5b83b6ce6..6e55ce2cc 100755 --- a/desmume/src/gtk-glade/main.c +++ b/desmume/src/gtk-glade/main.c @@ -221,7 +221,8 @@ int main(int argc, char *argv[]) { const char *commandLine_File = NULL; gtk_init(&argc, &argv); #ifdef HAVE_LIBGDKGLEXT_X11_1_0 -/* g_thread_init(NULL); */ +// check if you have GTHREAD when running configure script +// g_thread_init(NULL); gtk_gl_init(&argc, &argv); register_gl_fun(my_gl_Begin,my_gl_End); #endif @@ -258,7 +259,7 @@ int main(int argc, char *argv[]) { init_GL_capabilities(); - /* VĂ©rifie la ligne de commandes */ + /* check command line file */ if(commandLine_File) { if(desmume_open(commandLine_File) >= 0) { desmume_resume(); @@ -277,6 +278,8 @@ int main(int argc, char *argv[]) { gtk_widget_show(pDrawingArea); gtk_widget_show(pDrawingArea2); +// on_menu_tileview_activate(NULL,NULL); + /* start event loop */ gtk_main(); desmume_free();