blending effect for pause
This commit is contained in:
parent
0d76a6288a
commit
4080704c88
|
@ -76,8 +76,12 @@ static int colnum=0;
|
|||
static void refresh();
|
||||
static GtkWidget * wPaint;
|
||||
static GtkSpinButton * wSpin;
|
||||
static u16 mem[0x100];
|
||||
static int gl_context_num=0;
|
||||
|
||||
#define TILE_NUM_MAX 1024
|
||||
#define TILE_W_SZ 8
|
||||
#define TILE_H_SZ 8
|
||||
static u16 tiles[TILE_NUM_MAX][TILE_H_SZ*TILE_W_SZ];
|
||||
|
||||
static COLOR c;
|
||||
static COLOR32 c32;
|
||||
|
@ -89,14 +93,101 @@ static void wtools_4_update() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
static void refresh() {
|
||||
u16 palette_16[64];
|
||||
u16 palette_256[64];
|
||||
u8 * index16 = mem_addr[memnum];
|
||||
u8 * index256 = mem_addr[memnum];
|
||||
u8 * indexBMP = mem_addr[memnum];
|
||||
u16 * pal;
|
||||
int tile_n, index;
|
||||
guint Textures;
|
||||
|
||||
|
||||
return;
|
||||
|
||||
// this little thing doesnt display properly
|
||||
// quad gets drawn in the wrong place ?
|
||||
if (!my_gl_Begin(gl_context_num)) return;
|
||||
my_gl_Identity();
|
||||
|
||||
glClearColor(0.5,0.5,0.5,1.0);
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
my_gl_DrawBeautifulQuad();
|
||||
my_gl_End(gl_context_num);
|
||||
|
||||
return;
|
||||
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glGenTextures(1, &Textures);
|
||||
|
||||
//proxy
|
||||
glBindTexture(GL_TEXTURE_2D, Textures);
|
||||
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
|
||||
256, 256, 0,
|
||||
GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
||||
|
||||
|
||||
switch(colnum) {
|
||||
case 0: //BMP
|
||||
for (tile_n=0; tile_n<TILE_NUM_MAX; tile_n++) {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
(tile_n & 0x1F)<<3, (tile_n >> 5)<<3,
|
||||
8, 8, GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP);
|
||||
indexBMP +=64;
|
||||
}
|
||||
break;
|
||||
case 1: //256c
|
||||
if (pal = pal_addr[palindex]) {
|
||||
pal += palnum*256;
|
||||
for (tile_n=0; tile_n<1024; tile_n++) {
|
||||
for (index=0; index<64; index++) {
|
||||
palette_256[index]=pal[*index256];
|
||||
index256++;
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
(tile_n & 0x1F)<<3, (tile_n >> 5)<<3,
|
||||
8, 8, GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_256);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: //16c
|
||||
if (pal = pal_addr[palindex]) {
|
||||
pal += palnum*16;
|
||||
for (tile_n=0; tile_n<1024; tile_n++) {
|
||||
for (index=0; index<64; index++) {
|
||||
if (index & 1) continue;
|
||||
palette_16[index] =pal[*index16 & 15];
|
||||
palette_16[index+1]=pal[*index16 >> 4];
|
||||
index16++;
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
(tile_n & 0x1F)<<3, (tile_n >> 5)<<3,
|
||||
8, 8, GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
glEnd();
|
||||
|
||||
glDeleteTextures(1, &Textures);
|
||||
my_gl_End(gl_context_num);
|
||||
}
|
||||
|
||||
static void initialize() {
|
||||
GtkComboBox * combo;
|
||||
if (init) return;
|
||||
init=TRUE;
|
||||
|
||||
wPaint= glade_xml_get_widget(xml_tools, "wDraw_Tile");
|
||||
wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_4_palnum");
|
||||
|
@ -104,7 +195,9 @@ static void initialize() {
|
|||
init_combo_palette(combo, pal_addr);
|
||||
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory");
|
||||
init_combo_memory(combo, mem_addr);
|
||||
init=TRUE;
|
||||
|
||||
gl_context_num = init_GL_free(wPaint);
|
||||
gtk_widget_show(wPaint);
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,6 +229,10 @@ void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data
|
|||
colnum = dyn_CAST(int,user_data);
|
||||
refresh();
|
||||
}
|
||||
gboolean on_wDraw_Tile_expose_event (GtkWidget * w, GdkEventExpose * e, gpointer user_data) {
|
||||
refresh();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ G_MODULE_EXPORT void on_wtools_4_memory_changed (GtkComboBox *, gpoi
|
|||
G_MODULE_EXPORT void on_wtools_4_palette_changed (GtkComboBox *, gpointer );
|
||||
G_MODULE_EXPORT void on_wtools_4_palnum_value_changed (GtkSpinButton *, gpointer );
|
||||
G_MODULE_EXPORT void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data);
|
||||
|
||||
G_MODULE_EXPORT gboolean on_wDraw_Tile_expose_event (GtkWidget *, GdkEventExpose *, gpointer );
|
||||
|
||||
|
|
|
@ -145,7 +145,8 @@ gboolean EmuLoop(gpointer data)
|
|||
gtk_widget_queue_draw(pDrawingArea2);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw(pDrawingArea);
|
||||
gtk_widget_queue_draw(pDrawingArea2);
|
||||
regMainLoop = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -39,16 +39,15 @@ GtkWidget *pDrawingTexArea;
|
|||
#undef _DUP4
|
||||
#undef _DUP2
|
||||
|
||||
INLINE void my_gl_Identity() {
|
||||
void my_gl_Identity() {
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
INLINE void my_gl_DrawBeautifulQuad() {
|
||||
void my_gl_DrawBeautifulQuad() {
|
||||
// beautiful quad
|
||||
glColor4ub(255,255,255,128);
|
||||
glBegin(GL_QUADS);
|
||||
glColor3ub(255,0,0); glVertex2d(-0.75,-0.75);
|
||||
glColor3ub(128,255,0); glVertex2d(-0.75, 0.75);
|
||||
|
@ -58,6 +57,13 @@ INLINE void my_gl_DrawBeautifulQuad() {
|
|||
glColor3ub(255,255,255);
|
||||
}
|
||||
|
||||
|
||||
void my_gl_DrawLogo() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOL my_gl_Begin (int screen) {
|
||||
return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext[screen]);
|
||||
}
|
||||
|
@ -75,6 +81,7 @@ void my_gl_Clear(int screen) {
|
|||
|
||||
/* Set the background black */
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClearDepth(1.0);
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
||||
my_gl_DrawBeautifulQuad();
|
||||
|
@ -86,7 +93,9 @@ void init_GL(GtkWidget * widget, int screen, int share_num) {
|
|||
// init GL capability
|
||||
if (!gtk_widget_set_gl_capability(
|
||||
widget, my_glConfig,
|
||||
&my_glContext[share_num], TRUE,
|
||||
my_glContext[share_num],
|
||||
//NULL,
|
||||
TRUE,
|
||||
GDK_GL_RGBA_TYPE)) {
|
||||
printf ("gtk_widget_set_gl_capability\n");
|
||||
exit(1);
|
||||
|
@ -94,7 +103,7 @@ void init_GL(GtkWidget * widget, int screen, int share_num) {
|
|||
// realize so that we get a GdkWindow
|
||||
gtk_widget_realize(widget);
|
||||
// make sure we realize
|
||||
while (gtk_events_pending()) gtk_main_iteration();
|
||||
// while (gtk_events_pending()) gtk_main_iteration();
|
||||
my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget);
|
||||
|
||||
if (screen == share_num) {
|
||||
|
@ -160,7 +169,9 @@ INLINE void my_gl_Texture2D() {
|
|||
}
|
||||
|
||||
INLINE void my_gl_ScreenTex() {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 4,
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
// pause effect
|
||||
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,
|
||||
|
@ -172,9 +183,9 @@ void my_gl_ScreenTexApply(int screen) {
|
|||
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);
|
||||
glTexCoord2f(1.0, off+0.375); glVertex2d( 1.0,-1.0);
|
||||
glTexCoord2f(0.0, off+0.375); glVertex2d(-1.0,-1.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
@ -188,12 +199,16 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
|
|||
|
||||
if (!my_gl_Begin(viewportscreen)) return TRUE;
|
||||
|
||||
glLoadIdentity();
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
// glLoadIdentity();
|
||||
|
||||
my_gl_DrawBeautifulQuad();
|
||||
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);
|
||||
// rotate
|
||||
glRotatef(ScreenRotate, 0.0, 0.0, 1.0);
|
||||
// draw screen
|
||||
|
@ -201,8 +216,15 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
|
|||
if (viewportscreen==0) {
|
||||
my_gl_ScreenTex();
|
||||
}
|
||||
my_gl_ScreenTexApply(screen);
|
||||
} 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);
|
||||
}
|
||||
my_gl_ScreenTexApply(screen);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
// glDisable(GL_BLEND);
|
||||
my_gl_End(viewportscreen);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
BOOL my_gl_Begin (int screen);
|
||||
void my_gl_End (int screen);
|
||||
void my_gl_Clear(int screen);
|
||||
void my_gl_DrawBeautifulQuad();
|
||||
|
||||
void init_GL_capabilities();
|
||||
void init_GL(GtkWidget * widget, int screen, int share_num);
|
||||
|
|
|
@ -609,7 +609,7 @@ ARM7 cpu</property>
|
|||
<property name="width_request">256</property>
|
||||
<property name="height_request">256</property>
|
||||
<property name="events">GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK</property>
|
||||
<signal name="expose_event" handler="on_wDraw_Tex_expose_event" last_modification_time="Mon, 12 Feb 2007 17:45:04 GMT"/>
|
||||
<signal name="expose_event" handler="on_wDraw_Tile_expose_event" last_modification_time="Mon, 12 Feb 2007 17:45:04 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
|
|
|
@ -112,6 +112,7 @@ typedef void (*VoidFunPtr)();
|
|||
void notify_Tools();
|
||||
void register_Tool(VoidFunPtr fun);
|
||||
void unregister_Tool(VoidFunPtr fun);
|
||||
gchar * get_ui_file (const char *filename);
|
||||
|
||||
/* callbacks.c */
|
||||
void enable_rom_features();
|
||||
|
|
Loading…
Reference in New Issue