示例#1
0
文件: menu.c 项目: Almamu/portalDS
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();
}
示例#2
0
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(&currentTouch);
	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);
}
示例#3
0
int main() {

	int rotateX = 0;
	int rotateY = 0;

	//set mode 0, enable BG0 and set it to 3D
	videoSetMode(MODE_0_3D);

	// initialize gl
	glInit();
	
	// enable antialiasing
	glEnable(GL_ANTIALIAS);
	
	// setup the rear plane
	glClearColor(0,0,0,31); // BG must be opaque for AA to work
	glClearPolyID(63); // BG must have a unique polygon ID for AA to work
	glClearDepth(0x7FFF);

	//this should work the same as the normal gl call
	glViewport(0,0,255,191);

	//toon-table entry 0 is for completely unlit pixels, going up to entry 31 for completely lit
	//We block-fill it in two halves, we get cartoony 2-tone lighting
	glSetToonTableRange( 0, 15, RGB15(8,8,8) );
	glSetToonTableRange( 16, 31, RGB15(24,24,24) );
	
	//any floating point gl call is being converted to fixed prior to being implemented
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(70, 256.0 / 192.0, 0.1, 40);
	
	//NB: When toon-shading, the hw ignores lights 2 and 3
	//Also note that the hw uses the RED component of the lit vertex to index the toon-table
	glLight(0, RGB15(16,16,16) , 0,		floattov10(-1.0),		0);
	glLight(1, RGB15(16,16,16),   floattov10(-1.0),	0,		0);
	
	gluLookAt(	0.0, 0.0, -3.0,		//camera possition 
				0.0, 0.0, 0.0,		//look at
				0.0, 1.0, 0.0);		//up
	
	while(1) {

		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
			glRotateXi(rotateX);
			glRotateYi(rotateY);


			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));

			glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_TOON_HIGHLIGHT);


			scanKeys();
			u32 keys = keysHeld();

			if( keys & KEY_UP ) rotateX += 1;
			if( keys & KEY_DOWN ) rotateX -= 1;
			if( keys & KEY_LEFT ) rotateY += 1;
			if( keys & KEY_RIGHT ) rotateY -= 1;

			int pen_delta[2];
			get_pen_delta( &pen_delta[0], &pen_delta[1] );
			rotateY -= pen_delta[0];
			rotateX -= pen_delta[1];

			glCallList((u32*)statue_bin);
			glPopMatrix(1);

		glFlush(0);

		swiWaitForVBlank();
	}

	return 0;
}
示例#4
0
文件: game.c 项目: dibas/portalDS
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;
}
示例#5
0
int App_Test::start()
{
    int code_out = 0;

    this->model_animated[ 0] = (u8 *)heavy_walk_01_bin;
    this->model_animated[ 1] = (u8 *)heavy_walk_02_bin;
    this->model_animated[ 2] = (u8 *)heavy_walk_03_bin;
    this->model_animated[ 3] = (u8 *)heavy_walk_04_bin;
    this->model_animated[ 4] = (u8 *)heavy_walk_05_bin;
    this->model_animated[ 5] = (u8 *)heavy_walk_06_bin;
    this->model_animated[ 6] = (u8 *)heavy_walk_07_bin;
    this->model_animated[ 7] = (u8 *)heavy_walk_08_bin;
    this->model_animated[ 8] = (u8 *)heavy_walk_09_bin;
    this->model_animated[ 9] = (u8 *)heavy_walk_10_bin;
    this->model_animated[10] = (u8 *)heavy_walk_11_bin;
    this->model_animated[11] = (u8 *)heavy_walk_12_bin;
    this->model_animated[12] = (u8 *)heavy_walk_13_bin;
    this->model_animated[13] = (u8 *)heavy_walk_14_bin;
    this->model_animated[14] = (u8 *)heavy_walk_15_bin;
    this->model_animated[15] = (u8 *)heavy_walk_16_bin;
    this->model_animated[16] = (u8 *)heavy_walk_17_bin;
    this->model_animated[17] = (u8 *)heavy_walk_18_bin;
    this->model_animated[18] = (u8 *)heavy_walk_19_bin;
    this->model_animated[19] = (u8 *)heavy_walk_20_bin;
    this->model_animated[20] = (u8 *)heavy_walk_21_bin;
    this->model_animated[21] = (u8 *)heavy_walk_22_bin;
    this->model_animated[22] = (u8 *)heavy_walk_23_bin;
    this->model_animated[23] = (u8 *)heavy_walk_24_bin;
    this->model_animated[24] = (u8 *)heavy_walk_25_bin;
    this->model_animated[25] = (u8 *)heavy_walk_26_bin;
    this->model_animated[26] = (u8 *)heavy_walk_27_bin;
    this->model_animated[27] = (u8 *)heavy_walk_28_bin;
    this->model_animated[28] = (u8 *)heavy_walk_29_bin;
    this->model_animated[29] = (u8 *)heavy_walk_30_bin;
    this->model_animated[30] = (u8 *)heavy_walk_31_bin;
    this->model_animated[31] = (u8 *)heavy_walk_32_bin;
    this->model_animated[32] = (u8 *)heavy_walk_33_bin;
    this->model_animated[33] = (u8 *)heavy_walk_34_bin;
    this->model_animated[34] = (u8 *)heavy_walk_35_bin;
    this->model_animated[35] = (u8 *)heavy_walk_36_bin;
    this->model_animated[36] = (u8 *)heavy_walk_37_bin;
    this->model_animated[37] = (u8 *)heavy_walk_38_bin;
    this->model_animated[38] = (u8 *)heavy_walk_39_bin;
    this->model_animated[39] = (u8 *)heavy_walk_40_bin;



    //Animations variables
	this->frame = 0;
    this->max_frame = 40;

	//Debug variables for animations
	int32 test_time = 0; 
 
	this->xrot = 0.0f;
    this->yrot = 0.0f;
    this->zrot = 0.0f;

    this->p_mgr_display->setup_screen();

    this->target.set_vec_ox(0);
    this->target.set_vec_oy(0);
    this->target.set_vec_oz(0);

    this->camera.setLookAt(CAMERA_MODE_TARGET,&(this->target));
    this->camera.computeLookAt();
	this->camera.dist_from_target = floattof32(23);
    this->p_mgr_display->set_camera(&(this->camera));

    this->p_mgr_display->init();
    this->load_Texture();

    this->app_running = 1;
    this->p_mgr_system->reset_timer();

	this->animation_pause = 1;	

    glSetToonTableRange( 0, 8, RGB15(8,8,8) );
    glSetToonTableRange( 8, 10, RGB15(12,12,12) );
    glSetToonTableRange( 10, 13, RGB15(16,16,16) );
    glSetToonTableRange( 13, 31, RGB15(31,31,31) );

	//glEnable(GL_TOON_HIGHLIGHT);
    while(this->app_running)
    {
        this->process_inputs();
        //printf("%d\n",this->p_mgr_system->last_millisec);
        //this->camera.setStep(this->p_mgr_system->last_millisec); // TODO : init and use millisec pointer within Model_Camera
        this->camera.setStep(17); // TODO : init and use millisec pointer within Model_Camera

        //Animations step calculation
        //this->frame += mulf32(this->frame_speed,this->p_mgr_system->last_millisec);
		if (!this->animation_pause) this->frame+= test_time;
		else this->frame=0;
        if (this->frame >= this->max_frame) this->frame = this->frame - this->max_frame;
		
		this->model_selected = this->model_animated[this->frame];
        //Start Display

        this->p_mgr_display->begin_3D();

        this->display_Model();

        this->p_mgr_display->end_3D();

        this->p_mgr_display->flush_display();
        //End Display

        iprintf("\x1b[2J");
        iprintf("\x1b[1;0Hframe  = %d\n",this->frame);
	    iprintf("\x1b[2;0Htest_timer  = %d\n",timerElapsed(0));
	    iprintf("\x1b[3;0Htest_ms  = %d\n",test_time);

		swiIntrWait(IRQ_TIMER0,1);
	    iprintf("\x1b[5;0H Timer ok\n");
		test_time = this->p_mgr_system->last_millisec;
        this->p_mgr_system->reset_timer();

//        printf("dst_from_target = %f\n",f32tofloat(this->camera.dist_from_target));
		swiWaitForVBlank(); 

    }

    return code_out;

}