Exemplo n.º 1
0
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");
}
Exemplo n.º 2
0
int main() {	
	
	int textureID;

	float rotateX = 0.0;
	float rotateY = 0.0;

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

	// initialize gl
	glInit();
	
	//enable textures
	glEnable(GL_TEXTURE_2D);
	
	// 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);
	
	vramSetBankA(VRAM_A_TEXTURE);

	glGenTextures(1, &textureID);
	glBindTexture(0, textureID);
	glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)texture_bin);
	
	
	//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);
	
	gluLookAt(	0.0, 0.0, 1.0,		//camera possition 
				0.0, 0.0, 0.0,		//look at
				0.0, 1.0, 0.0);		//up	
	
	while(1) {
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();

		//move it away from the camera
		glTranslate3f32(0, 0, floattof32(-1));
				
		glRotateX(rotateX);
		glRotateY(rotateY);
		
		

		glMaterialf(GL_AMBIENT, RGB15(16,16,16));
		glMaterialf(GL_DIFFUSE, RGB15(16,16,16));
		glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));
		glMaterialf(GL_EMISSION, RGB15(16,16,16));

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

		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;
		
		glBindTexture(0, textureID);

		//draw the obj
		glBegin(GL_QUAD);
			glNormal(NORMAL_PACK(0,inttov10(-1),0));

			GFX_TEX_COORD = (TEXTURE_PACK(0, inttot16(128)));
			glVertex3v16(floattov16(-0.5),	floattov16(-0.5), 0 );
	
			GFX_TEX_COORD = (TEXTURE_PACK(inttot16(128),inttot16(128)));
			glVertex3v16(floattov16(0.5),	floattov16(-0.5), 0 );
	
			GFX_TEX_COORD = (TEXTURE_PACK(inttot16(128), 0));
			glVertex3v16(floattov16(0.5),	floattov16(0.5), 0 );

			GFX_TEX_COORD = (TEXTURE_PACK(0,0));
			glVertex3v16(floattov16(-0.5),	floattov16(0.5), 0 );
		
		glEnd();
		
		glPopMatrix(1);
			
		glFlush(0);

		swiWaitForVBlank();
	}

	return 0;
}//end main