#include <nds.h>
u32 triangle[] =
{
12,
FIFO_COMMAND_PACK(FIFO_BEGIN, FIFO_COLOR, FIFO_VERTEX16, FIFO_COLOR),
GL_TRIANGLE,
RGB15(31,0,0),
VERTEX_PACK(inttov16(-1),inttov16(-1)), VERTEX_PACK(0,0),
RGB15(0,31,0),
FIFO_COMMAND_PACK(FIFO_VERTEX16, FIFO_COLOR, FIFO_VERTEX16, FIFO_END),
VERTEX_PACK(inttov16(1),inttov16(-1)), VERTEX_PACK(0,0),
RGB15(0,0,31),
VERTEX_PACK(inttov16(0),inttov16(1)), VERTEX_PACK(0,0),
};
int main()
{
float rotateX = 0.0;
float rotateY = 0.0;
videoSetMode(MODE_0_3D);
glInit();
glEnable(GL_ANTIALIAS);
glClearColor(0,0,0,31);
glClearPolyID(63);
glClearDepth(0x7FFF);
glViewport(0,0,255,191);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, 256.0 / 192.0, 0.1, 40);
gluLookAt( 0.0, 0.0, 1.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
while(1)
{
glPushMatrix();
glTranslate3f32(0, 0, floattof32(-1));
glRotateX(rotateX);
glRotateY(rotateY);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
scanKeys();
u16 keys = keysHeld();
if((keys & KEY_UP)) rotateX += 3;
if((keys & KEY_DOWN)) rotateX -= 3;
if((keys & KEY_LEFT)) rotateY += 3;
if((keys & KEY_RIGHT)) rotateY -= 3;
glCallList(triangle);
glPopMatrix(1);
glFlush(0);
}
return 0;
}