|
From: <at...@us...> - 2007-10-30 18:43:53
|
Revision: 523
http://cadcdev.svn.sourceforge.net/cadcdev/?rev=523&view=rev
Author: atani
Date: 2007-10-30 11:43:38 -0700 (Tue, 30 Oct 2007)
Log Message:
-----------
more NDS work, still not 100% functional for textures :(
Modified Paths:
--------------
tiki/examples/menu/basic/Makefile
tiki/nds/src/init_shutdown.cpp
tiki/src/gl/font.cpp
tiki/src/gl/genmenu.cpp
tiki/src/gl/gl.cpp
tiki/src/gl/texture.cpp
Property Changed:
----------------
tiki/examples/events/
tiki/examples/events/src/
tiki/examples/menu/basic/
tiki/examples/menu/basic/src/
tiki/examples/menu/popup/
tiki/examples/menu/popup/src/
Property changes on: tiki/examples/events
___________________________________________________________________
Name: svn:ignore
- Debug
*.user
+ Debug
Release
*.user
*.nds
*.ds.gba
Property changes on: tiki/examples/events/src
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: tiki/examples/menu/basic
___________________________________________________________________
Name: svn:ignore
+ Debug
Release
*.user
*.nds
*.ds.gba
Modified: tiki/examples/menu/basic/Makefile
===================================================================
--- tiki/examples/menu/basic/Makefile 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/examples/menu/basic/Makefile 2007-10-30 18:43:38 UTC (rev 523)
@@ -9,8 +9,8 @@
NDS_CART_VERSION ?= 1
endif
-all: menu_popup
-menu_popup: $(OBJS)
+all: menu_basic
+menu_basic: $(OBJS)
$(build_romdisk)
$(CXX) $(LDFLAGS) -L$(TIKI_DIR)$(TIKI_PLAT) -L$(TIKI_DIR)$(TIKI_PLAT)/lib $(OBJS) $(TIKI_BASE_LIBS) -o menu_basic$(PLATFORM_BINARY_EXT) $(ROMDISK_OBJ)
$(post_build)
Property changes on: tiki/examples/menu/basic/src
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: tiki/examples/menu/popup
___________________________________________________________________
Name: svn:ignore
+ Debug
Release
*.user
*.nds
*.ds.gba
Property changes on: tiki/examples/menu/popup/src
___________________________________________________________________
Name: svn:ignore
+ *.d
Modified: tiki/nds/src/init_shutdown.cpp
===================================================================
--- tiki/nds/src/init_shutdown.cpp 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/nds/src/init_shutdown.cpp 2007-10-30 18:43:38 UTC (rev 523)
@@ -29,41 +29,43 @@
bool init( int argc, char **argv ) {
// Turn on everything
- powerON( POWER_ALL );
-
+ powerON( POWER_ALL );
+
lcdMainOnTop();
- consoleDemoInit();
-
- // Setup the Main screen for 3D
- videoSetMode( MODE_0_3D );
+ consoleDemoInit();
- //vramSetBankA( VRAM_A_TEXTURE );
-
+ // Setup the Main screen for 3D
+ videoSetMode( MODE_0_3D );
+ vramSetBankA( VRAM_A_TEXTURE );
+
Tiki::Debug::printf("Enabling IRQs\n");
// IRQ basic setup
irqInit();
- irqSet(IRQ_VBLANK, 0);
-
+ irqSet(IRQ_VBLANK, 0);
+
Tiki::Debug::printf("Enabling GL\n");
// initialize the geometry engine
- glInit();
+ glInit();
glEnable(GL_TEXTURE_2D);
- // Set our viewport to be the same size as the screen
- glViewport(0,0,255,191);
-
// enable antialiasing
glEnable(GL_ANTIALIAS);
glClearColor(0,0,0,31); // BG must be opaque for AA to work
glClearPolyID(63); // BG must have a unique polygon ID for AA to work
- glClearDepth( 0x7FFFF );
+ glClearDepth( 0x7FFF );
+ // Set our viewport to be the same size as the screen
+ glViewport(0,0,255,191);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, 256.0 / 192.0, 0.1, 100);
- glMatrixMode(GL_MODELVIEW);
+
+
+ glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0),0);
+ glLight(1, RGB15(31,31,31) , 0,0,floattov10(-1.0));
+ glLight(2, RGB15(31,31,31) , 0,0,floattov10(1.0));
//need to set up some material properties since DS does not have them set by default
glMaterialf(GL_AMBIENT, RGB15(16,16,16));
@@ -74,11 +76,13 @@
//ds uses a table for shinyness..this generates a half-ass one
glMaterialShinyness();
- glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE );
+ glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2 );
+
+ glMatrixMode(GL_MODELVIEW);
// set a default color.
glColor3f(1, 1, 1);
-
+
Tiki::Debug::printf("Enabling libFAT\n");
// initialize libfat
fatInitDefault();
@@ -86,17 +90,17 @@
// initialize parallax
Tiki::Debug::printf("Enabling Sound\n");
Audio::Stream::initGlobal();
- Hid::init();
-
+ Hid::init();
+
irqSet( IRQ_TIMER3, Timer_50ms ); // setup timer IRQ
- irqEnable( IRQ_TIMER3 );
- Tiki::Debug::printf("Enabling Wifi\n");
+ irqEnable( IRQ_TIMER3 );
+ Tiki::Debug::printf("Enabling Wifi\n");
{ // send fifo message to initialize the arm7 wifi
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_SEND_CLEAR; // enable & clear FIFO
u32 Wifi_pass = Wifi_Init( WIFIINIT_OPTION_USELED );
REG_IPC_FIFO_TX = 0x12345678;
- REG_IPC_FIFO_TX = Wifi_pass;
+ REG_IPC_FIFO_TX = Wifi_pass;
irqEnable( IRQ_FIFO_NOT_EMPTY );
REG_IPC_FIFO_CR = IPC_FIFO_ENABLE | IPC_FIFO_RECV_IRQ; // enable FIFO IRQ
Modified: tiki/src/gl/font.cpp
===================================================================
--- tiki/src/gl/font.cpp 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/src/gl/font.cpp 2007-10-30 18:43:38 UTC (rev 523)
@@ -183,7 +183,7 @@
/* Make sure we can allocate texture space for it */
m_fnt.txr = new Texture;
- if ( !m_fnt.txr->createCanvas( hdr.txr_width, hdr.txr_height, Texture::ARGB4444 ) ) {
+ if ( !m_fnt.txr->createCanvas( hdr.txr_width, hdr.txr_height, Texture::ARGB1555 ) ) {
Debug::printf( "Font: can't allocate texture for '%s'\n", fn.c_str() );
return false;
}
Modified: tiki/src/gl/genmenu.cpp
===================================================================
--- tiki/src/gl/genmenu.cpp 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/src/gl/genmenu.cpp 2007-10-30 18:43:38 UTC (rev 523)
@@ -138,9 +138,9 @@
glClearColor( m_bg[ 0 ] * m_exitCount, m_bg[ 1 ] * m_exitCount, m_bg[ 2 ] * m_exitCount, 1.0f );
#else
- glClearColor( ( uint8 ) ( ( m_bg[ 0 ] * m_exitCount ) * 255 ),
- ( uint8 ) ( ( m_bg[ 1 ] * m_exitCount ) * 255 ),
- ( uint8 ) ( ( m_bg[ 2 ] * m_exitCount ) * 255 ), 255 );
+ glClearColor( ( uint8 ) ( ( m_bg[ 0 ] * m_exitCount ) * 32 ),
+ ( uint8 ) ( ( m_bg[ 1 ] * m_exitCount ) * 32 ),
+ ( uint8 ) ( ( m_bg[ 2 ] * m_exitCount ) * 32 ), 31 );
#endif
} else {
@@ -148,9 +148,9 @@
glClearColor( m_bg[ 0 ], m_bg[ 1 ], m_bg[ 2 ], 1.0f );
#else
- glClearColor( ( uint8 ) ( m_bg[ 0 ] * 255 ),
- ( uint8 ) ( m_bg[ 1 ] * 255 ),
- ( uint8 ) ( m_bg[ 2 ] * 255 ), 255 );
+ glClearColor( ( uint8 ) ( m_bg[ 0 ] * 32 ),
+ ( uint8 ) ( m_bg[ 1 ] * 32 ),
+ ( uint8 ) ( m_bg[ 2 ] * 32 ), 31 );
#endif
}
Modified: tiki/src/gl/gl.cpp
===================================================================
--- tiki/src/gl/gl.cpp 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/src/gl/gl.cpp 2007-10-30 18:43:38 UTC (rev 523)
@@ -39,8 +39,10 @@
glDisable( GL_CULL_FACE );
set2d();
+
+ Tiki::Math::Vector screen = getScreenExtents();
- glViewport( 0, 0, 640, 480 );
+ glViewport( 0, 0, screen.x, screen.y );
glClearDepth( 0.0f );
#if TIKI_PLAT != TIKI_DC
glClear( GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT + GL_STENCIL_BUFFER_BIT );
@@ -61,22 +63,16 @@
void Frame::set2d() {
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
-#if TIKI_PLAT != TIKI_NDS
- glOrtho( 0, 640, 480, 0, 1.0f, -1.0f );
-#else
- glOrtho( 0, 256, 192, 0, 0.1f, 100.0f );
-#endif
+ Tiki::Math::Vector screen = getScreenExtents();
+ glOrtho( 0, screen.x, screen.y, 0, 1.0f, -1.0f );
glMatrixMode( GL_MODELVIEW );
}
void Frame::set3d() {
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
-#if TIKI_PLAT != TIKI_NDS
- gluPerspective( 45.0f, 640.0f / 480.0f, 0.1f, 100.0f );
-#else
- gluPerspective( 70.0f, 256.0f / 192.0f, 0.1f, 100.0f );
-#endif
+ Tiki::Math::Vector screen = getScreenExtents();
+ gluPerspective( 45.0f, screen.x / screen.y, 0.1f, 100.0f );
glMatrixMode( GL_MODELVIEW );
}
@@ -90,22 +86,24 @@
// This will leave the depth testing enabled (to not overdraw
// opaque objects) but not update the depth buffer.
glDepthMask( GL_FALSE );
+#endif
+
#if TIKI_PLAT == TIKI_DC
glKosFinishList();
#endif
glEnable( GL_BLEND );
+#if TIKI_PLAT != TIKI_NDS
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
#else // TIKI_NDS
- glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
+ glPolyFmt(POLY_ALPHA(0) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2);
#endif
}
void Frame::transDisable() {
// glEnable(GL_DEPTH_TEST);
-#if TIKI_PLAT != TIKI_NDS
glDisable( GL_BLEND );
-#else
- glPolyFmt(POLY_ALPHA(0) | POLY_CULL_NONE);
+#if TIKI_PLAT == TIKI_NDS
+ glPolyFmt(POLY_ALPHA(31) | POLY_CULL_FRONT | POLY_FORMAT_LIGHT0| POLY_FORMAT_LIGHT1| POLY_FORMAT_LIGHT2);
#endif
}
Modified: tiki/src/gl/texture.cpp
===================================================================
--- tiki/src/gl/texture.cpp 2007-10-30 05:05:47 UTC (rev 522)
+++ tiki/src/gl/texture.cpp 2007-10-30 18:43:38 UTC (rev 523)
@@ -65,6 +65,7 @@
}
void Texture::convertToGl() {
+#if TIKI_PLAT != TIKI_NDS
uint16 * src16 = ( uint16 * ) m_ptr;
uint8 * dst = m_txrdata;
@@ -117,6 +118,7 @@
*dst++ = a;
}
}
+#endif
}
#if TIKI_PLAT == TIKI_WIN32
@@ -141,7 +143,30 @@
#endif
#endif
+#if TIKI_PLAT == TIKI_NDS
+static void getTextureSize(int x, int y, uint8 *tx, uint8 *ty) {
+ if(x < 9) { *tx = TEXTURE_SIZE_8; }
+ else if(x < 17) { *tx = TEXTURE_SIZE_16; }
+ else if(x < 33) { *tx = TEXTURE_SIZE_32; }
+ else if(x < 65) { *tx = TEXTURE_SIZE_64; }
+ else if(x < 129) { *tx = TEXTURE_SIZE_128; }
+ else if(x < 257) { *tx = TEXTURE_SIZE_256; }
+ else if(x < 513) { *tx = TEXTURE_SIZE_512; }
+ else if(x < 1025) { *tx = TEXTURE_SIZE_1024; }
+
+ if(y < 9) { *ty = TEXTURE_SIZE_8; }
+ else if(y < 17) { *ty = TEXTURE_SIZE_16; }
+ else if(y < 33) { *ty = TEXTURE_SIZE_32; }
+ else if(y < 65) { *ty = TEXTURE_SIZE_64; }
+ else if(y < 129) { *ty = TEXTURE_SIZE_128; }
+ else if(y < 257) { *ty = TEXTURE_SIZE_256; }
+ else if(y < 513) { *ty = TEXTURE_SIZE_512; }
+ else if(y < 1025) { *ty = TEXTURE_SIZE_1024; }
+}
+#endif
+
+
bool Texture::loadFromFile( const string & fn, int use_alpha ) {
RefPtr<Image> img;
size_t fnlen;
@@ -242,14 +267,17 @@
}
glTexEnvi( GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATEALPHA );
#elif TIKI_PLAT == TIKI_NDS
- glGenTextures( 1, &m_gltxr );
- glBindTexture( 0, m_gltxr );
- if(use_alpha) {
- glTexImage2D( 0, 0, GL_RGBA, (m_w/8) - 1, (m_h/8) - 1, 0, TEXGEN_TEXCOORD, m_ptr );
- }
- else {
- glTexImage2D( 0, 0, GL_RGB, (m_w/8) - 1, (m_h/8) - 1, 0, TEXGEN_TEXCOORD, m_ptr );
- }
+ uint8 w, h;
+ getTextureSize(img->w, img->h, &w, &h);
+ m_w = w;
+ m_h = h;
+ Debug::printf("TextureSize: (%d, %d) -> (%d, %d)\n", img->w, img->h, m_w, m_h);
+ if(use_alpha) {
+ glTexImage2D( 0, 0, GL_RGBA, m_w, m_h, 0, TEXGEN_TEXCOORD, m_ptr );
+ }
+ else {
+ glTexImage2D( 0, 0, GL_RGB, m_w, m_h, 0, TEXGEN_TEXCOORD, m_ptr );
+ }
#endif
return true;
@@ -293,12 +321,22 @@
return false;
}
+#if TIKI_PLAT != TIKI_NDS
// We'll write the converted data into this buffer
if ( m_fmt == RGBA8888 )
m_txrdata = m_ptr;
else
m_txrdata = new uint8[ m_w * m_h * 4 ];
-
+#else
+ // on the DS we only handle 16 bit textures, so use existing allocated space
+ m_txrdata = m_ptr;
+
+ uint8 tw, th;
+ getTextureSize(w, h, &tw, &th);
+ m_w = tw;
+ m_h = th;
+ Debug::printf("TextureSize: (%d, %d) -> (%d, %d)\n", w, h, m_w, m_h);
+#endif
return true;
}
@@ -364,21 +402,31 @@
glBindTexture( GL_TEXTURE_2D, m_gltxr );
#if TIKI_PLAT != TIKI_DC && TIKI_PLAT != TIKI_NDS
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, m_w, m_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_txrdata );
-#elif TIKI_PLAT != TIKI_NDS
+#elif TIKI_PLAT == TIKI_NDS
switch ( m_fmt ) {
case ARGB1555:
- glTexImage2D( GL_TEXTURE_2D, 0, GL_ARGB1555, m_w, m_h, 0, GL_ARGB1555, GL_UNSIGNED_BYTE, m_ptr );
- break;
+ glTexImage2D( 0, 0, GL_RGBA, m_w, m_h, 0, TEXGEN_TEXCOORD, m_ptr );
+ break;
+ case RGB565:
+ default:
+ glTexImage2D( 0, 0, GL_RGB, m_w, m_h, 0, TEXGEN_TEXCOORD, m_ptr );
+ break;
+ }
+#elif TIKI_PLAT == TIKI_DC
+ switch ( m_fmt ) {
+ case ARGB1555:
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_ARGB1555, m_w, m_h, 0, GL_ARGB1555, GL_UNSIGNED_BYTE, m_ptr );
+ break;
case ARGB4444:
- glTexImage2D( GL_TEXTURE_2D, 0, GL_ARGB4444, m_w, m_h, 0, GL_ARGB4444, GL_UNSIGNED_BYTE, m_ptr );
- break;
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_ARGB4444, m_w, m_h, 0, GL_ARGB4444, GL_UNSIGNED_BYTE, m_ptr );
+ break;
case RGB565:
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB565, m_w, m_h, 0, GL_RGB565, GL_UNSIGNED_BYTE, m_ptr );
- break;
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB565, m_w, m_h, 0, GL_RGB565, GL_UNSIGNED_BYTE, m_ptr );
+ break;
default:
- Debug::printf( "Texture::canvasUnlock: Unsupported texture format\n" );
- assert( false );
- break;
+ Debug::printf( "Texture::canvasUnlock: Unsupported texture format\n" );
+ assert( false );
+ break;
}
#endif
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|