コード例 #1
0
ファイル: video.c プロジェクト: Tomwi/FeOSMusic
void init3D(void)
{
	videoSetMode(MODE_0_3D);
	glInit();
	glEnable( GL_TEXTURE_2D | GL_ANTIALIAS );
	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( GL_MAX_DEPTH );
	glViewport(0,0,255,191);		// set the viewport to screensize
	glColor( 0x7FFF ); 				// max color
	glPolyFmt( POLY_ALPHA(31) | POLY_CULL_NONE );  // geen dingen laten verdwijnen
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();				// reset view
	glOrthof32( 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1 << 12, 1 << 12 );
	gluLookAt(	0.0, 0.0, 1.0,		//camera possition
	            0.0, 0.0, 0.0,		//look at
	            0.0, 1.0, 0.0);		//up
}
コード例 #2
0
ファイル: menu.c プロジェクト: Almamu/portalDS
void drawLogo(void)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glOrthof32(inttof32(0), inttof32(255), inttof32(191), inttof32(0), -inttof32(1), inttof32(1));
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glPushMatrix();
		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
		applyMTL(logoMain);
		glScalef32(inttof32(256),inttof32(128),inttof32(1));
		glBegin(GL_QUADS);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
			glVertex3v16(inttof32(0), inttof32(0), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(256), inttot16(0));
			glVertex3v16(inttof32(1), inttof32(0), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(256), inttot16(128));
			glVertex3v16(inttof32(1), inttof32(1), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(128));
			glVertex3v16(inttof32(0), inttof32(1), inttof32(0));
	glPopMatrix(1);

	glPushMatrix();
		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
		applyMTL(logoRotate);
		glTranslate3f32(inttof32(90+32),inttof32(28+32),-inttof32(1)/16);
		glRotateZi(logoAngle+=32);
		glTranslate3f32(-inttof32(32),-inttof32(32),0);
		glScalef32(inttof32(64),inttof32(64),inttof32(1));
		glBegin(GL_QUADS);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
			glVertex3v16(inttof32(0), inttof32(0), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(0));
			glVertex3v16(inttof32(1), inttof32(0), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(64));
			glVertex3v16(inttof32(1), inttof32(1), inttof32(0));
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(64));
			glVertex3v16(inttof32(0), inttof32(1), inttof32(0));
	glPopMatrix(1);
}
コード例 #3
0
ファイル: starfield.c プロジェクト: protosphere/proto_nds
void Starfield_Draw(Starfield *starfield)
{
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrthof32(0, inttof32(4), 0, inttof32(3), 0, inttof32(40));

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	gluLookAtf32(0, 0, inttof32(1),
				 0, 0, 0,
				 0, inttof32(1), 0);

	glPolyFmt(POLY_ALPHA(0x1f) | POLY_CULL_NONE);

	for (int i = 0; i < num_stars; i++) {
		StarfieldStar *star = &starfield->stars[i];
		Starfield_DrawStar(star);
	}

	glPopMatrix(1);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: jkroll20/libflux
int main(void)
{
    touchPosition touch;

    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);	//sub bg 0 will be used to print text
    vramSetBankC(VRAM_C_SUB_BG);

    SUB_BG0_CR = BG_MAP_BASE(31);

    BG_PALETTE_SUB[255] = RGB15(31,31,31);	//by default font will be rendered with color 255

    //consoleInit() is a lot more fluxible but this gets you up and running quick
    consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
    
/////////////
    powerON(POWER_ALL);

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

    // irqs are nice
    irqInit();
    irqEnable(IRQ_VBLANK);
    
    // initialize gl
    glInit();
    
    // setup the rear plane
    glClearColor(2, 4, 3, 16);
    glClearDepth(GL_MAX_DEPTH);
    
    // this should work the same as the normal gl call
    glViewPort(0,0, 255,191);
    
    glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
    
    glMatrixMode(GL_PROJECTION);
    
    glLoadIdentity();
    //~ glOrtho(0, 1, 192.0/256.0, 0, -10, 10);
    glOrthof32(0, 1<<12, (192<<12)/256, 0, -10<<12, 10<<12);
    
    REG_POWERCNT^= POWER_SWAP_LCDS;
/////////////


    flux_init();
    create_frame_groups();
    create_button_groups();
    create_titleframe();
    
    dmaCopy(fluxcolors, syscol_table, sizeof(fluxcolors));
    
    dword rc1= create_rect(NOPARENT, 20,20, 128,96, 0x808080);
    dword rc= create_rect(NOPARENT, 10,10, 128,96, 0x404040|TRANSL_3);
    dword frm= clone_frame("titleframe", rc);
    clone_frame("titleframe", rc1);
    //~ clone_group("button", rc, 10,30, 30,14, ALIGN_LEFT|ALIGN_TOP);

    create_rect(rc, 10,10, 10,10, 0xFFFFFF|TRANSL_1);
    create_rect(rc, 20,10, 10,10, 0xFFFFFF|TRANSL_2);
    create_rect(rc, 30,10, 10,10, 0xFFFFFF|TRANSL_3);
    create_rect(rc, 10,15, 30,10, 0xFFFFFF|TRANSL_1);
    
    create_text(rc, 10,30, 40,40, "Text! Space!\nNewline!", 0xFFFFFF, FONT_DEFAULT);
    
    bool redraw_all= true;
    bool touch_wasdown= false;
    int lasttouch_x, lasttouch_y;
    while(1)
    {
	scanKeys();
    	u32 keysheld= keysHeld();
	u32 keysdown= keysDown();
	touch= touchReadXY();
	
	if(keysdown&KEY_A)
	{
	    redraw_all^= 1;
	    iprintf("redraw each frame: %s\n", redraw_all? "on": "off");
	}
	
	if(keysdown&KEY_B)
	{
	    do_texalpha^= 1;
	    iprintf("texture alpha: %s\n", do_texalpha? "on": "off");
	}
	
	if(touch.x || touch.y)
	{
	    flux_mouse_event(touch.px, touch.py, 1);
	    lasttouch_x= touch.px, lasttouch_y= touch.py;
	    touch_wasdown= true;
	}
	else
	{
	    if(touch_wasdown) flux_mouse_event(lasttouch_x, lasttouch_y, 0);
	    touch_wasdown= false;
	}
	    

	flux_tick();
	if(redraw_all)
	{
	    redraw_rect(&viewport);
	    update_rect(&viewport);
	}
	
	swiWaitForVBlank();
    }

    return 0;
}
コード例 #5
0
ファイル: game.c プロジェクト: dibas/portalDS
static inline void render1(void)
{
	scanKeys();
	
	// cpuEndSlice();
	playerControls(NULL);
	updateControls();
	// iprintf("controls : %d  \n",cpuEndSlice());
	
		updatePlayer(NULL);
	// iprintf("player : %d  \n",cpuEndSlice());
	
		updatePortals();
		updateTurrets();
		updateBigButtons();
		updateTimedButtons();
		updateEnergyDevices();
		updateEnergyBalls();
		updatePlatforms();
		updateCubeDispensers();
		updateEmancipators();
		updateEmancipationGrids();
		updateDoors();
		updateWallDoors();
	// iprintf("updates : %d  \n",cpuEndSlice());
	
	// if(currentPortal)GFX_CLEAR_COLOR=currentPortal->color|(31<<16);
	// else GFX_CLEAR_COLOR=0;
	u16 color=getCurrentPortalColor(getPlayer()->object->position);
	// NOGBA("col %d",color);
	// GFX_CLEAR_COLOR=color|(31<<16);
	GFX_CLEAR_COLOR=RGB15(0,0,0)|(31<<16);
	
	#ifdef DEBUG_GAME
		if(fifoCheckValue32(FIFO_USER_08))iprintf("\x1b[0J");
		while(fifoCheckValue32(FIFO_USER_08)){int32 cnt=fifoGetValue32(FIFO_USER_08);iprintf("ALERT %d      \n",cnt);NOGBA("ALERT %d      \n",cnt);}
	#else
		while(fifoCheckValue32(FIFO_USER_08)){int32 cnt=fifoGetValue32(FIFO_USER_08);NOGBA("ALERT %d      \n",cnt);}
	#endif
	
	projectCamera(NULL);

	glPushMatrix();
		
		glScalef32(SCALEFACT,SCALEFACT,SCALEFACT);
		
		renderGun(NULL);
		
		transformCamera(NULL);
		
		cpuEndSlice();
			// drawRoomsGame(128, color);
			drawRoomsGame(0, color);
			// drawCell(getCurrentCell(getPlayer()->currentRoom,getPlayerCamera()->position));
		// iprintf("room : %d  \n",cpuEndSlice());
		
		updateParticles();
		drawParticles();
		// iprintf("particles : %d  \n",cpuEndSlice());
		
			drawOBBs();
		// iprintf("OBBs : %d  \n",cpuEndSlice());
			drawBigButtons();
			drawTimedButtons();
			drawEnergyDevices();
			drawEnergyBalls();
			drawPlatforms();
			drawCubeDispensers();
			drawTurretsStuff();
			drawEmancipators();
			drawEmancipationGrids();
			drawDoors();
			drawWallDoors(NULL);
			drawSludge(&gameRoom);
		// iprintf("stuff : %d  \n",cpuEndSlice());
		
		drawPortal(&portal1);
		drawPortal(&portal2);
			
	glPopMatrix(1);

	//HUD TEST
	if(levelInfoCounter>0 && (levelTitle || levelAuthor))
	{
		levelInfoCounter--;
		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
			glLoadIdentity();
			glOrthof32(inttof32(0), inttof32(255), inttof32(191), inttof32(0), -inttof32(1), inttof32(1));
			
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
				glLoadIdentity();

				if(levelTitle)drawCenteredString(levelTitle, inttof32(17)/10, (82));
				if(levelAuthor)drawCenteredString(levelAuthor, inttof32(1), (100));

			glPopMatrix(1);
			glMatrixMode(GL_PROJECTION);
		glPopMatrix(1);
	}
	
	glFlush(0);
}