示例#1
0
void SeaActor::renderSea(int xMin, int xMax, int zMin, int zMax, int inc, bool trick)
{
    int s = 900;

    int vel = 7;
    int zstart = sc->time / vel + zMin; //6 quad/s
    int zend= sc->time / vel + zMax; //6 quad/s
    int ofs = sc->time * s / vel;

    int r = 80;
    int b = 240;
    for(int z = zstart; z < zend; z+=inc)
    {
        glBegin(GL_QUAD_STRIP);
        int old1 = gety(xMin, z);
        int old2 = gety(xMin, z+inc);
        int oldc1 = getc(xMin, z);
        int oldc2 = getc(xMin, z+inc);

        GFX_TEX_COORD = TEXTURE_PACK(inttot16(64*inc), inttot16(0));
        glColor3b(r, oldc1, b);
        glVertex3v16((xMin+0)*s, old1, -(z+0)*s+ofs);
        GFX_TEX_COORD = TEXTURE_PACK(inttot16(64*inc), inttot16(64*inc));
        glColor3b(r, oldc2, b);
        glVertex3v16((xMin+0)*s, old2, -(z+inc)*s+ofs);
        bool tex = false;
        for(int x = xMin; x < xMax; x+=inc)
        {
            int new1 = gety(x+inc, z);
            int new2;

            if(trick && z == zend-1 && (x/inc)%2 == 0)
                new2 = (old2+gety(x+inc*2, z+inc))/2;
            else
                new2 = gety(x+inc, z+inc);
            int newc1 = getc(x+inc, z);
            int newc2 = getc(x+inc, z+inc);

            GFX_TEX_COORD = TEXTURE_PACK(inttot16(64*tex*inc), inttot16(0));
            glColor3b(r, newc1, b);
            glVertex3v16((x+inc)*s, new1, -(z+0)*s+ofs);
            GFX_TEX_COORD = TEXTURE_PACK(inttot16(64*tex*inc), inttot16(64*inc));
            glColor3b(r, newc2, b);
            glVertex3v16((x+inc)*s, new2, -(z+inc)*s+ofs);

            tex = !tex;
            old1 = new1;
            old2 = new2;
            oldc1 = newc1;
            oldc2 = newc2;
        }
        glEnd();
    }

}
示例#2
0
文件: turrets.c 项目: Almamu/portalDS
void drawLaser(vect3D orig, vect3D target)
{
	unbindMtl();
	glPolyFmt(POLY_ID(63));
	GFX_COLOR=RGB15(31,0,0);
	glPushMatrix();
		vect3D v=vectDifference(target,orig);
		glBegin(GL_TRIANGLES);
			glTranslatef32(orig.x, orig.y, orig.z);
			glVertex3v16(0, 0, 0);
			glTranslatef32(v.x, v.y, v.z);
			glVertex3v16(0, 0, 0);
			glVertex3v16(0, 0, 0);
	glPopMatrix(1);
}
示例#3
0
文件: turrets.c 项目: Almamu/portalDS
void drawTurretStuff(turret_struct* t)
{
	if(!t || !t->used || t->dead)return;
	
	drawLaser(t->laserOrigin,t->laserDestination);
	if(t->laserThroughPortal)drawLaser(t->laserOrigin2,t->laserDestination2);

	//TEMP TEST BILLBOARD
		vect3D u1=vect(t->OBB->transformationMatrix[0],t->OBB->transformationMatrix[3],t->OBB->transformationMatrix[6]);
		vect3D u2=vect(t->OBB->transformationMatrix[1],t->OBB->transformationMatrix[4],t->OBB->transformationMatrix[7]);
		vect3D u3=vect(t->OBB->transformationMatrix[2],t->OBB->transformationMatrix[5],t->OBB->transformationMatrix[8]);

		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_ID(63));
		GFX_COLOR=RGB15(31,31,31);
		applyMTL(turretShotTexture);

		if(t->drawShot[0])
		{
			glPushMatrix();
				glTranslatef32(t->laserOrigin.x, t->laserOrigin.y, t->laserOrigin.z);
				glTranslatef32(u3.x/128, u3.y/128, u3.z/128);
				glTranslatef32(u1.x/32, u1.y/32, u1.z/32);
				glScalef32(inttof32(1)/16,inttof32(1)/16,inttof32(1)/16);
				glRotatef32i(t->shotAngle[0],u3.x,u3.y,u3.z);
				glBegin(GL_QUADS);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
					glVertex3v16(-u1.x/2-u2.x, -u1.y/2-u2.y, -u1.z/2-u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(32), inttot16(0));
					glVertex3v16(+u1.x/2-u2.x, +u1.y/2-u2.y, +u1.z/2-u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(32), inttot16(64));
					glVertex3v16(+u1.x/2+u2.x, +u1.y/2+u2.y, +u1.z/2+u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(64));
					glVertex3v16(-u1.x/2+u2.x, -u1.y/2+u2.y, -u1.z/2+u2.z);
			glPopMatrix(1);
		}

		if(t->drawShot[1])
		{
			glPushMatrix();
				glTranslatef32(t->laserOrigin.x, t->laserOrigin.y, t->laserOrigin.z);
				glTranslatef32(u3.x/128, u3.y/128, u3.z/128);
				glTranslatef32(-u1.x/32, -u1.y/32, -u1.z/32);
				glScalef32(inttof32(1)/16,inttof32(1)/16,inttof32(1)/16);
				glRotatef32i(t->shotAngle[1],u3.x,u3.y,u3.z);
				glBegin(GL_QUADS);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
					glVertex3v16(-u1.x/2-u2.x, -u1.y/2-u2.y, -u1.z/2-u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(32), inttot16(0));
					glVertex3v16(+u1.x/2-u2.x, +u1.y/2-u2.y, +u1.z/2-u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(32), inttot16(64));
					glVertex3v16(+u1.x/2+u2.x, +u1.y/2+u2.y, +u1.z/2+u2.z);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(64));
					glVertex3v16(-u1.x/2+u2.x, -u1.y/2+u2.y, -u1.z/2+u2.z);
			glPopMatrix(1);
		}
}
示例#4
0
文件: polygon.c 项目: Almamu/portalDS
void drawPolygon(polygon_struct* p)
{
	if(!p || !p->next || !p->next->next)return;	
	polygon_struct* pp1=p->next;
	polygon_struct* pp2=pp1->next;
	
	glBegin(GL_TRIANGLES);
	while(pp2)
	{		
		// GFX_TEX_COORD=TEXTURE_PACK(p->t.x,p->t.y);
		glVertex3v16(p->v.x, p->v.y, p->v.z);
		// GFX_TEX_COORD=TEXTURE_PACK(pp1->t.x,pp1->t.y);
		glVertex3v16(pp1->v.x, pp1->v.y, pp1->v.z);
		// GFX_TEX_COORD=TEXTURE_PACK(pp2->t.x,pp2->t.y);
		glVertex3v16(pp2->v.x, pp2->v.y, pp2->v.z);
		pp1=pp2;
		pp2=pp2->next;
	}
}
//stats: LATS: 6, ANGLE_INCR: 0.523599, NDS_LATS: 2, NDS_ANGLE_INCR: 1.570796
void draw_sphere_point1()
{
#ifndef ECHO_NDS
	glutSolidSphere(0.100f, 6, 6);
#else
	glBegin(GL_QUAD_STRIP);
		glVertex3v16(-409, 409, -409);
		glVertex3v16(-409, -409, -409);
		glVertex3v16(409, 409, -409);
		glVertex3v16(409, -409, -409);
		glVertex3v16(409, 409, 409);
		glVertex3v16(409, -409, 409);
		glVertex3v16(-409, 409, 409);
		glVertex3v16(-409, -409, 409);
		glVertex3v16(-409, 409, -409);
		glVertex3v16(-409, -409, -409);
	glEnd();
#endif
}
示例#6
0
void Starfield_DrawStar(StarfieldStar *star)
{
	v16 startX = star->x * 64;
	v16 endX = startX + 64;

	v16 startY = star->y * 64;
	v16 endY = startY + 64;

	u16 star_color = star_palette[star->depth];
	glColor(star_color);

	glBegin(GL_QUAD);
	{
		glVertex3v16(startX, startY, 0);
		glVertex3v16(startX, endY, 0);
		glVertex3v16(endX, endY, 0);
		glVertex3v16(endX, startY, 0);
	}
	glEnd();
}
示例#7
0
//draw a cube face at the specified color
 void drawQuad(int poly)
{	
	
	u32 f1 = CubeFaces[poly * 4] ;
	u32 f2 = CubeFaces[poly * 4 + 1] ;
	u32 f3 = CubeFaces[poly * 4 + 2] ;
	u32 f4 = CubeFaces[poly * 4 + 3] ;


	glNormal(normals[poly]);

	GFX_TEX_COORD = (uv[0]);
	glVertex3v16(CubeVectors[f1*3], CubeVectors[f1*3 + 1], CubeVectors[f1*3 +  2] );
	
	GFX_TEX_COORD = (uv[1]);
	glVertex3v16(CubeVectors[f2*3], CubeVectors[f2*3 + 1], CubeVectors[f2*3 + 2] );
	
	GFX_TEX_COORD = (uv[2]);
	glVertex3v16(CubeVectors[f3*3], CubeVectors[f3*3 + 1], CubeVectors[f3*3 + 2] );

	GFX_TEX_COORD = (uv[3]);
	glVertex3v16(CubeVectors[f4*3], CubeVectors[f4*3 + 1], CubeVectors[f4*3 + 2] );
}
示例#8
0
文件: polygon.c 项目: Almamu/portalDS
void drawPolygonStrip(polygon_struct* p, u16 col1, u16 col2)
{
	if(!p || !p->next || !p->next->next || !p->next->next->next)return;	
	polygon_struct* pp1=p;
	u8 cnt=0;
	
	glBegin(GL_QUAD_STRIP);
	while(pp1)
	{
		// GFX_TEX_COORD=TEXTURE_PACK(pp1->t.x,pp1->t.y);
		GFX_COLOR=cnt?col2:col1;
		glVertex3v16(pp1->v.x, pp1->v.y, pp1->v.z);
		pp1=pp1->next;
		cnt++;
		cnt%=2;
	}
}
示例#9
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);
}
示例#10
0
文件: video.c 项目: Tomwi/FeOSMusic
void drawLine(int x, int y, int x2, int y2)
{
	glVertex3v16(x,y,0);
	glVertex2v16(x2,y2);
	glVertex2v16(x2,y2);
}
示例#11
0
文件: main.cpp 项目: bkuker/DiceDS
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");
}
示例#12
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 
示例#13
0
void RubiksCube::Draw(touchPosition touchXY)
{
	int viewport[]={0,0,255,191}; // used later for gluPickMatrix()
	
	int16 vx, vy, vz, vsize;
	vx = f32tov16(Position.X);
	vy = f32tov16(Position.Y);
	vz = f32tov16(Position.Z);
	vsize = f32tov16(Size);

	glPushMatrix();
	{
		glRotateY(90);
		glRotateZ(180);
		
		if(Twisting||AutoTwisting)
		{
			int ax=0;
			// Rotate so we draw the cube the right way round
			while(ax<Twist.axis)
			{
				glRotateX(90);
				glRotateZ(90);
				ax++;
			}

			if(Twist.position==0 || Twist.position==3) glRotateZ(Twist.rotation);
			DrawSide(Twist.left.side,Twist.axis,Position.X,Position.Y,Position.Z,Size,false);
			glBegin(GL_QUADS);
				glColor3f(0,0,0);
				glVertex3v16(vx + vsize, vy, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx, vy, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx, vy + vsize, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx + vsize, vy + vsize, vz + f32tov16(divf32(Size,inttof32(3))));
			glEnd();
			if(Twist.position==0 || Twist.position==3) glRotateZ(-Twist.rotation);
			glRotateY(180);
			if(Twist.position==2 || Twist.position==3) glRotateZ(-Twist.rotation);
			DrawSide(Twist.right.side,Twist.axis+3,Position.X,Position.Y,Position.Z,Size,false);
			glBegin(GL_QUADS);
				glColor3f(0,0,0);
				glVertex3v16(vx + vsize, vy, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx, vy, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx, vy + vsize, vz + f32tov16(divf32(Size,inttof32(3))));
				glVertex3v16(vx + vsize, vy + vsize, vz + f32tov16(divf32(Size,inttof32(3))));
			glEnd();
			if(Twist.position==2 || Twist.position==3) glRotateZ(Twist.rotation);
			glRotateY(90);
			glRotateX(-90);
			if(Twist.position==1 || Twist.position==3) glRotateX(Twist.rotation);
			glBegin(GL_QUADS);
				glColor3f(0,0,0);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3))), vy, vz);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3))), vy + vsize, vz);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3))), vy + vsize, vz + vsize);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3))), vy, vz + vsize);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3)))*2, vy, vz);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3)))*2, vy, vz + vsize);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3)))*2, vy + vsize, vz + vsize);
				glVertex3v16(vx + f32tov16(divf32(Size,inttof32(3)))*2, vy + vsize, vz);
			glEnd();
			if(Twist.position==1 || Twist.position==3) glRotateX(-Twist.rotation);
			for(int i=0;i<4;i++)
			{
				if(Twist.position==0) glRotateX(Twist.rotation);
				DrawLine(Twist.left.line[i],Position.X,Position.Y,Position.Z,Size/3);
				if(Twist.position==0) glRotateX(-Twist.rotation);
				if(Twist.position==1) glRotateX(Twist.rotation);
				DrawLine(Twist.middle.line[i],Position.X+(Size/3),Position.Y,Position.Z,Size/3);
				if(Twist.position==1) glRotateX(-Twist.rotation);
				if(Twist.position==2) glRotateX(Twist.rotation);
				DrawLine(Twist.right.line[i],Position.X+(Size/3*2),Position.Y,Position.Z,Size/3);
				if(Twist.position==2) glRotateX(-Twist.rotation);
				glRotateX(90);
			}
		}else{
			for(int i=0;i<3;i++)
			{
				DrawSide(Side[i],i,Position.X,Position.Y,Position.Z,Size, false);
				glRotateY(180);
				DrawSide(Side[i+3],i+3,Position.X,Position.Y,Position.Z,Size, false);
				glRotateX(90);
				glRotateZ(-90);
			}
		}
	}
	glPopMatrix(1);
	
	
	if(Picking)
	{
		glPushMatrix();
		for(int i=0;i<3;i++)
			clicked[i]=0;
		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(70, 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
		
		{
			glRotateY(90);
			glRotateZ(180);
			for(int i=0;i<3;i++)
			{
				DrawSide(Side[i],i,Position.X,Position.Y,Position.Z,Size, true);
				glRotateY(180);
				DrawSide(Side[i+3],i+3,Position.X,Position.Y,Position.Z,Size, true);
				glRotateX(90);
				glRotateZ(-90);
			}
		}
		
		glViewport(0,0,255,191);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(70, 256.0 / 192.0, 0.1, 20);
		glMatrixMode(GL_MODELVIEW);
		
		if(closeW<0x7FFFFFFF)
		{
			if(Painting)
			{
				if(Side[clicked[0]].tile[clicked[1]][clicked[2]].color!=paintColour)
				{
					if(undoQueue.numEntries==0)
					{
						undoQueue.numEntries++;
						undoQueue.currentEntry=0;
					}
					else if(undoQueue.currentEntry < (undoQueue.numEntries-1))
					{
						undoQueue.currentEntry++;
						undoQueue.numEntries=undoQueue.currentEntry+1;
					}
					else if(undoQueue.numEntries==20)
					{
						for(int i=0; i<19; i++)
						{
						undoQueue.entry[i]=undoQueue.entry[i+1];
						}
					}
					else
					{
						undoQueue.numEntries++;
						undoQueue.currentEntry++;
					}
					undoQueue.entry[undoQueue.currentEntry].from=Side[clicked[0]].tile[clicked[1]][clicked[2]].color;
					undoQueue.entry[undoQueue.currentEntry].to=paintColour;
					for(int i=0; i<3; i++)
						undoQueue.entry[undoQueue.currentEntry].position[i]=clicked[i];
				
					Side[clicked[0]].tile[clicked[1]][clicked[2]].color=paintColour;
				}
			}else{
				Grabbing=true;
				Picking=false;
			}
		}
		glPopMatrix(1);
	}else{
		//Twisting=false;
	}
}
示例#14
0
int main()
{	
    struct touchPosition pos;
	float rotateX = 0.0;
	float rotateY = 0.0;

	powerON(POWER_ALL);
    consoleDemoInit();

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

	//irqs are nice
	irqInit();
	irqEnable(IRQ_VBLANK);
    
	// 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);
    
	//any floating point gl call is being converted to fixed prior to being implemented
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(35, 256.0 / 192.0, 0.1, 100);
	
	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)		
	{
        float px, py;
        
    	pos = touchReadXY();
        px = pos.px;
        py = pos.py;

        px = (px * 5) / 256;
        py = (py * 3) / 192;

        px -= 2.5;
        py -= 1.5;

		glPushMatrix();

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

		glRotateX(rotateX);
		glRotateY(rotateY);

		glMatrixMode(GL_MODELVIEW);

		//not a real gl function and will likely change
		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
        
		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;
        
		//draw the obj
		glBegin(GL_TRIANGLE);
			
			glColor3b(255,0,0);
			glVertex3v16(inttov16(-1),inttov16(-1),0);

			glColor3b(0,255,0);
			glVertex3v16(inttov16(1), inttov16(-1), 0);

			glColor3b(0,0,255);
			glVertex3v16(inttov16(0), inttov16(1), 0);
			
		glEnd();

        glLoadIdentity();
        glTranslatef(px,-py,-3.0);
        glBegin(GL_TRIANGLE);
            glVertex3f( 0.0, 1.0, 0.0);
            glVertex3f(-1.0,-1.0, 0.0);
            glVertex3f( 1.0,-1.0, 0.0);
        glEnd();

		glPopMatrix(1);

		glFlush(0);
		swiWaitForVBlank();
	}

	return 0;
}//end main 
示例#15
0
//stats: LATS: 6, ANGLE_INCR: 0.523599, NDS_LATS: 2, NDS_ANGLE_INCR: 1.570796
void draw_left_hand()
{
#ifndef ECHO_NDS
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.000f, 0.000f, -0.075f);
		glVertex3f(0.037f, 0.000f, -0.065f);
		glVertex3f(0.000f, -0.050f, -0.065f);
		glVertex3f(0.032f, -0.050f, -0.056f);
		glVertex3f(0.000f, -0.087f, -0.038f);
		glVertex3f(0.019f, -0.087f, -0.032f);
		glVertex3f(0.000f, -0.100f, -0.000f);
		glVertex3f(0.000f, -0.100f, -0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.037f, 0.000f, -0.065f);
		glVertex3f(0.065f, 0.000f, -0.038f);
		glVertex3f(0.032f, -0.050f, -0.056f);
		glVertex3f(0.056f, -0.050f, -0.032f);
		glVertex3f(0.019f, -0.087f, -0.032f);
		glVertex3f(0.032f, -0.087f, -0.019f);
		glVertex3f(0.000f, -0.100f, -0.000f);
		glVertex3f(0.000f, -0.100f, -0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.065f, 0.000f, -0.038f);
		glVertex3f(0.075f, 0.000f, -0.000f);
		glVertex3f(0.056f, -0.050f, -0.032f);
		glVertex3f(0.065f, -0.050f, -0.000f);
		glVertex3f(0.032f, -0.087f, -0.019f);
		glVertex3f(0.038f, -0.087f, -0.000f);
		glVertex3f(0.000f, -0.100f, -0.000f);
		glVertex3f(0.000f, -0.100f, -0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.075f, 0.000f, -0.000f);
		glVertex3f(0.065f, 0.000f, 0.037f);
		glVertex3f(0.065f, -0.050f, -0.000f);
		glVertex3f(0.056f, -0.050f, 0.032f);
		glVertex3f(0.038f, -0.087f, -0.000f);
		glVertex3f(0.032f, -0.087f, 0.019f);
		glVertex3f(0.000f, -0.100f, -0.000f);
		glVertex3f(0.000f, -0.100f, 0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.065f, 0.000f, 0.037f);
		glVertex3f(0.038f, 0.000f, 0.065f);
		glVertex3f(0.056f, -0.050f, 0.032f);
		glVertex3f(0.032f, -0.050f, 0.056f);
		glVertex3f(0.032f, -0.087f, 0.019f);
		glVertex3f(0.019f, -0.087f, 0.032f);
		glVertex3f(0.000f, -0.100f, 0.000f);
		glVertex3f(0.000f, -0.100f, 0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.038f, 0.000f, 0.065f);
		glVertex3f(0.000f, 0.000f, 0.075f);
		glVertex3f(0.032f, -0.050f, 0.056f);
		glVertex3f(0.000f, -0.050f, 0.065f);
		glVertex3f(0.019f, -0.087f, 0.032f);
		glVertex3f(0.000f, -0.087f, 0.038f);
		glVertex3f(0.000f, -0.100f, 0.000f);
		glVertex3f(0.000f, -0.100f, 0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.000f, 0.000f, 0.075f);
		glVertex3f(-0.037f, 0.000f, 0.065f);
		glVertex3f(0.000f, -0.050f, 0.065f);
		glVertex3f(-0.032f, -0.050f, 0.056f);
		glVertex3f(0.000f, -0.087f, 0.038f);
		glVertex3f(-0.019f, -0.087f, 0.032f);
		glVertex3f(0.000f, -0.100f, 0.000f);
		glVertex3f(-0.000f, -0.100f, 0.000f);
	glEnd();
