tileviewer : still not functionnal
"master brightness" done by hardware
This commit is contained in:
parent
3505b8c7ce
commit
8b44d9fade
|
@ -1624,6 +1624,8 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
|
|
||||||
// FIXME !!!
|
// FIXME !!!
|
||||||
/* capture */
|
/* capture */
|
||||||
|
#if 0
|
||||||
|
// to be done with opengl
|
||||||
capcnt = &gpu->dispCapCnt.bits;
|
capcnt = &gpu->dispCapCnt.bits;
|
||||||
if (capcnt->Capture_Enable)
|
if (capcnt->Capture_Enable)
|
||||||
{
|
{
|
||||||
|
@ -1713,16 +1715,25 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* end of capture */
|
/* 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)
|
// Apply final brightness adjust (MASTER_BRIGHT)
|
||||||
// Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS)
|
// Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS)
|
||||||
/* Mightymax> it should be more effective if the windowmanager applies brightness when drawing */
|
/* 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 */
|
/* 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)
|
switch (gpu->masterBright.bits.Mode)
|
||||||
{
|
{
|
||||||
// Disabled
|
// Disabled
|
||||||
|
@ -1829,4 +1840,5 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
||||||
case 3:
|
case 3:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,19 +106,40 @@ static void refresh() {
|
||||||
|
|
||||||
// this little thing doesnt display properly
|
// this little thing doesnt display properly
|
||||||
// nothing drawn...
|
// nothing drawn...
|
||||||
|
// seems that is the context is not shared there is a pb switching context
|
||||||
|
/*
|
||||||
if (!my_gl_Begin(gl_context_num)) return;
|
if (!my_gl_Begin(gl_context_num)) return;
|
||||||
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
my_gl_DrawBeautifulQuad();
|
my_gl_DrawBeautifulQuad();
|
||||||
my_gl_End(gl_context_num);
|
my_gl_End(gl_context_num);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
*/
|
||||||
if (!my_gl_Begin(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);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glGenTextures(1, &Textures);
|
glGenTextures(1, &Textures);
|
||||||
|
|
||||||
//proxy
|
//proxy
|
||||||
glBindTexture(GL_TEXTURE_2D, Textures);
|
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,
|
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
|
||||||
256, 256, 0,
|
256, 256, 0,
|
||||||
GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
||||||
|
@ -169,10 +190,10 @@ static void refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0);
|
glTexCoord2f(0.0, 0.0); glVertex2d(-0.5, 0.5);
|
||||||
glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0);
|
glTexCoord2f(0.0, 1.0); glVertex2d(-0.5,-0.5);
|
||||||
glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0);
|
glTexCoord2f(1.0, 1.0); glVertex2d( 0.5,-0.5);
|
||||||
glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0);
|
glTexCoord2f(1.0, 0.0); glVertex2d( 0.5, 0.5);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glDeleteTextures(1, &Textures);
|
glDeleteTextures(1, &Textures);
|
||||||
|
@ -190,7 +211,7 @@ static void initialize() {
|
||||||
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory");
|
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory");
|
||||||
init_combo_memory(combo, mem_addr);
|
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);
|
gtk_widget_show(wPaint);
|
||||||
init=TRUE;
|
init=TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ void my_gl_Clear(int screen) {
|
||||||
if (!my_gl_Begin(screen)) return;
|
if (!my_gl_Begin(screen)) return;
|
||||||
|
|
||||||
/* Set the background black */
|
/* 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);
|
glClearDepth(1.0);
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
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 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_glContext[r]=NULL;
|
||||||
|
my_glDrawable[r]=NULL;
|
||||||
init_GL(widget, r, share_num);
|
init_GL(widget, r, share_num);
|
||||||
|
free_gl_drawable++;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int init_GL_free(GtkWidget * widget) {
|
int init_GL_free(GtkWidget * widget) {
|
||||||
int r = free_gl_drawable; free_gl_drawable++;
|
int r = free_gl_drawable;
|
||||||
my_glContext[r]=NULL;
|
my_glContext[r]=NULL;
|
||||||
|
my_glDrawable[r]=NULL;
|
||||||
init_GL(widget, r, r);
|
init_GL(widget, r, r);
|
||||||
|
free_gl_drawable++;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_GL_capabilities() {
|
void init_GL_capabilities() {
|
||||||
|
|
||||||
my_glConfig = gdk_gl_config_new_by_mode (
|
my_glConfig = gdk_gl_config_new_by_mode (
|
||||||
GDK_GL_MODE_RGB
|
GDK_GL_MODE_RGBA
|
||||||
| GDK_GL_MODE_DEPTH
|
| GDK_GL_MODE_DEPTH
|
||||||
| GDK_GL_MODE_DOUBLE
|
| GDK_GL_MODE_DOUBLE
|
||||||
);
|
);
|
||||||
|
@ -198,9 +202,9 @@ void my_gl_Texture2D() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void my_gl_ScreenTex() {
|
void my_gl_ScreenTex() {
|
||||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||||
// pause effect
|
// pause effect
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
||||||
256, 512, 0, GL_RGBA,
|
256, 512, 0, GL_RGBA,
|
||||||
GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
||||||
// GL_UNSIGNED_SHORT_5_5_5_1,
|
// GL_UNSIGNED_SHORT_5_5_5_1,
|
||||||
|
@ -224,6 +228,9 @@ void my_gl_ScreenTexApply(int screen) {
|
||||||
|
|
||||||
gboolean screen (GtkWidget * widget, int viewportscreen) {
|
gboolean screen (GtkWidget * widget, int viewportscreen) {
|
||||||
int H,W,screen;
|
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 take care to draw the right thing the right place
|
||||||
// we need to rearrange widgets not to use this trick
|
// 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;
|
if (!my_gl_Begin(viewportscreen)) return TRUE;
|
||||||
|
|
||||||
// glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
// clear screen
|
||||||
// glEnable(GL_BLEND);
|
|
||||||
// glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
if (desmume_running()) {
|
|
||||||
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
glClearColor(0.0f,0.0f,0.0f,0.0f);
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
glColor4ub(255,255,255,255);
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
if (desmume_running()) {
|
||||||
|
|
||||||
|
// 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
|
// rotate
|
||||||
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
|
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
|
||||||
// draw screen
|
// create the texture for both display
|
||||||
my_gl_Texture2D();
|
my_gl_Texture2D();
|
||||||
if (viewportscreen==0) {
|
if (viewportscreen==0) {
|
||||||
my_gl_ScreenTex();
|
my_gl_ScreenTex();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// background color black
|
// pause
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
// fake master bright up 50%
|
||||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
bright_color = 0.0f;
|
||||||
glColor4f(0.5f,0.5f,0.5f,0.5f);
|
bright_alpha = 0.5f;
|
||||||
}
|
}
|
||||||
|
// make sure current color is ok
|
||||||
|
glColor4ub(255,255,255,255);
|
||||||
|
// apply part of the texture
|
||||||
my_gl_ScreenTexApply(screen);
|
my_gl_ScreenTexApply(screen);
|
||||||
glDisable(GL_TEXTURE_2D);
|
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);
|
my_gl_End(viewportscreen);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,8 @@ int main(int argc, char *argv[]) {
|
||||||
const char *commandLine_File = NULL;
|
const char *commandLine_File = NULL;
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
|
#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);
|
gtk_gl_init(&argc, &argv);
|
||||||
register_gl_fun(my_gl_Begin,my_gl_End);
|
register_gl_fun(my_gl_Begin,my_gl_End);
|
||||||
#endif
|
#endif
|
||||||
|
@ -258,7 +259,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
init_GL_capabilities();
|
init_GL_capabilities();
|
||||||
|
|
||||||
/* Vérifie la ligne de commandes */
|
/* check command line file */
|
||||||
if(commandLine_File) {
|
if(commandLine_File) {
|
||||||
if(desmume_open(commandLine_File) >= 0) {
|
if(desmume_open(commandLine_File) >= 0) {
|
||||||
desmume_resume();
|
desmume_resume();
|
||||||
|
@ -277,6 +278,8 @@ int main(int argc, char *argv[]) {
|
||||||
gtk_widget_show(pDrawingArea);
|
gtk_widget_show(pDrawingArea);
|
||||||
gtk_widget_show(pDrawingArea2);
|
gtk_widget_show(pDrawingArea2);
|
||||||
|
|
||||||
|
// on_menu_tileview_activate(NULL,NULL);
|
||||||
|
|
||||||
/* start event loop */
|
/* start event loop */
|
||||||
gtk_main();
|
gtk_main();
|
||||||
desmume_free();
|
desmume_free();
|
||||||
|
|
Loading…
Reference in New Issue