void loseRender(Board *b, int step){ glResetMatrixStack(); if ( step > 1000 ) return; glMatrixMode(GL_PROJECTION); gluPerspective(20, 256.0 / 192.0, 0.1, 40); float d = (float)step / 6.0; gluLookAt( 5.0 + d, 5.0 + d, 7.0 + d, //camera possition 1.0, 0.0, 1.5, //look at 0.0, 1.0, 0.0); //up glRotateY(step*3); glLight(0, RGB15(31,31,31), 0, floattov10(1.0)-1, 0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(31,31,31)); glMaterialf(GL_SPECULAR, RGB15(31,31,31)); glMaterialf(GL_EMISSION, RGB15(8,8,8)); glMaterialShinyness(); glPolyFmt( POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 ); glBindTexture(0, textureID); b->draw(); glFlush(0); swiWaitForVBlank(); }
//--------------------------------------------------------------------------------- void glInit_C(void) { //--------------------------------------------------------------------------------- glGlob = glGetGlobals(); glGlob->clearColor = 0; // init texture globals glGlob->activeTexture = 0; glGlob->nextBlock = (uint32*)0x06800000; glGlob->nextPBlock = 0; glGlob->nameCount = 1; while (GFX_STATUS & (1<<27)); // wait till gfx engine is not busy // Clear the FIFO GFX_STATUS |= (1<<29); // Clear overflows from list memory glResetMatrixStack(); // prime the vertex/polygon buffers glFlush(0); // reset the control bits GFX_CONTROL = 0; // reset the rear-plane(a.k.a. clear color) to black, ID=0, and opaque glClearColor(0,0,0,31); glClearPolyID(0); // reset stored texture locations glResetTextures(); // reset the depth to it's max glClearDepth(GL_MAX_DEPTH); GFX_TEX_FORMAT = 0; GFX_POLY_FORMAT = 0; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_TEXTURE); glLoadIdentity(); }
void logo() { glResetMatrixStack(); glMatrixMode(GL_PROJECTION); gluPerspective(20, 256.0 / 192.0, 0.1, 40); gluLookAt( 0.0, .55, 0.0 , //camera possition 0.0, 0.0, 0.0, //look at 0.0, 0.0, -1.0); //up glLight(0, RGB15(31,31,31), 0, floattov10(1.0)-1, 0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(31,31,31)); glMaterialf(GL_SPECULAR, RGB15(31,31,31)); glMaterialf(GL_EMISSION, RGB15(8,8,8)); glMaterialShinyness(); glPolyFmt( POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 ); glGenTextures(1, &logotex); glBindTexture(0, logotex); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD , (u8*)billkuker_bmp_bin); glBindTexture(0, logotex); glBegin(GL_QUAD); glNormal(NORMAL_PACK(0,inttov10(1),0)); glTexCoord1i(TEXTURE_PACK(0,0)); glVertex3v16(floattov16(-0.5), floattov16(-0.5), floattov16(0.5) ); glTexCoord1i(TEXTURE_PACK(inttot16(256), inttot16(0))); glVertex3v16(floattov16(0.5), floattov16(-0.5), floattov16(0.5) ); glTexCoord1i(TEXTURE_PACK(inttot16(256),inttot16(256))); glVertex3v16(floattov16(0.5), floattov16(-0.5), floattov16(-0.5) ); glTexCoord1i(TEXTURE_PACK(0, inttot16(256))); glVertex3v16(floattov16(-0.5), floattov16(-0.5), floattov16(-0.5) ); glEnd(); glFlush(0); playGenericSound(down_raw, down_raw_size); playGenericSound(up_raw, up_raw_size); swiWaitForVBlank(); iprintf("Press any button"); while( !keysHeld() ) scanKeys(); glResetTextures(); iprintf("\x1b[2J"); }
void gameLoop(){ iprintf("\x1b[2J"); int frame = 0; Board b(7); Player* p; p = new Player(b.space(5,4)); //iprintf("Entering Main Loop.\n"); int rot = 0; while( !b.full() ) { iprintf("\x1b[22;18HFrame: %d\n\x1b[0;0H", ++frame); glResetMatrixStack(); //any floating point gl call is being converted to fixed prior to being implemented glMatrixMode(GL_PROJECTION); gluPerspective(20, 256.0 / 192.0, 0.1, 40); gluLookAt( 5.0, 5.0, 7.0, //camera possition 1.0, 0.0, 1.5, //look at 0.0, 1.0, 0.0); //up glLight(0, RGB15(31,31,31), 0, floattov10(1.0)-1, 0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(31,31,31)); glMaterialf(GL_SPECULAR, RGB15(31,31,31)); glMaterialf(GL_EMISSION, RGB15(8,8,8)); //ds uses a table for shinyness..this generates a half-ass one glMaterialShinyness(); //not a real gl function and will likely change glPolyFmt( POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 ); //glPolyFmt(POLY_ALPHA(15) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 ); glRotateY(rot); glBindTexture(0, textureID); b.draw(); glFlush(0); b.tick(); Player::tickPlayers(); scanKeys(); u16 keys = keysHeld(); p->setDir(NODIR); if((keys & KEY_UP)) p->setDir(NORTH); if((keys & KEY_DOWN)) p->setDir(SOUTH); if((keys & KEY_LEFT)) p->setDir(WEST); if((keys & KEY_RIGHT)) p->setDir(EAST); if (( keys & KEY_R )) rot++; if (( keys & KEY_L )) rot--; swiWaitForVBlank(); } lose(&b); }