#else
	glBegin(GL_QUAD_STRIP);
		glVertex3v16(0, 0, 307);
		glVertex3v16(307, 0, 307);
		glVertex3v16(0, -409, 307);
		glVertex3v16(307, -409, 307);
		glVertex3v16(0, -409, -307);
		glVertex3v16(307, -409, -307);
		glVertex3v16(0, 0, -307);
		glVertex3v16(307, 0, -307);
	glEnd();
	glBegin(GL_QUADS);
		glVertex3v16(307, 0, 307);
		glVertex3v16(307, -409, 307);
		glVertex3v16(307, -409, -307);
		glVertex3v16(307, 0, -307);
	glEnd();
#endif
}
示例#16
0
void renderObject(LevelObj& obj, f32 xx, f32 yy, Scene* sc)
{
	int x = xx.toint();
	int y = yy.toint();
	const int z = 1000;

		if(obj.type == BEH_WATER || obj.type == BEH_LAVA || obj.type == BEH_WATERDOWN || obj.type == BEH_LAVADOWN)
		{
			bool top = obj.type == BEH_WATER || obj.type == BEH_LAVA;
			bool lava = obj.type == BEH_LAVADOWN || obj.type == BEH_LAVA;

			if(top)
			{
				setTexture(TEX_VERTGRAD);
				glPolyFmt(POLY_ALPHA(28) | POLY_ID(WATER_POLYID) | POLY_CULL_NONE);
				glBegin(GL_QUAD_STRIP);
				int divnum = 32;
				f32 dx = obj.x[1]-obj.x[0];
				f32 dy = obj.y[1]-obj.y[0];
				f32 len = fsqrt(dx*dx+dy*dy);
				if(len < 90) divnum = 16;
				if(len < 45) divnum = 8;
				if(!top) divnum = 1;
				for(int j = 0; j <= divnum; j++)
				{
					int x1 = (obj.x[0]*j+obj.x[1]*(divnum-j))/divnum;
					int y1 = (obj.y[0]*j+obj.y[1]*(divnum-j))/divnum;
					int x2 = (obj.x[3]*j+obj.x[2]*(divnum-j))/divnum;
					int y2 = (obj.y[3]*j+obj.y[2]*(divnum-j))/divnum;
					
					f32 dx = x2-x1;
					f32 dy = y2-y1;
					f32 len = fsqrt(dx*dx+dy*dy);
					dx /= len;
					dy /= len;
					
					int in = x1*19+y1*14+sc->time*20;
					int in2 = x1*24-y1*18-sc->time*12;
	//				int in2 = x1*18-y1*21-sc->time*15;
					if(top)
					{
						int xw = 0;
						if(!lava)
						{
							xw += sinLerp(in*40)/600;
							xw += sinLerp(in2*23)/600;
						}
						else
						{
							xw += sinLerp(in*27)/800;
							xw += sinLerp(in2*13)/300;
						}
						dx *= xw;
						dy *= xw;
						x1 += dx.toint();
						y1 += dy.toint();
						
						if(!lava)
							glColor3b(130, 180, 255);
						else
							glColor3b(255, 180, 30);
					}
					
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(64));
					glVertex3v16((x1-x)*32, (y1-y)*32, z);

					if(!lava)
						glColor3b(20, 50, 215);
					else
						glColor3b(255, 60, 0);
					GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(0));
					glVertex3v16((x2-x)*32, (y2-y)*32, z);
				}
				glEnd();
			}
			else
			{
				if(!lava)
					glColor3b(20, 50, 215);
				else
					glColor3b(255, 60, 0);

				setNoTexture();
				glPolyFmt(POLY_ALPHA(7) | POLY_ID(WATER_POLYID) | POLY_CULL_NONE);
				
				glBegin(GL_QUAD);

				glVertex3v16((obj.x[0]-x)*32, (obj.y[0]-y)*32, z);
				glVertex3v16((obj.x[1]-x)*32, (obj.y[1]-y)*32, z);
				glVertex3v16((obj.x[2]-x)*32, (obj.y[2]-y)*32, z);
				glVertex3v16((obj.x[3]-x)*32, (obj.y[3]-y)*32, z);

				glEnd();
				
			}
		}
		else
		{

			int a = 28;
			if(obj.type == BEH_WALL)
				glColor3b(200, 200, 255);
			else if(obj.type == BEH_BOUNCY)
				glColor3b(255, 100, 210);
			else if(obj.type == BEH_PORTAL1)
				glColor3b(100, 255, 20);
			else if(obj.type == BEH_PORTAL2)
				glColor3b(30, 140, 210);

			if(obj.type == BEH_PORTAL1 && sc->switchesActive[0]) a = 6;
			if(obj.type == BEH_PORTAL2 && sc->switchesActive[1]) a = 6;
			
			if(debugShown)
			{
				if(obj.state == 1)
					glColor3b(0, 200, 0);
				else if(obj.state == 2)
					glColor3b(0, 000, 200);
			}
			
			setTexture(TEX_INVBALL);
			glPolyFmt(POLY_ALPHA(a) | POLY_ID(LEVEL_POLYID) | POLY_CULL_NONE);

			glBegin(GL_QUAD);

			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(0));
			glVertex3v16((obj.x[0]-x)*32, (obj.y[0]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(64), inttot16(64));
			glVertex3v16((obj.x[1]-x)*32, (obj.y[1]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(64));
			glVertex3v16((obj.x[2]-x)*32, (obj.y[2]-y)*32, z);
			GFX_TEX_COORD = TEXTURE_PACK(inttot16(0), inttot16(0));
			glVertex3v16((obj.x[3]-x)*32, (obj.y[3]-y)*32, z);

			glEnd();
		}
}
示例#17
0
//---------------------------------------------------------------------------------
// Draw a single tile of the rubik's cube. assumes all necessary rotation has
// been performed already.
//---------------------------------------------------------------------------------
void RubiksCube::DrawTile(int color, int32 x, int32 y, int32 z, int32 size, bool picking)
{
	int16 blackbit = f32tov16(divf32(size, inttof32(20)));

	int16 vx, vy, vz, vsize;
	vx = f32tov16(x);
	vy = f32tov16(y);
	vz = f32tov16(z);
	vsize = f32tov16(size);

	if(!picking) SetRCColor(color); //if we're not picking, then we need the right colour
	// Draw the coloured part of the tile (sans black bits):
	glVertex3v16(vx + blackbit, vy + blackbit, vz);
	glVertex3v16(vx + vsize - blackbit, vy + blackbit, vz);
	glVertex3v16(vx + vsize - blackbit, vy + vsize - blackbit, vz);
	glVertex3v16(vx + blackbit, vy + vsize - blackbit, vz);

	if(!picking) //if we're not picking, better draw in the black bits too
	{
		glColor3f(0,0,0);
		//top
		glVertex3v16(vx, vy, vz + blackbit);
		glVertex3v16(vx + vsize, vy, vz + blackbit);
		glVertex3v16(vx + vsize - blackbit, vy + blackbit, vz);
		glVertex3v16(vx + blackbit, vy + blackbit, vz);
		//right
		glVertex3v16(vx + vsize - blackbit, vy + blackbit, vz);
		glVertex3v16(vx + vsize, vy, vz + blackbit);
		glVertex3v16(vx + vsize, vy + vsize, vz + blackbit);
		glVertex3v16(vx + vsize - blackbit, vy + vsize - blackbit, vz);
		//bottom
		glVertex3v16(vx + blackbit, vy + vsize - blackbit, vz);
		glVertex3v16(vx + vsize - blackbit, vy + vsize - blackbit, vz);
		glVertex3v16(vx + vsize, vy + vsize, vz + blackbit);
		glVertex3v16(vx, vy + vsize, vz + blackbit);
		//left
		glVertex3v16(vx, vy, vz + blackbit);
		glVertex3v16(vx + blackbit, vy + blackbit, vz);
		glVertex3v16(vx + blackbit, vy + vsize - blackbit, vz);
		glVertex3v16(vx, vy + vsize, vz + blackbit);
	}
}
示例#18
0
//stats: LATS: 6, ANGLE_INCR: 0.523599, NDS_LATS: 2, NDS_ANGLE_INCR: 1.570796
void draw_foot()
{
#ifndef ECHO_NDS
	glBegin(GL_QUAD_STRIP);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.037f, 0.130f, 0.000f);
		glVertex3f(-0.032f, 0.130f, 0.050f);
		glVertex3f(-0.065f, 0.075f, 0.000f);
		glVertex3f(-0.056f, 0.075f, 0.087f);
		glVertex3f(-0.075f, 0.000f, 0.000f);
		glVertex3f(-0.065f, 0.000f, 0.100f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.032f, 0.130f, 0.050f);
		glVertex3f(-0.019f, 0.130f, 0.087f);
		glVertex3f(-0.056f, 0.075f, 0.087f);
		glVertex3f(-0.032f, 0.075f, 0.150f);
		glVertex3f(-0.065f, 0.000f, 0.100f);
		glVertex3f(-0.038f, 0.000f, 0.173f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(-0.019f, 0.130f, 0.087f);
		glVertex3f(-0.000f, 0.130f, 0.100f);
		glVertex3f(-0.032f, 0.075f, 0.150f);
		glVertex3f(-0.000f, 0.075f, 0.173f);
		glVertex3f(-0.038f, 0.000f, 0.173f);
		glVertex3f(-0.000f, 0.000f, 0.200f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(-0.000f, 0.150f, 0.000f);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(-0.000f, 0.130f, 0.100f);
		glVertex3f(0.019f, 0.130f, 0.087f);
		glVertex3f(-0.000f, 0.075f, 0.173f);
		glVertex3f(0.032f, 0.075f, 0.150f);
		glVertex3f(-0.000f, 0.000f, 0.200f);
		glVertex3f(0.037f, 0.000f, 0.173f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(0.019f, 0.130f, 0.087f);
		glVertex3f(0.032f, 0.130f, 0.050f);
		glVertex3f(0.032f, 0.075f, 0.150f);
		glVertex3f(0.056f, 0.075f, 0.087f);
		glVertex3f(0.037f, 0.000f, 0.173f);
		glVertex3f(0.065f, 0.000f, 0.100f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(0.032f, 0.130f, 0.050f);
		glVertex3f(0.037f, 0.130f, 0.000f);
		glVertex3f(0.056f, 0.075f, 0.087f);
		glVertex3f(0.065f, 0.075f, 0.000f);
		glVertex3f(0.065f, 0.000f, 0.100f);
		glVertex3f(0.075f, 0.000f, 0.000f);
	glEnd();
	glBegin(GL_QUAD_STRIP);
		glVertex3f(0.000f, 0.150f, 0.000f);
		glVertex3f(0.000f, 0.150f, -0.000f);
		glVertex3f(0.037f, 0.130f, 0.000f);
		glVertex3f(0.032f, 0.130f, -0.050f);
		glVertex3f(0.065f, 0.075f, 0.000f);
		glVertex3f(0.056f, 0.075f, -0.087f);
		glVertex3f(0.075f, 0.000f, 0.000f);
		glVertex3f(0.065f, 0.000f, -0.100f);
	glEnd();
#else
	glBegin(GL_QUAD_STRIP);
		glVertex3v16(-307, 0, 0);
		glVertex3v16(-307, 0, 819);
		glVertex3v16(-307, 614, 0);
		glVertex3v16(-307, 614, 819);
		glVertex3v16(307, 614, 0);
		glVertex3v16(307, 614, 819);
		glVertex3v16(307, 0, 0);
		glVertex3v16(307, 0, 819);
	glEnd();
	glBegin(GL_QUADS);
		glVertex3v16(-307, 0, 819);
		glVertex3v16(-307, 614, 819);
		glVertex3v16(307, 614, 819);
		glVertex3v16(307, 0, 819);
	glEnd();
#endif
}
示例#19
0
int main()
{

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

	//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)
	{
		glPushMatrix();

		//move it away from the camera
		glTranslatef32(0, 0, floattof32(-1));

		glRotateX(rotateX);
		glRotateY(rotateY);


		glMatrixMode(GL_MODELVIEW);



		//not a real gl function and will likely change
		glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);

		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;

		//draw the obj
		glBegin(GL_QUAD);

			glColor3b(255,0,0);
			glVertex3v16(inttov16(-1),inttov16(-1),0);

			glColor3b(0,255,0);
			glVertex3v16(inttov16(1), inttov16(-1), 0);

			glColor3b(0,0,255);
			glVertex3v16(inttov16(1), inttov16(1), 0);

			glColor3b(255,0,255);
			glVertex3v16(inttov16(-1), inttov16(1), 0);

		glEnd();

		glPopMatrix(1);

		glFlush(0);

		swiWaitForVBlank();

		if(keys & KEY_START) break;
	}

	return 0;
}//end main
示例#20
0
int renderModel(struct MODEL * model)
{
	int v_one, v_two, v_thr;
	int c_one, c_two, c_thr;
	//int n_one, n_two, n_thr;
	int t_one, t_two, t_thr;
	v16 v_x, v_y, v_z;
	t16 u_m, v_m;
	char r, g, b;
	//v16 n_x, n_y, n_z;
	
	int objectC = 0;
	int triangleC = 0;
	
	while(objectC < model->header.objectCount)
	{
		glMatrixMode(GL_MODELVIEW);
		glPushMatrix();
		
		unsigned char mat = model->faces.object[objectC].materialID;
		unsigned char X = model->materials.material[mat].X;
		unsigned char Y = model->materials.material[mat].Y;
		unsigned char TX = model->materials.material[mat].TX;
		unsigned char TY = model->materials.material[mat].TY;
		unsigned char A = model->materials.material[mat].alpha;
		unsigned char C = model->materials.material[mat].culling;
		
		glPolyFmt(POLY_ALPHA(A) | C);
		
		if(TX != 0 || TY != 0)
		{
			glMatrixMode(GL_TEXTURE);
			glLoadIdentity();
			glTranslatef(model->materials.material[mat].scrollX, model->materials.material[mat].scrollY, 0);
			model->materials.material[mat].scrollX += TX;
			model->materials.material[mat].scrollY += TY;
		}
		
		glBindTexture(GL_TEXTURE_2D, model->textures[mat]);
		
		while(triangleC < model->faces.object[objectC].triangleCount)
		{
			v_one = model->faces.object[objectC].triangles[triangleC].triangle[0].v;
			v_two = model->faces.object[objectC].triangles[triangleC].triangle[1].v;
			v_thr = model->faces.object[objectC].triangles[triangleC].triangle[2].v;
			c_one = model->faces.object[objectC].triangles[triangleC].triangle[0].c;
			c_two = model->faces.object[objectC].triangles[triangleC].triangle[1].c;
			c_thr = model->faces.object[objectC].triangles[triangleC].triangle[2].c;
			/*n_one = model->faces.object[objectC].triangles[triangleC].triangle[0].n;
			n_two = model->faces.object[objectC].triangles[triangleC].triangle[1].n;
			n_thr = model->faces.object[objectC].triangles[triangleC].triangle[2].n;*/
			t_one = model->faces.object[objectC].triangles[triangleC].triangle[0].t;
			t_two = model->faces.object[objectC].triangles[triangleC].triangle[1].t;
			t_thr = model->faces.object[objectC].triangles[triangleC].triangle[2].t;
			
			glBegin(GL_TRIANGLES);
			glNormal(NORMAL_PACK( 0, 0, 1<<10));
						
			v_x = model->vertices.vertex[v_one].x;
			v_y = model->vertices.vertex[v_one].y;
			v_z = model->vertices.vertex[v_one].z;
			r = model->colors.color[c_one].r;
			g = model->colors.color[c_one].g;
			b = model->colors.color[c_one].b;
			/*n_x = model->normals.normal[n_one].x;
			n_y = model->normals.normal[n_one].y;
			n_z = model->normals.normal[n_one].z;
			glNormal3f(n_x, n_y, n_z);*/
			u_m = model->coordinates.coordinate[t_one].u;
			v_m = model->coordinates.coordinate[t_one].v;
			glColor3b(r,g,b);
			glTexCoord2t16(u_m * X,v_m * Y);
			glVertex3v16(v_x, v_y, v_z);
			
			v_x = model->vertices.vertex[v_two].x;
			v_y = model->vertices.vertex[v_two].y;
			v_z = model->vertices.vertex[v_two].z;
			r = model->colors.color[c_two].r;
			g = model->colors.color[c_two].g;
			b = model->colors.color[c_two].b;
			/*n_x = model->normals.normal[n_two].x;
			n_y = model->normals.normal[n_two].y;
			n_z = model->normals.normal[n_two].z;
			glNormal3f(n_x, n_y, n_z);*/
			u_m = model->coordinates.coordinate[t_two].u;
			v_m = model->coordinates.coordinate[t_two].v;
			glColor3b(r,g,b);
			glTexCoord2t16(u_m * X,v_m * Y);
			glVertex3v16(v_x, v_y, v_z);
			
			v_x = model->vertices.vertex[v_thr].x;
			v_y = model->vertices.vertex[v_thr].y;
			v_z = model->vertices.vertex[v_thr].z;
			r = model->colors.color[c_thr].r;
			g = model->colors.color[c_thr].g;
			b = model->colors.color[c_thr].b;
			/*n_x = model->normals.normal[n_thr].x;
			n_y = model->normals.normal[n_thr].y;
			n_z = model->normals.normal[n_thr].z;
			glNormal3f(n_x, n_y, n_z);*/
			u_m = model->coordinates.coordinate[t_thr].u;
			v_m = model->coordinates.coordinate[t_thr].v;
			glColor3b(r,g,b);
			glTexCoord2t16(u_m * X,v_m * Y);
			glVertex3v16(v_x, v_y, v_z);
			
			glEnd();
			
			triangleC++;
		}
		
		glPopMatrix(1);
		
		triangleC = 0;
		objectC++;
	}
	
	return 1;
}