#include <nds.h>
#include <stdlib.h>
#include <malloc.h>
//needed to load pcx files
#include <nds/arm9/image.h>
#include "drunkenlogo3_pcx.h"
int main() {
int textureID;
powerON(POWER_ALL);
//set mode 0, enable BG0 and set it to 3D
videoSetMode(MODE_0_3D);
//irqs are nice
irqInit();
irqEnable(IRQ_VBLANK);
//this should work the same as the normal gl call
glViewPort(0,0,255,191);
glClearColor(0,0,0);
glClearDepth(0x7FFF);
//vramSetBankA(VRAM_A_LCD); vramSetBankB(VRAM_B_LCD); vramSetBankC(VRAM_C_LCD); vramSetBankD(VRAM_D_LCD);
vramSetBankA(VRAM_A_TEXTURE_SLOT0); vramSetBankB(VRAM_B_TEXTURE_SLOT1); vramSetBankC(VRAM_C_TEXTURE_SLOT2); vramSetBankD(VRAM_D_TEXTURE_SLOT3);
sImage pcx; //////////////(NEW) and different from nehe.
//load our texture
loadPCX((u8*)drunkenlogo3_pcx, &pcx);
image8to16(&pcx);
glGenTextures(1, &textureID);
glBindTexture(0, textureID);
glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_512, TEXTURE_SIZE_512, 0, TEXGEN_TEXCOORD, (u8*)pcx.data8);
imageDestroy(&pcx);
while(1) {
glReset();
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
//not a real gl function and will likely change
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK);
glBindTexture(0, textureID);
//glBindTexture (GL_TEXTURE_2D, 13); /* bind to our texture, has id of 13 */
glBegin (GL_QUADS);
glEnable (GL_TEXTURE_2D); /* enable texture mapping */
glBegin (GL_QUADS);
glTexCoord2f (0.0, 0.0);
glVertex3f (0.0, 0.0, 0.0);
glTexCoord2f (1.0, 0.0);
glVertex3f (10.0, 0.0, 0.0);
glTexCoord2f (1.0, 1.0);
glVertex3f (10.0, 10.0, 0.0);
glTexCoord2f (0.0, 1.0);
glVertex3f (0.0, 10.0, 0.0);
glEnd ();
glEnd ();
glPopMatrix (0);
glMatrixMode (GL_MODELVIEW);
glPopMatrix (1);
glFlush();
swiWaitForVBlank();
}
return 0;
}//end main |