void initMenu(void) { lcdMainOnTop(); videoSetMode(MODE_5_3D); videoSetModeSub(MODE_5_2D); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_SUB_BG,VRAM_D_TEXTURE); initD3D(); glInit(); glEnable(GL_TEXTURE_2D); glEnable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); initVramBanks(2); initTextures(); initMenuScene(); initMenuButtons(); //TEMP glLight(0, RGB15(31,31,31), cosLerp(4096), 0, sinLerp(4096)); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(24,24,24)); glMaterialf(GL_SPECULAR, RGB15(0,0,0)); glMaterialf(GL_EMISSION, RGB15(0,0,0)); glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? applyCameraState(&menuCamera,&cameraStates[4]); tempState=cameraStates[4]; testTransition=startCameraTransition(&cameraStates[1],&cameraStates[4],64); setupMenuPage(startMenuPage, startMenuPageLength); logoMain=createTexture("logo.pcx", "menu"); logoRotate=createTexture("rotate_logo.pcx", "menu"); logoAlpha=31; glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(0,0,0)); //TEMP? NOGBA("END mem free : %dko (%do)",getMemFree()/1024,getMemFree()); fadeIn(); }
void App_Test::display_Model() { // gluLookAtf32( this->camera.getPosition()->get_vec_ox(),this->camera.getPosition()->get_vec_oy(),this->camera.getPosition()->get_vec_oz(), // this->camera.getLookAt()->get_vec_ox(),this->camera.getLookAt()->get_vec_oy(),this->camera.getLookAt()->get_vec_oz(), // 0,4096,0 // ); // glLoadIdentity(); glEnable(GL_TEXTURE_2D); glEnable(GL_ANTIALIAS); glEnable(GL_OUTLINE); glLight(0, RGB15(31,31,31) , 0, floattov10(-6.0), floattov10(-1.0)); glSetOutlineColor(0,RGB15(0,0,0)); glPolyFmt(POLY_ID(0) | POLY_ALPHA(31)|POLY_CULL_NONE | POLY_FORMAT_LIGHT0 | POLY_TOON_HIGHLIGHT); // glPolyFmt(POLY_ALPHA(31)|POLY_CULL_NONE | POLY_FORMAT_LIGHT0); glColor3b(31,31,31); glBindTexture(GL_TEXTURE_2D, this->textureID[0]); glTranslatef(0,-6,0); glRotatef(90,-1,0,0); glRotatef(-90,0,0,1); glCallList( (u32 *) this->model_selected); glEnd(); }
void initRoomEdition(void) { initLights(); initBlocks(); initEntities(); initInterface(); initEditorRoom(&editorRoom); initContextButtons(); initSelection(NULL); initCamera(&editorCamera); // initProjectionMatrixOrtho(&editorCamera, inttof32(-128), inttof32(127),inttof32(-96), inttof32(95), inttof32(-1000), inttof32(1000)); initProjectionMatrix(&editorCamera, 70*90, inttof32(4)/3, inttof32(1)/10, inttof32(1000)); //TEMP? editorCamera.position=vect(0,0,0); editorTranslation=vect(0,0,inttof32(-1)); editorScale=inttof32(1); lineOfTouchOrigin=vect(0,0,0); lineOfTouchVector=vect(0,0,0); currentScreen=false; //initial camera setup rotateMatrixY(editorCamera.transformationMatrix, 2048+384, true); rotateMatrixX(editorCamera.transformationMatrix, 1024+128, false); editorScale=inttof32(8*20); //controls stuff touchRead(¤tTouch); oldTouch=currentTouch; //cosmetics glSetOutlineColor(0,RGB15(0,0,0)); glSetOutlineColor(1,RGB15(29,15,3)); glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(24,24,24)); glMaterialf(GL_SPECULAR, RGB15(0,0,0)); glMaterialf(GL_EMISSION, RGB15(0,0,0)); glSetToonTableRange(0, 2, RGB15(8,8,8)); glSetToonTableRange(3, 31, RGB15(24,24,24)); glLight(0, RGB15(31,31,31), cosLerp(4096)>>3, 0, sinLerp(4096)>>3); }
int main() { // initialize gl glInit(); u32 rotateX = 0; u32 rotateY = 0; //set mode 0, enable BG0 and set it to 3D videoSetMode(MODE_0_3D); // used to hold touched position touchPosition touchXY; lcdMainOnBottom(); // we are going to be touching the 3D display // enable edge outlining, this will be used to show which object is selected glEnable(GL_OUTLINE); //set the first outline color to white glSetOutlineColor(0,RGB15(31,31,31)); int viewport[]={0,0,255,191}; // used later for gluPickMatrix() // setup the rear plane glClearColor(0,0,0,0); // set BG to black and clear glClearPolyID(0); // the BG and polygons will have the same ID unless a polygon is highlighted glClearDepth(0x7FFF); // setup the camera gluLookAt( 0.0, 0.0, 1.0, //camera possition 0.0, 0.0, 0.0, //look at 0.0, 1.0, 0.0); //up glLight(0, RGB15(31,31,31) , 0, floattov10(-1.0), 0); // setup the light while(1) { // handle key input 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; // get touchscreen position touchRead(&touchXY); glViewport(0,0,255,191); // set the viewport to fullscreen // setup the projection matrix for regular drawing glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 256.0 / 192.0, 0.1, 20); glMatrixMode(GL_MODELVIEW); // use the modelview matrix while drawing glPushMatrix(); // save the state of the current matrix(the modelview matrix) { glTranslatef32(0,0,floattof32(-6)); glRotateXi(rotateX); // add X rotation to the modelview matrix glRotateYi(rotateY); // add Y rotation to the modelview matrix glPushMatrix(); // save the state of the modelview matrix while making the first pass { // draw the scene for displaying glTranslatef32(floattof32(2.9),floattof32(0),floattof32(0)); // translate the modelview matrix to the drawing location if(clicked==CONE) { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(1)); // set a poly ID for outlining } else { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(0)); // set a poly ID for no outlining (same as BG) } glCallList((u32*)cone_bin); // draw a green cone from a predefined packed command list glTranslatef32(floattof32(-3),floattof32(1.8),floattof32(2)); // translate the modelview matrix to the drawing location if(clicked==CYLINDER) { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(1)); // set a poly ID for outlining } else { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(0)); // set a poly ID for no outlining (same as BG) } glCallList((u32*)cylinder_bin); // draw a blue cylinder from a predefined packed command list glTranslatef32(floattof32(.5),floattof32(-2.6),floattof32(-4)); // translate the modelview matrix to the drawing location if(clicked==SPHERE) { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(1)); // set a poly ID for outlining } else { glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_ID(0)); // set a poly ID for no outlining (same as BG) } glCallList((u32*)sphere_bin); // draw a red sphere from a predefined packed command list } glPopMatrix(1); // restores the modelview matrix to where it was just rotated // draw the scene again for picking { clicked = NOTHING; //reset what was clicked on closeW = 0x7FFFFFFF; //reset the distance //set the viewport to just off-screen, this hides all rendering that will be done during picking glViewport(0,192,0,192); // setup the projection matrix for picking glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix((touchXY.px),(191-touchXY.py),4,4,viewport); // render only what is below the cursor gluPerspective(60, 256.0 / 192.0, 0.1, 20); // this must be the same as the original perspective matrix glMatrixMode(GL_MODELVIEW); // switch back to modifying the modelview matrix for drawing glTranslatef32(floattof32(2.9),floattof32(0),floattof32(0)); // translate the modelview matrix to the drawing location startCheck(); glCallList((u32*)cone_bin); // draw a cone from a predefined packed command list endCheck(CONE); glTranslatef32(floattof32(-3),floattof32(1.8),floattof32(2)); // translate the modelview matrix to the drawing location startCheck(); glCallList((u32*)cylinder_bin); // draw a cylinder from a predefined packed command list endCheck(CYLINDER); glTranslatef32(floattof32(.5),floattof32(-2.6),floattof32(-4)); // translate the modelview matrix to the drawing location startCheck(); glCallList((u32*)sphere_bin); // draw a sphere from a predefined packed command list endCheck(SPHERE); } } glPopMatrix(1); // restores the modelview matrix to its original state glFlush(0); // wait for everything to be drawn before starting on the next frame } return 0; }//end main
void initGame(void) { lcdMainOnTop(); int oldv=getMemFree(); NOGBA("mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("initializing..."); videoSetMode(MODE_5_3D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); glInit(); vramSetPrimaryBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_LCD,VRAM_D_MAIN_BG_0x06000000); vramSetBankH(VRAM_H_SUB_BG); vramSetBankI(VRAM_I_SUB_BG_0x06208000); glEnable(GL_TEXTURE_2D); // glEnable(GL_ANTIALIAS); glDisable(GL_ANTIALIAS); glEnable(GL_BLEND); glEnable(GL_OUTLINE); glSetOutlineColor(0,RGB15(0,0,0)); //TEMP? glSetOutlineColor(1,RGB15(0,0,0)); //TEMP? glSetOutlineColor(7,RGB15(31,0,0)); //TEMP? glSetToonTableRange(0, 15, RGB15(8,8,8)); //TEMP? glSetToonTableRange(16, 31, RGB15(24,24,24)); //TEMP? glClearColor(31,31,0,31); glClearPolyID(63); glClearDepth(0x7FFF); glViewport(0,0,255,191); // initVramBanks(1); initVramBanks(2); initTextures(); initSound(); initCamera(NULL); initPlayer(NULL); initLights(); initParticles(); initMaterials(); loadMaterialSlices("slices.ini"); loadMaterials("materials.ini"); loadControlConfiguration("config.ini"); initElevators(); initWallDoors(); initTurrets(); initBigButtons(); initTimedButtons(); initEnergyBalls(); initPlatforms(); initCubes(); initEmancipation(); initDoors(); initSludge(); initPause(); initText(); NOGBA("lalala"); getPlayer()->currentRoom=&gameRoom; currentBuffer=false; getVramStatus(); fadeIn(); mainBG=bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); bgSetPriority(mainBG, 0); REG_BG0CNT=BG_PRIORITY(3); #ifdef DEBUG_GAME consoleInit(&bottomScreen, 3, BgType_Text4bpp, BgSize_T_256x256, 16, 0, false, true); consoleSelect(&bottomScreen); #endif // glSetToonTableRange(0, 14, RGB15(16,16,16)); // glSetToonTableRange(15, 31, RGB15(26,26,26)); initPortals(); //PHYSICS initPI9(); strcpy(&mapFilePath[strlen(mapFilePath)-3], "map"); newReadMap(mapFilePath, NULL, 255); transferRectangles(&gameRoom); makeGrid(); generateRoomGrid(&gameRoom); gameRoom.displayList=generateRoomDisplayList(&gameRoom, vect(0,0,0), vect(0,0,0), false); getVramStatus(); startPI(); NOGBA("START mem free : %dko (%do)",getMemFree()/1024,getMemFree()); NOGBA("vs mem free : %dko (%do)",oldv/1024,oldv); levelInfoCounter=60; }