#104428 - Dan Forever - Fri Sep 29, 2006 1:07 am
Finally figured out today that the devkitpro supplied makefiles automatically convert .pcx files to textures! Got it all running up and fine in Dualis, but when I actually load [the .ds.gba or] the nds file on the ds hardware itself, all I get is a blank white quad (which is the colour it's set to).
It's based on the nehe 6 tutorial code:
Any suggestions as to why this might happen would be most appreciated :)
It's based on the nehe 6 tutorial code:
Any suggestions as to why this might happen would be most appreciated :)
Code: |
// include your ndslib
#include <nds.h> #include <stdio.h> #include "blue_large_pcx.h" //#include "drunkenlogo_pcx.h" void DrawDude(void); void ProcessInput(void); float x, y; int texture[1]; int LoadGLTextures() // Load PCX files And Convert To Textures { sImage pcx; //////////////(NEW) and different from nehe. //load our texture loadPCX((u8*)blue_large_pcx, &pcx); // loadPCX((u8*)drunkenlogo_pcx, &pcx); image8to16(&pcx); glGenTextures(1, &texture[0]); glBindTexture(0, texture[0]); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, pcx.data8); // glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64 , TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, pcx.data8); imageDestroy(&pcx); return TRUE; } int main() { // Turn on everything powerON(POWER_ALL); // Setup the Main screen for 3D videoSetMode(MODE_0_3D); vramSetBankA(VRAM_A_TEXTURE); //NEW must set up some memory for textures // IRQ basic setup irqInit(); irqSet(IRQ_VBLANK, 0); // Set our viewport to be the same size as the screen glViewPort(0,0,255,191); // Specify the Clear Color and Depth glClearColor(0,0,0); glClearDepth(0x7FFF); LoadGLTextures(); consoleDemoInit(); printf("Lets do something fun...\n"); //lcdMainOnTop(); lcdMainOnBottom(); x = 0.0f; y = 0.0f; while(true) { ProcessInput(); // Reset the screen and setup the view glReset(); gluPerspective(35, 256.0 / 192.0, 0.1, 100); glColor3f(0, 1, 0); // Set the color..not in nehe source...ds gl default will be black //ds specific, several attributes can be set here glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE); // Set the current matrix to be the model matrix glMatrixMode(GL_MODELVIEW); //Push our original Matrix onto the stack (save state) glPushMatrix(); glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(x,y,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glColor3f(1.0f,1.0f,1.0f); // Set The Color To Blue One Time Only DrawDude(); //*/ // Pop our Matrix from the stack (restore state) glPopMatrix(1); //a handy little built in function to wait for a screen refresh swiWaitForVBlank(); // flush to screen glFlush(); } return 0; } void DrawDude(void) { glBindTexture(GL_TEXTURE_2D, texture[0]); glBegin(GL_QUADS); // Draw A Quad glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad } void ProcessInput(void) { scanKeys(); uint32 keyFlags = keysDown(); switch(keyFlags) { case KEY_A: printf("A Pressed\n"); break; case KEY_B: printf("B Pressed\n"); break; case KEY_X: printf("X Pressed\n"); break; case KEY_Y: printf("Y Pressed\n"); break; case KEY_UP: printf("Up Pressed\n"); break; case KEY_DOWN: printf("Down Pressed\n"); break; case KEY_LEFT: printf("Left Pressed\n"); break; case KEY_RIGHT: printf("Right Pressed\n"); break; case KEY_START: printf("Start Pressed\n"); break; case KEY_SELECT: printf("Select Pressed\n"); break; case KEY_R: printf("R Shoulder Pressed\n"); break; case KEY_L: printf("L Shoulder Pressed\n"); break; case KEY_TOUCH: printf("Touchpad Pressed\n"); break; case KEY_LID: printf("Lid Down\n"); break; } keyFlags = keysHeld(); if(keyFlags & KEY_UP) y += 0.3f; if(keyFlags & KEY_DOWN) y -= 0.3f; if(keyFlags & KEY_LEFT) x -= 0.3f; if(keyFlags & KEY_RIGHT) x += 0.3f; } |