misc. function changes (to be a little more generic to claim a GL

context)
added tile viewer backbone
This commit is contained in:
damdoum 2007-02-12 20:12:33 +00:00
parent 768f32ef69
commit 902f673ab4
12 changed files with 623 additions and 116 deletions

View File

@ -8,7 +8,8 @@ desmume_glade_SOURCES = \
callbacks.c callbacks.h callbacks_IO.c callbacks_IO.h desmume.c desmume.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/callbacks_3_palview.c dTools/callbacks_4_tileview.c \
dTools/callbacks_dtools.h \
dTools/dTools_display.h \
../sndsdl.h ../sndsdl.c ../ctrlssdl.h ../ctrlssdl.c

View File

@ -345,16 +345,22 @@ void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data)
GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_1_IOregs");
gtk_widget_show(dlg);
}
void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_2_MemView");
gtk_widget_show(dlg);
}
void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_3_PalView");
gtk_widget_show(dlg);
}
void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_4_TileView");
gtk_widget_show(dlg);
}
void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data) {
GtkWidget * w = user_data;
gtk_widget_show(w);
}

View File

@ -48,9 +48,11 @@ G_MODULE_EXPORT void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpoi
G_MODULE_EXPORT void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data);
/* MENU TOOLS */
G_MODULE_EXPORT void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data);
G_MODULE_EXPORT void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data);
/* MENU ? */
G_MODULE_EXPORT void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data);

View File

@ -21,6 +21,42 @@
#include "callbacks_dtools.h"
void init_combo_palette(GtkComboBox *combo, u16 ** addresses) {
GtkTreeIter iter;
GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_set_model(combo, model);
int i=0;
#define DO(str,addr,r) \
gtk_list_store_append (model, &iter); \
gtk_list_store_set (model, &iter, 0, str,-1); \
addresses[i]=((u16*)(addr) r); i++;
DO("Main screen BG PAL", ARM9Mem.ARM9_VMEM,)
DO("Main screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x100)
DO("Sub screen BG PAL", ARM9Mem.ARM9_VMEM,+0x200)
DO("Sub screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x300)
DO("Main screen ExtPAL 0", ARM9Mem.ExtPal[0][0],)
DO("Main screen ExtPAL 1", ARM9Mem.ExtPal[0][1],)
DO("Main screen ExtPAL 2", ARM9Mem.ExtPal[0][2],)
DO("Main screen ExtPAL 3", ARM9Mem.ExtPal[0][3],)
DO("Sub screen ExtPAL 0", ARM9Mem.ExtPal[1][0],)
DO("Sub screen ExtPAL 1", ARM9Mem.ExtPal[1][1],)
DO("Sub screen ExtPAL 2", ARM9Mem.ExtPal[1][2],)
DO("Sub screen ExtPAL 3", ARM9Mem.ExtPal[1][3],)
DO("Main screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[0][0],)
DO("Main screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[0][1],)
DO("Sub screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[1][0],)
DO("Sub screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[1][1],)
DO("Texture PAL 0", ARM9Mem.texPalSlot[0],)
DO("Texture PAL 1", ARM9Mem.texPalSlot[1],)
DO("Texture PAL 2", ARM9Mem.texPalSlot[2],)
DO("Texture PAL 3", ARM9Mem.texPalSlot[3],)
#undef DO
gtk_combo_box_set_active(combo,0);
}
static u16* base_addr[20];
static BOOL init=FALSE;
static int palnum=0;
@ -91,47 +127,17 @@ static void refresh() {
g_object_unref(gdkGC);
}
static void initialize() {
GtkComboBox * combo;
GtkTreeIter iter, *parent=NULL;
GtkListStore* model;
int i=0;
if (init) return;
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette");
model = (GtkListStore*)gtk_combo_box_get_model(combo);
wPaint= glade_xml_get_widget(xml_tools, "wtools_3_draw");
wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_3_palnum");
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette");
#define DO(str,addr,r) \
gtk_list_store_append (model, &iter); \
gtk_list_store_set (model, &iter, 0, str,-1); \
base_addr[i]=((u16*)(addr) r); i++;
init_combo_palette(combo, base_addr);
DO("Main screen BG PAL", ARM9Mem.ARM9_VMEM,)
DO("Main screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x100)
DO("Sub screen BG PAL", ARM9Mem.ARM9_VMEM,+0x200)
DO("Sub screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x300)
DO("Main screen ExtPAL 0", ARM9Mem.ExtPal[0][0],)
DO("Main screen ExtPAL 1", ARM9Mem.ExtPal[0][1],)
DO("Main screen ExtPAL 2", ARM9Mem.ExtPal[0][2],)
DO("Main screen ExtPAL 3", ARM9Mem.ExtPal[0][3],)
DO("Sub screen ExtPAL 0", ARM9Mem.ExtPal[1][0],)
DO("Sub screen ExtPAL 1", ARM9Mem.ExtPal[1][1],)
DO("Sub screen ExtPAL 2", ARM9Mem.ExtPal[1][2],)
DO("Sub screen ExtPAL 3", ARM9Mem.ExtPal[1][3],)
DO("Main screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[0][0],)
DO("Main screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[0][1],)
DO("Sub screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[1][0],)
DO("Sub screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[1][1],)
DO("Texture PAL 0", ARM9Mem.texPalSlot[0],)
DO("Texture PAL 1", ARM9Mem.texPalSlot[1],)
DO("Texture PAL 2", ARM9Mem.texPalSlot[2],)
DO("Texture PAL 3", ARM9Mem.texPalSlot[3],)
#undef DO
init=TRUE;
gtk_combo_box_set_active(combo,0);
}

View File

@ -0,0 +1,290 @@
/* callbacks_3_palview.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 "callbacks_dtools.h"
void init_combo_memory(GtkComboBox *combo, u8 ** addresses) {
GtkTreeIter iter;
GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING);
gtk_combo_box_set_model(combo, model);
int i=0;
#define DO(str,addr,r) \
gtk_list_store_append (model, &iter); \
gtk_list_store_set (model, &iter, 0, str,-1); \
addresses[i]=(addr r); i++;
DO("A-BG - 0x6000000",ARM9Mem.ARM9_ABG,)
DO("A-BG - 0x6010000",ARM9Mem.ARM9_ABG,+0x10000)
DO("A-BG - 0x6020000",ARM9Mem.ARM9_ABG,+0x20000)
DO("A-BG - 0x6030000",ARM9Mem.ARM9_ABG,+0x30000)
DO("A-BG - 0x6040000",ARM9Mem.ARM9_ABG,+0x40000)
DO("A-BG - 0x6050000",ARM9Mem.ARM9_ABG,+0x50000)
DO("A-BG - 0x6060000",ARM9Mem.ARM9_ABG,+0x60000)
DO("A-BG - 0x6070000",ARM9Mem.ARM9_ABG,+0x70000)
DO("B-BG - 0x6200000",ARM9Mem.ARM9_BBG,)
DO("B-BG - 0x6210000",ARM9Mem.ARM9_BBG,+0x10000)
DO("A-OBJ- 0x6400000",ARM9Mem.ARM9_AOBJ,)
DO("A-OBJ- 0x6410000",ARM9Mem.ARM9_AOBJ,+0x10000)
DO("A-OBJ- 0x6420000",ARM9Mem.ARM9_AOBJ,+0x20000)
DO("A-OBJ- 0x6430000",ARM9Mem.ARM9_AOBJ,+0x30000)
DO("B-OBJ- 0x6600000",ARM9Mem.ARM9_BOBJ,)
DO("B-OBJ- 0x6610000",ARM9Mem.ARM9_BOBJ,+0x10000)
DO("LCD - 0x6800000",ARM9Mem.ARM9_LCD,)
DO("LCD - 0x6810000",ARM9Mem.ARM9_LCD,+0x10000)
DO("LCD - 0x6820000",ARM9Mem.ARM9_LCD,+0x20000)
DO("LCD - 0x6830000",ARM9Mem.ARM9_LCD,+0x30000)
DO("LCD - 0x6840000",ARM9Mem.ARM9_LCD,+0x40000)
DO("LCD - 0x6850000",ARM9Mem.ARM9_LCD,+0x50000)
DO("LCD - 0x6860000",ARM9Mem.ARM9_LCD,+0x60000)
DO("LCD - 0x6870000",ARM9Mem.ARM9_LCD,+0x70000)
DO("LCD - 0x6880000",ARM9Mem.ARM9_LCD,+0x80000)
DO("LCD - 0x6890000",ARM9Mem.ARM9_LCD,+0x90000)
#undef DO
gtk_combo_box_set_active(combo,0);
}
static u16* pal_addr[20];
static u8* mem_addr[26];
static BOOL init=FALSE;
static int palnum=0;
static int palindex=0;
static int memnum=0;
static int colnum=0;
static void refresh();
static GtkWidget * wPaint;
static GtkSpinButton * wSpin;
static u16 mem[0x100];
static COLOR c;
static COLOR32 c32;
static GdkGC * gdkGC;
static void wtools_4_update() {
}
static void refresh() {
}
static void initialize() {
GtkComboBox * combo;
if (init) return;
wPaint= glade_xml_get_widget(xml_tools, "wDraw_Tile");
wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_4_palnum");
combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_palette");
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;
}
void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) {
initialize();
register_Tool(wtools_4_update);
}
gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) {
unregister_Tool(wtools_4_update);
gtk_widget_hide(widget);
return TRUE;
}
void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) {
palindex = gtk_combo_box_get_active(combo);
gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4));
gtk_spin_button_set_value(wSpin,0);
refresh();
}
void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) {
palnum = gtk_spin_button_get_value_as_int(spin);
refresh();
}
void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) {
memnum = gtk_combo_box_get_active(combo);
refresh();
}
void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
colnum = dyn_CAST(int,user_data);
refresh();
}
#if 0
void other_screen (GtkWidget * widget, int screen) {
if (!my_gl_Begin(screen)) return;
my_gl_Identity();
glClear( GL_COLOR_BUFFER_BIT );
GPU * gpu = &SubScreen;
_OAM_ * spriteInfo = (_OAM_*)(gpu->oam + 127);// + 127;
u16 i; int mode;
u8 prioTab[256];
#define MODE_IDX_16 1
#define MODE_IDX_256 2
#define MODE_BMP 3
for(i = 0; i<127; ++i, --spriteInfo)
{
size sprSize;
s32 sprX, sprY, x, y, lg;
int xdir;
u8 prio, * src;
u16 * pal;
u16 i,j;
u16 rotScaleA,rotScaleB,rotScaleC,rotScaleD;
int block;
prio = spriteInfo->Priority;
// get sprite location and size
sprX = (spriteInfo->X<<23)>>23;
sprY = spriteInfo->Y;
sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape];
lg = sprSize.x;
if (spriteInfo->RotScale == 2) continue;
#if 0
// switch TOP<-->BOTTOM
if (spriteInfo->VFlip);
// switch LEFT<-->RIGHT
if (spriteInfo->HFlip);
{
u16 rotScaleIndex;
// index from 0 to 31
rotScaleIndex = spriteInfo->RotScalIndex + (spriteInfo->HFlip<<1) + (spriteInfo->VFlip << 2);
rotScaleA = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x06),0) ;
rotScaleB = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x0E),0) ;
rotScaleC = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x16),0) ;
rotScaleD = T1ReadWord((u8*)(gpu->oam + rotScaleIndex*0x20 + 0x1E),0) ;
}
if (spriteInfo->Mode == 2) {
src = gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10);
continue;
}
if (spriteInfo->Mode == 3) /* sprite is in BMP format */
{
src = (gpu->sprMem) + (spriteInfo->TileIndex<<4) + (y<<gpu->sprBMPBoundary);
if (gpu->dispCnt.bits.OBJ_BMP_2D_dim) // 256*256
src = (gpu->sprMem) + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8) << 1);
else // 128 * 512
src = (gpu->sprMem) + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8) << 1);
continue;
}
if(gpu->dispCnt.bits.OBJ_Tile_1D)
if (spriteInfo->Depth) {
//256 colors
glColorTable(GL_TEXTURE_COLOR_TABLE_EXT,
GL_RGBA, 256, GL_RGBA,
GL_UNSIGNED_SHORT_1_5_5_5_REV, pal);
} else {
pal += (spriteInfo->PaletteIndex<<4);
glColorTable(GL_TEXTURE_COLOR_TABLE_EXT,
GL_RGBA, 16, GL_RGBA,
GL_UNSIGNED_SHORT_1_5_5_5_REV, pal);
}
glTexImage2D(GL_TEXTURE_2D, 0, COLOR_INDEX4_EXT,
16, 16, 0,
GL_COLOR_INDEX, GL_UNSIGNED_BYTE, src);
src = gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10);
pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400);
#endif
}
struct _DISPCNT * dispcnt = &(gpu->dispCnt.bits);
int boundary = 32;
if (dispcnt->OBJ_Tile_1D)
boundary <<= dispcnt->OBJ_Tile_1D_Bound;
int bmpboundary = 128;
bmpboundary <<= (dispcnt->OBJ_BMP_mapping & dispcnt->OBJ_BMP_1D_Bound);
guint Textures[3];
glGenTextures(3, Textures);
glBindTexture(GL_TEXTURE_2D, Textures[0]);
//proxy
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
256, 256, 0,
GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
u16 * pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400);
u8 palette_16[1024][64];
u8 palette_256[1024][64];
// u16 tile_BMP[1024][64];
u8 * index16 = gpu->sprMem;
u8 * index256 = gpu->sprMem;
u16 * indexBMP = gpu->sprMem;
int tile_n, index;
if (gpu->sprMem != NULL)
for (tile_n=0; tile_n<1024; tile_n++) {
for (index=0; index<64; index++) {
// tile_BMP[tile_n][index]=*indexBMP;
// indexBMP++;
palette_256[tile_n][index]=pal[*index256];
index256++;
if (index & 1) continue;
palette_16[tile_n][index] =pal[*index16 & 15];
palette_16[tile_n][index+1]=pal[*index16 >> 4];
index16++;
}
glBindTexture(GL_TEXTURE_2D, Textures[0]);
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);
}
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();
my_gl_End(screen);
glDeleteTextures(3, &Textures);
}
#endif

View File

@ -45,10 +45,27 @@ G_MODULE_EXPORT gboolean on_wtools_2_draw_expose_event (GtkWidget *, GdkE
G_MODULE_EXPORT gboolean on_wtools_2_draw_scroll_event (GtkWidget *, GdkEventScroll *, gpointer );
/* ***** ***** PALETTE VIEWER ***** ***** */
// initialise combo box for all palettes
void init_combo_palette(GtkComboBox *combo, u16 ** addresses);
G_MODULE_EXPORT void on_wtools_3_PalView_show (GtkWidget *, gpointer );
G_MODULE_EXPORT gboolean on_wtools_3_PalView_close (GtkWidget *, ...);
G_MODULE_EXPORT gboolean on_wtools_3_PalView_delete_event (GtkWidget *, GdkEvent *, gpointer );
G_MODULE_EXPORT gboolean on_wtools_3_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer );
G_MODULE_EXPORT void on_wtools_3_palette_changed (GtkComboBox *, gpointer );
G_MODULE_EXPORT void on_wtools_3_palnum_value_changed (GtkSpinButton *, gpointer );
/* ***** ***** TILE VIEWER ***** ***** */
// initialise combo box for all palettes
void init_combo_memory(GtkComboBox *combo, u8 ** addresses);
G_MODULE_EXPORT void on_wtools_4_TileView_show (GtkWidget *, gpointer );
G_MODULE_EXPORT gboolean on_wtools_4_TileView_close (GtkWidget *, ...);
G_MODULE_EXPORT gboolean on_wtools_4_TileView_delete_event (GtkWidget *, GdkEvent *, gpointer );
G_MODULE_EXPORT void on_wtools_4_memory_changed (GtkComboBox *, gpointer );
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);

View File

@ -23,13 +23,22 @@
#ifdef HAVE_LIBGDKGLEXT_X11_1_0
#define _DUP8(a) a,a,a,a, a,a,a,a
#define _DUP4(a) a,a,a,a
#define _DUP2(a) a,a
GLuint Textures[2];
// free number we can use in tools 0-1 reserved for screens
int free_gl_drawable=2;
GdkGLConfig *my_glConfig=NULL;
GdkGLContext *my_glContext[3]={NULL,NULL,NULL};
GdkGLDrawable *my_glDrawable[3]={NULL,NULL,NULL};
GdkGLContext *my_glContext[8]={ _DUP8(NULL) };
GdkGLDrawable *my_glDrawable[8]={ _DUP8(NULL) };
GtkWidget *pDrawingTexArea;
#undef _DUP8
#undef _DUP4
#undef _DUP2
INLINE void my_gl_Identity() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
@ -61,6 +70,18 @@ void my_gl_End (int screen) {
gdk_gl_drawable_gl_end(my_glDrawable[screen]);
}
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);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
my_gl_DrawBeautifulQuad();
my_gl_End(screen);
}
void init_GL(GtkWidget * widget, int screen, int share_num) {
// init GL capability
if (!gtk_widget_set_gl_capability(
@ -74,8 +95,8 @@ void init_GL(GtkWidget * widget, int screen, int share_num) {
gtk_widget_realize(widget);
// make sure we realize
while (gtk_events_pending()) gtk_main_iteration();
my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget);
if (screen == share_num) {
my_glContext[screen] = gtk_widget_get_gl_context(widget);
} else {
@ -83,22 +104,21 @@ void init_GL(GtkWidget * widget, int screen, int 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);
}
int init_GL_free_s(GtkWidget * widget, int share_num) {
int r = free_gl_drawable; free_gl_drawable++;
init_GL(widget, r, share_num);
return r;
}
int init_GL_free(GtkWidget * widget) {
int r = free_gl_drawable; free_gl_drawable++;
init_GL(widget, r, r);
return r;
}
void init_GL_capabilities() {
my_glConfig = gdk_gl_config_new_by_mode (
GDK_GL_MODE_RGB
@ -107,10 +127,17 @@ void init_GL_capabilities() {
);
// initialize 1st drawing area
init_GL(pDrawingArea,0,0);
my_gl_Clear(0);
if (!my_gl_Begin(0)) return;
// generate ONE texture (display)
glEnable(GL_TEXTURE_2D);
glGenTextures(2, Textures);
my_gl_End(0);
// initialize 2nd drawing area (sharing context)
init_GL(pDrawingArea2,1,0);
init_GL(pDrawingAreaTex,2,2);
my_gl_Clear(1);
}
void reshape (GtkWidget * widget, int screen) {
@ -151,29 +178,9 @@ 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;

View File

@ -32,8 +32,12 @@
BOOL my_gl_Begin (int screen);
void my_gl_End (int screen);
void my_gl_Clear(int screen);
void init_GL_capabilities();
void init_GL(GtkWidget * widget, int screen, int share_num);
int init_GL_free_s(GtkWidget * widget, int share_num);
int init_GL_free(GtkWidget * widget);
void reshape (GtkWidget * widget, int screen);
gboolean screen (GtkWidget * widget, int off);

View File

@ -820,6 +820,28 @@
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="menu_tileview">
<property name="visible">True</property>
<property name="label" translatable="yes">View Tiles</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_menu_tileview_activate" last_modification_time="Sun, 14 Jan 2007 10:34:32 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image121">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
@ -1271,25 +1293,6 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkDrawingArea" id="wDraw_Tex">
<property name="visible">False</property>
<property name="width_request">256</property>
<property name="height_request">192</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK</property>
<signal name="configure_event" handler="on_wDrawScreen_configure_event" object="%d:2" last_modification_time="Mon, 05 Feb 2007 00:49:24 GMT"/>
<signal name="expose_event" handler="on_wDrawScreen_expose_event" object="%d:2" last_modification_time="Tue, 02 Jan 2007 10:27:18 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>

View File

@ -434,8 +434,8 @@ ARM7 cpu</property>
<child>
<widget class="GtkComboBox" id="wtools_3_palette">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="items" translatable="yes"></property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_wtools_3_palette_changed" last_modification_time="Sun, 14 Jan 2007 09:29:39 GMT"/>
</widget>
@ -525,14 +525,14 @@ ARM7 cpu</property>
</widget>
</child>
</widget>
<!--
<widget class="GtkDialog" id="wtool_4_TexView">
<property name="visible">True</property>
<property name="title" translatable="yes">Texture viewer</property>
<widget class="GtkDialog" id="wtools_4_TileView">
<property name="visible">False</property>
<property name="title" translatable="yes">Tile 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="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
@ -542,8 +542,9 @@ ARM7 cpu</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"/>
<signal name="delete_event" handler="on_wtools_4_TileView_close" last_modification_time="Mon, 12 Feb 2007 17:14:14 GMT"/>
<signal name="response" handler="on_wtools_4_TileView_close" last_modification_time="Mon, 12 Feb 2007 17:14:28 GMT"/>
<signal name="show" handler="on_wtools_4_TileView_show" last_modification_time="Mon, 12 Feb 2007 17:14:37 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">
@ -578,12 +579,185 @@ ARM7 cpu</property>
</child>
<child>
<widget class="GtkDrawingArea" id="wTexDrawArea">
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">4</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<child>
<widget class="GtkComboBox" id="wtools_4_palette">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_wtools_4_palette_changed" last_modification_time="Mon, 12 Feb 2007 16:57:25 GMT"/>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkDrawingArea" id="wDraw_Tile">
<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"/>
<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"/>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="wtools_4_palnum">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="climb_rate">1</property>
<property name="digits">0</property>
<property name="numeric">False</property>
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">0 0 15 1 2 1</property>
<signal name="value_changed" handler="on_wtools_4_palnum_value_changed" last_modification_time="Mon, 12 Feb 2007 16:57:35 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes"> Palette : </property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="wtools_4_r16">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">16c</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_wtools_4_rXX_toggled" object="%d:2" last_modification_time="Mon, 12 Feb 2007 16:59:20 GMT"/>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="wtools_4_r256">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">256c</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">wtools_4_r16</property>
<signal name="toggled" handler="on_wtools_4_rXX_toggled" object="%d:1" last_modification_time="Mon, 12 Feb 2007 16:59:20 GMT"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="wtools_4_rBMP">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">BMP</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">wtools_4_r16</property>
<signal name="toggled" handler="on_wtools_4_rXX_toggled" object="%d:0" last_modification_time="Mon, 12 Feb 2007 16:59:20 GMT"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="wtools_4_memory">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
<signal name="changed" handler="on_wtools_4_memory_changed" last_modification_time="Mon, 12 Feb 2007 17:06:20 GMT"/>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
@ -594,5 +768,5 @@ ARM7 cpu</property>
</widget>
</child>
</widget>
-->
</glade-interface>

View File

@ -105,7 +105,7 @@ u16 Keypad_Temp[NB_KEYS];
/* main.c */
GtkWidget * pWindow;
GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex;
GtkWidget * pDrawingArea, * pDrawingArea2;
GladeXML * xml, * xml_tools;
typedef void (*VoidFunPtr)();

View File

@ -26,7 +26,7 @@
#include "globals.h"
GtkWidget * pWindow;
GtkWidget * pDrawingArea, * pDrawingArea2, * pDrawingAreaTex;
GtkWidget * pDrawingArea, * pDrawingArea2;
GladeXML * xml, * xml_tools;
SoundInterface_struct *SNDCoreList[] = {
@ -251,8 +251,6 @@ 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);
@ -277,7 +275,6 @@ int main(int argc, char *argv[]) {
gtk_widget_show(pDrawingArea);
gtk_widget_show(pDrawingArea2);
//gtk_widget_show(pDrawingAreaTex);
/* start event loop */
gtk_main();