Пример #1
0
void draw_stalk( f32 angle, f32 scale, f32 sx, f32 sy, u8 *col )
{
	f32 ca, sa;
	s32 i;

	if( scale < 0.2f ) return;

	ca = cos( angle );
	sa = sin( angle );

	for( i=0; i<NUM_STALK_VERTICES; i++ )
	{
		stalk[i].sx = ((stalk[i].x*ca - stalk[i].y*sa) * scale) + sx;
		stalk[i].sy = ((stalk[i].x*sa + stalk[i].y*ca) * scale) + sy;
	}

	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, NUM_STALK_POLYS*3 );
	for( i=0; i<NUM_STALK_POLYS*3; i++ )
	{
		GX_Position3f32( stalk[stalk_polys[i]].sx, stalk[stalk_polys[i]].sy, 1.0f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
	}
	GX_End();
  
	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, NUM_STALK_EDGES );
	for( i=0; i<NUM_STALK_EDGES; i++ )
	{
		GX_Position3f32( stalk[stalk_edges[i]].sx, stalk[stalk_edges[i]].sy, 1.0f );
		GX_Color4u8( 0, 0, 0, 0xff );
	}
	GX_End();

	stalktopx = ((stopx*ca - stopy*sa)*scale) + sx;
	stalktopy = ((stopx*sa + stopy*ca)*scale) + sy;
}
Пример #2
0
void drawAGoofyWhiteTriangle(){
	GX_Begin(GX_TRIANGLES, GX_VTXFMT0, 3);
		GX_Position3f32( 0.0f, 1.0f, 0.0f);		// Top
		GX_Position3f32(-1.0f,-1.0f, 0.0f);	// Bottom Left
		GX_Position3f32( 1.0f,-1.0f, 0.0f);	// Bottom Right
	GX_End();
}
Пример #3
0
void GuiCross::Draw()
{
	GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);

	f32 x1 = GetLeft();
	f32 x2 = x1 + width;
	f32 y1 = GetTop();
	f32 y2 = y1 + height;
	
	int alpha = GetAlpha();
	
	GX_Begin(GX_LINES, GX_VTXFMT0, 4);
	GX_Position3f32(x1, y1, 0.0f);
	GX_Color4u8(color.r, color.g, color.b, alpha);
	GX_Position3f32(x2, y2, 0.0f);
	GX_Color4u8(color.r, color.g, color.b, alpha);
	GX_Position3f32(x2, y1, 0.0f);
	GX_Color4u8(color.r, color.g, color.b, alpha);
	GX_Position3f32(x1, y2, 0.0f);
	GX_Color4u8(color.r, color.g, color.b, alpha);
	GX_End();
	GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
}
Пример #4
0
void circle( f32 x, f32 y, f32 r, u8 *col, u8 edge, s32 amt, f32 z )
{
	s32 segs, i;
	f32 a, aa, px, py;
	
	if( r < 1.0f )
	  return;
	
	if( r > 240.0f )
		segs = 60;
	else if( r > 160.0f )
		segs = 44;
	else if( r > 100.0f )
		segs = 36;
	else if( r > 80.0f )
		segs = 28;
	else if( r > 40.0f )
		segs = 20;
	else if( r > 20.0f )
		segs = 14;
	else if( r > 10.0f )
		segs = 10;
	else
		segs = 8;

	aa = (3.14159265f*2.0f) / (f32)segs;
	a = 0.0f;
	
	segs = (segs*amt)/100;

	GX_Begin( GX_TRIANGLEFAN, GX_VTXFMT0, segs+2 );
	GX_Position3f32( x, y, z );
	GX_Color4u8( col[0], col[1], col[2], 0xff );
		
	for( i=0; i<=segs; i++ )
	{
		px = cos( a ) * r + x;
		py = sin( a ) * r + y;
		GX_Position3f32( px, py, z );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
		a -= aa;
	}
	GX_End();
	
	if( edge )
	{
		a = 0.0f;
		GX_Begin( GX_LINESTRIP, GX_VTXFMT0, segs+1 );
		for( i=0; i<=segs; i++ )
		{
			px = cos( a ) * r + x;
			py = sin( a ) * r + y;
			GX_Position3f32( px, py, z );
			GX_Color4u8( 0, 0, 0, 0xff );
			a -= aa;
		}
		GX_End();
	}
}
Пример #5
0
// these goofy white rectangles can have textures printed on them...
// that's how I'm going to handle the title screen
void drawAGoofyWhiteRectangle(){
	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
		GX_Position3f32( -1.0f, 0.0f, 0.0f);		// Top Left
		GX_Position3f32( 1.0f, 0.0f, 0.0f);		// Top Right
		GX_Position3f32( 1.0f,-1.0f, 0.0f);	// Bottom Right
		GX_Position3f32(-1.0f,-1.0f, 0.0f);	// Bottom Left
	GX_End();
}
Пример #6
0
void draw_cloud( struct cloud *cd, f32 orx, f32 ory, f32 scale, u8 *col )
{
	f32 ca, sa, a2;
	f32 sx, sy;
	s32 i;

	a2 = cd->ang - (3.14159265f/2.0f);

	ca = cos( cd->ang );
	sa = sin( cd->ang );

	sx = (cos(a2)*cd->r)+orx;
	sy = (sin(a2)*cd->r)+ory;
	
	cd->px1 = (clox1*scale*ca - cloy1*scale*sa) + sx;
	cd->py1 = (clox1*scale*sa + cloy1*scale*ca) + sy;
	cd->pr1 = clr1*scale;
	cd->px2 = (clox2*scale*ca - cloy2*scale*sa) + sx;
	cd->py2 = (clox2*scale*sa + cloy2*scale*ca) + sy;
	cd->pr2 = clr2*scale;
	cd->px3 = (clox3*scale*ca - cloy3*scale*sa) + sx;
	cd->py3 = (clox3*scale*sa + cloy3*scale*ca) + sy;
	cd->pr3 = clr3*scale;

	circle( cd->px2, cd->py2, cd->pr2, col, 1, 100, 0.5f );
	circle( cd->px1, cd->py1, cd->pr1, col, 1, 100, 0.5f );
	circle( cd->px3, cd->py3, cd->pr3, col, 1, 100, 0.5f );

	cloudbot[0].sx = (cloudbot[0].x*scale*ca - cloudbot[0].y*scale*sa)+sx;
	cloudbot[0].sy = (cloudbot[0].x*scale*sa + cloudbot[0].y*scale*ca)+sy;
	cloudbot[1].sx = (cloudbot[1].x*scale*ca - cloudbot[1].y*scale*sa)+sx;
	cloudbot[1].sy = (cloudbot[1].x*scale*sa + cloudbot[1].y*scale*ca)+sy;
	cloudbot[2].sx = (cloudbot[2].x*scale*ca - cloudbot[2].y*scale*sa)+sx;
	cloudbot[2].sy = (cloudbot[2].x*scale*sa + cloudbot[2].y*scale*ca)+sy;
	cloudbot[3].sx = (cloudbot[3].x*scale*ca - cloudbot[3].y*scale*sa)+sx;
	cloudbot[3].sy = (cloudbot[3].x*scale*sa + cloudbot[3].y*scale*ca)+sy;

	GX_Begin( GX_QUADS, GX_VTXFMT0, 4 );
	for( i=0; i<4; i++ )
	{
		GX_Position3f32( cloudbot[i].sx, cloudbot[i].sy, 0.5f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
	}
	GX_End();

	// Huh!?
	if( ( cloudbot[3].sx >= 640.0f ) && ( cloudbot[2].sx >= 640.0f ) ) return;
	if( ( cloudbot[3].sx < 0.0f ) && ( cloudbot[2].sx < 0.0f ) ) return;

	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, 2 );
		GX_Position3f32( cloudbot[3].sx, cloudbot[3].sy, 0.5f );
		GX_Color4u8( 0, 0, 0, 0xff );
		GX_Position3f32( cloudbot[2].sx, cloudbot[2].sy, 0.5f );
		GX_Color4u8( 0, 0, 0, 0xff );
	GX_End();
}
Пример #7
0
/****************************************************************************
 * Menu_DrawImg
 *
 * Draws the specified image on screen using GX
 ***************************************************************************/
void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY,
		u8 alpha, int XX1, int YY1, int XX2, int YY2, int XX3, int YY3, int XX4, int YY4)
{
	if (data == NULL) return;

	GX_LoadProjectionMtx(FSProjection2D, GX_ORTHOGRAPHIC);

	GXTexObj texObj;

	GX_InitTexObj(&texObj, data, width, height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
	GX_LoadTexObj(&texObj, GX_TEXMAP0);
	GX_ClearVtxDesc();
	GX_InvVtxCache();
	GX_InvalidateTexAll();

	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

	Mtx m, m1, m2, mv;
	width *= 0.5f;
	height *= 0.5f;
	guMtxIdentity(m1);
	guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0f);
	guVector axis = (guVector) {0 , 0, 1};
	guMtxRotAxisDeg (m2, &axis, degrees);
	guMtxConcat(m1, m2, m);

	guMtxTransApply(m, m, xpos + width + 0.5f, ypos + height + 0.5f, zpos);
	guMtxConcat(FSModelView2D, m, mv);
	GX_LoadPosMtxImm(mv, GX_PNMTX0);

	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
	GX_Position3f32(-width + XX1, -height + YY1, 0);
	GX_Color4u8(0xFF, 0xFF, 0xFF, alpha);
	GX_TexCoord2f32(0, 0);

	GX_Position3f32(width + XX2, -height + YY2, 0);
	GX_Color4u8(0xFF, 0xFF, 0xFF, alpha);
	GX_TexCoord2f32(1, 0);

	GX_Position3f32(width + XX3, height + YY3, 0);
	GX_Color4u8(0xFF, 0xFF, 0xFF, alpha);
	GX_TexCoord2f32(1, 1);

	GX_Position3f32(-width + XX4, height + YY4, 0);
	GX_Color4u8(0xFF, 0xFF, 0xFF, alpha);
	GX_TexCoord2f32(0, 1);

	GX_End();
}
Пример #8
0
/****************************************************************************
 * Menu_DrawImg
 *
 * Draws the specified image on screen using GX
 ***************************************************************************/
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[],
	f32 degrees, f32 scaleX, f32 scaleY, u8 alpha)
{
	if(data == NULL)
		return;

	GXTexObj texObj;

	GX_InitTexObj(&texObj, data, width, height, GX_TF_RGBA8, GX_CLAMP, GX_CLAMP, GX_FALSE);
	GX_LoadTexObj(&texObj, GX_TEXMAP0);
	GX_InvalidateTexAll();

	GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
	GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);

	Mtx m,m1,m2, mv;
	width  >>= 1;
	height >>= 1;

	guMtxIdentity (m1);
	guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
	guVector axis = (guVector) {0 , 0, 1 };
	guMtxRotAxisDeg (m2, &axis, degrees);
	guMtxConcat(m2,m1,m);

	guMtxTransApply(m,m, xpos+width,ypos+height,0);
	guMtxConcat (GXmodelView2D, m, mv);
	GX_LoadPosMtxImm (mv, GX_PNMTX0);

	GX_Begin(GX_QUADS, GX_VTXFMT0,4);
	GX_Position3f32(-width, -height,  0);
	GX_Color4u8(0xFF,0xFF,0xFF,alpha);
	GX_TexCoord2f32(0, 0);

	GX_Position3f32(width, -height,  0);
	GX_Color4u8(0xFF,0xFF,0xFF,alpha);
	GX_TexCoord2f32(1, 0);

	GX_Position3f32(width, height,  0);
	GX_Color4u8(0xFF,0xFF,0xFF,alpha);
	GX_TexCoord2f32(1, 1);

	GX_Position3f32(-width, height,  0);
	GX_Color4u8(0xFF,0xFF,0xFF,alpha);
	GX_TexCoord2f32(0, 1);
	GX_End();
	GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);

	GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
	GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
}
Пример #9
0
static void
render_texture (greets_data *gdata, float zpos, float scroll)
{
  world_info *world = gdata->world;
  Mtx mvtmp;
  extern Mtx tube_rotmtx;

  guMtxIdentity (mvtmp);
  guMtxConcat (mvtmp, tube_rotmtx, mvtmp);

  object_set_matrices (&world->scene, &gdata->greets_loc, world->scene.camera,
		       mvtmp, NULL, world->projection, world->projection_type);

  GX_ClearVtxDesc ();
  GX_SetVtxDesc (GX_VA_POS, GX_DIRECT);
  GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);

  GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
  GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);

  GX_SetCullMode (GX_CULL_NONE);

  scroll = scroll * 8.0f;
  scroll = scroll - floorf (scroll);
  scroll = scroll * 1./8;

  GX_Begin (GX_TRIANGLESTRIP, GX_VTXFMT0, 4);

  GX_Position3f32 (-40, 8, 0);
  GX_TexCoord2f32 (scroll, 0);

  GX_Position3f32 (40, 8, 0);
  GX_TexCoord2f32 (4 + scroll, 0);

  GX_Position3f32 (-40, -8, 0);
  GX_TexCoord2f32 (scroll, 0.5);

  GX_Position3f32 (40, -8, 0);
  GX_TexCoord2f32 (4 + scroll, 0.5);

  GX_End ();

  GX_Begin (GX_TRIANGLESTRIP, GX_VTXFMT0, 4);

  GX_Position3f32 (-40, 0, 8);
  GX_TexCoord2f32 (scroll, 0);

  GX_Position3f32 (40, 0, 8);
  GX_TexCoord2f32 (4 + scroll, 0);

  GX_Position3f32 (-40, 0, -8);
  GX_TexCoord2f32 (scroll, 0.5);

  GX_Position3f32 (40, 0, -8);
  GX_TexCoord2f32 (4 + scroll, 0.5);

  GX_End ();
}
Пример #10
0
/*
=============
EmitSkyPolys
=============
*/
void EmitSkyPolys (msurface_t *fa)
{
	glpoly_t	*p;
	float		*v;
	int			i;
	float	s, t;
	vec3_t	dir;
	float	length;

	for (p=fa->polys ; p ; p=p->next)
	{
		GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, p->numverts);
		for (i=0,v=p->verts[0] ; i<p->numverts ; i++, v+=VERTEXSIZE)
		{
			VectorSubtract (v, r_origin, dir);
			dir[2] *= 3;	// flatten the sphere

			length = dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2];
			length = sqrt (length);
			length = 6*63/length;

			dir[0] *= length;
			dir[1] *= length;

			s = (speedscale + dir[0]) * (1.0/128);
			t = (speedscale + dir[1]) * (1.0/128);

			GX_Position3f32(v[0], v[1], v[2]);
			GX_Color4u8(0xff, 0xff, 0xff, 0xff);
			GX_TexCoord2f32(s, t);
		}
		GX_End ();
	}
}
Пример #11
0
/*
=============
EmitWaterPolys

Does a water warp on the pre-fragmented glpoly_t chain
=============
*/
void EmitWaterPolys (msurface_t *fa)
{
	glpoly_t	*p;
	float		*v;
	int			i;
	float		s, t, os, ot;

	for (p=fa->polys ; p ; p=p->next)
	{
		GX_Begin (GX_TRIANGLEFAN, GX_VTXFMT0, p->numverts);
		for (i=0,v=p->verts[0] ; i<p->numverts ; i++, v+=VERTEXSIZE)
		{
			os = v[3];
			ot = v[4];

			s = os + turbsin[(int)((ot*0.125+realtime) * TURBSCALE) & 255];
			s *= (1.0/64);

			t = ot + turbsin[(int)((os*0.125+realtime) * TURBSCALE) & 255];
			t *= (1.0/64);

			GX_Position3f32(v[0], v[1], v[2]);
			GX_Color4u8(0xff, 0xff, 0xff, r_wateralpha.value * 0xff); // ELUTODO issues with draw order AND shoudn't be enabled if the map doesn't have watervis info
			GX_TexCoord2f32(s, t);
		}
		GX_End ();
	}
}
Пример #12
0
/****************************************************************************
 * Menu_DrawRectangle
 *
 * Draws a rectangle at the specified coordinates using GX
 ***************************************************************************/
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled)
{
	u8 fmt;
	long n;
	int i;
	f32 x2 = x+width;
	f32 y2 = y+height;
	Vector v[] = {{x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f}, {x,y,0.0f}};

	if(!filled)
	{
		fmt = GX_LINESTRIP;
		n = 5;
	}
	else
	{
		fmt = GX_TRIANGLEFAN;
		n = 4;
	}

	GX_Begin(fmt, GX_VTXFMT0, n);
	for(i=0; i<n; i++)
	{
		GX_Position3f32(v[i].x, v[i].y,  v[i].z);
		GX_Color4u8(color.r, color.g, color.b, color.a);
	}
	GX_End();
}
Пример #13
0
MF_API void MFSetPosition(float x, float y, float z)
{
	MFCALLSTACK;

	GX_Position3f32(x, y, z);
	++currentVert;
}
Пример #14
0
void drawRect(int x, int y, int width, int height, int depth, GXColor color, float s0, float s1, float t0, float t1)
{
	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
		GX_Position3f32((float) x,(float) y,(float) depth );
		GX_Color4u8(color.r, color.g, color.b, color.a);
		GX_TexCoord2f32(s0,t0);
		GX_Position3f32((float) (x+width),(float) y,(float) depth );
		GX_Color4u8(color.r, color.g, color.b, color.a);
		GX_TexCoord2f32(s1,t0);
		GX_Position3f32((float) (x+width),(float) (y+height),(float) depth );
		GX_Color4u8(color.r, color.g, color.b, color.a);
		GX_TexCoord2f32(s1,t1);
		GX_Position3f32((float) x,(float) (y+height),(float) depth );
		GX_Color4u8(color.r, color.g, color.b, color.a);
		GX_TexCoord2f32(s0,t1);
	GX_End();
}
Пример #15
0
// Render a vertex to Gecko (used by glEnd)
void UploadVertex(int index){    
		GX_Position3f32( _vertexelements[index].x, _vertexelements[index].y, _vertexelements[index].z);	
        GX_Normal3f32(_normalelements[index].x, _normalelements[index].y, _normalelements[index].z);

		//when using GL_FLAT only one color is allowed!!! //GL_SMOOTH allows for an color to be specified at each vertex
		GX_Color3f32( _colorelements[index].r, _colorelements[index].g, _colorelements[index].b); //glmaterialfv call instead when glcolormaterial call is used
		GX_TexCoord2f32(_texcoordelements[index].s,_texcoordelements[index].t);
};
Пример #16
0
void draw_pointer( f32 x, f32 y, f32 ang, u8 r, u8 g, u8 b )
{
	Mtx m,mv;

	guMtxRotAxisDeg( m, &rotax, ang );
	guMtxTransApply( m, m, x, y, 0 );
	guMtxConcat( GXmodelView2D, m, mv );
	GX_LoadPosMtxImm( mv, GX_PNMTX0 );

	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, 3 );
		GX_Position3f32(  0.0f,  0.0f, 19.0f );
		GX_Color4u8( r, g, b, 0xa0 );
		GX_Position3f32( 32.0f, 16.0f, 19.0f );
		GX_Color4u8( r, g, b, 0xa0 );
		GX_Position3f32( 16.0f, 32.0f, 19.0f );
		GX_Color4u8( r, g, b, 0xa0 );
	GX_End();

	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, 4 );
		GX_Position3f32(  0.0f,  0.0f, 19.0f );
		GX_Color4u8( 0, 0, 0, 0xff );
		GX_Position3f32( 32.0f, 16.0f, 19.0f );
		GX_Color4u8( 0, 0, 0, 0xff );
		GX_Position3f32( 16.0f, 32.0f, 19.0f );
		GX_Color4u8( 0, 0, 0, 0xff );
		GX_Position3f32(  0.0f,  0.0f, 19.0f );
		GX_Color4u8( 0, 0, 0, 0xff );
	GX_End();

	GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
}
Пример #17
0
void Enemy::Draw(Mtx44 view) {
	Mtx44 model, modelview;
	guMtxIdentity(model);
	guMtxIdentity(modelview);
	guMtxTransApply(model, model, this->x, this->y, this->z);
	guMtxConcat(view, model, modelview);
	GX_LoadPosMtxImm(modelview, GX_PNMTX0);
	GX_LoadTexObj(this->tex, GX_TEXMAP0);
	
	f32 width, height;
	width = this->w / 2.0f;
	height = this->h / 2.0f;
	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
		GX_Position3f32(-width, height, 0);
		GX_Color4u8(255, 255, 255, 255);
		if( this->velx > 0 )
			GX_TexCoord2f32(1, 0);
		else
			GX_TexCoord2f32(0, 0);
		GX_Position3f32(width, height, 0);
		GX_Color4u8(255, 255, 255, 255);
		if( this->velx > 0 ) 
			GX_TexCoord2f32(0, 0);
		else
			GX_TexCoord2f32(1, 0);
		GX_Position3f32(width, -height, 0);
		GX_Color4u8(255, 255, 255, 255);
		if( this->velx > 0 )
			GX_TexCoord2f32(0, 1);
		else 
			GX_TexCoord2f32(1, 1);
		GX_Position3f32(-width, -height, 0);
		GX_Color4u8(255, 255, 255, 255);
		if( this->velx > 0 )
			GX_TexCoord2f32(1, 1);
		else 
			GX_TexCoord2f32(0, 1);
	GX_End();
}
Пример #18
0
void draw_star( f32 scale, f32 angle, f32 x, f32 y, u8 *col, u8 alpha )
{
	int i, j;
	Mtx m,m1,m2,mv;

	guMtxIdentity(m1);
	guMtxScaleApply( m1, m1, scale, scale, 1.0f );
	guMtxRotAxisRad( m2, &rotax, angle );
	guMtxConcat( m2, m1, m);

	guMtxTransApply( m, m, x, y, 0 );
	guMtxConcat( GXmodelView2D, m, mv );
	GX_LoadPosMtxImm( mv, GX_PNMTX0 );

	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, 3*NUM_STAR_POLYS );
	for( i=0; i<NUM_STAR_POLYS*3; i++ )
	{
		j = star_polys[i]*2;
		GX_Position3f32( star_pts[j], star_pts[j+1], 0.0f );
		GX_Color4u8( col[0], col[1], col[2], alpha );
	}
	GX_End();

	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, NUM_STAR_EDGES );
	for( i=0; i<NUM_STAR_EDGES; i++ )
	{
		j = star_edges[i]*2;
		GX_Position3f32( star_pts[j], star_pts[j+1], 0.0f );
		GX_Color4u8( 0, 0, 0, alpha );
	}
	GX_End();
	

	GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);

	GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
  	GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
}
Пример #19
0
void DrawTexObj(GXTexObj *texObj, int x, int y, int width, int height, int depth, float s1, float s2, float t1, float t2, int centered)
{
	drawInit();
	GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
	GX_InvalidateTexAll();
	GX_LoadTexObj(texObj, GX_TEXMAP0);
	if(centered)
		x = (int) x - width/2;
	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
		GX_Position3f32((float) x,(float) y,(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s1,t1);
		GX_Position3f32((float) (x+width),(float) y,(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s2,t1);
		GX_Position3f32((float) (x+width),(float) (y+height),(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s2,t2);
		GX_Position3f32((float) x,(float) (y+height),(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s1,t2);
	GX_End();
}
Пример #20
0
inline void QuadPane::SetVertex(int ind, float x, float y, u8 render_alpha) const
{
	// position
	GX_Position3f32(x, y, 0.f);

	const GXColor &vertex_color = header->vertex_colors[ind];
	// color
	GX_Color4u8(vertex_color.r, vertex_color.g, vertex_color.b,
				MultiplyAlpha(vertex_color.a, render_alpha));

	// texture coord
	for(u32 i = 0; i < header->tex_coord_count; i++)
		GX_TexCoord2f32(tex_coords[i].coords[ind].s, tex_coords[i].coords[ind].t);
}
Пример #21
0
void draw_sun( f32 x, f32 y, f32 r, f32 ang, u8 *col )
{
	int i;
	Mtx m, mv;

	circle( x, y, r, col, 1, 100, 0.0f );
	
	guMtxIdentity( m );
	guMtxRotAxisRad( m, &rotax, ang );
	guMtxTransApply( m, m, x, y, 0 );
	guMtxConcat( GXmodelView2D, m, mv );
	GX_LoadPosMtxImm( mv, GX_PNMTX0 );

	GX_Begin( GX_QUADS, GX_VTXFMT0, NUMRAYS*4 );
	for( i=0; i<NUMRAYS; i++ )
	{
		GX_Position3f32( sunrays[i*4  ].x     , sunrays[i*4  ].y     , 0.0f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
		GX_Position3f32( sunrays[i*4+1].x     , sunrays[i*4+1].y     , 0.0f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
		GX_Position3f32( sunrays[i*4+2].x*0.9f, sunrays[i*4+2].y*0.9f, 0.0f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
		GX_Position3f32( sunrays[i*4+3].x*0.9f, sunrays[i*4+3].y*0.9f, 0.0f );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
	}
	GX_End();

	for( i=0; i<NUMRAYS; i++ )
	{
		GX_Begin( GX_LINESTRIP, GX_VTXFMT0, 4 );
			GX_Position3f32( sunrays[i*4+3].x, sunrays[i*4+3].y, 0.0f );
			GX_Color4u8( 0, 0, 0, 0xff );
			GX_Position3f32( sunrays[i*4  ].x, sunrays[i*4  ].y, 0.0f );
			GX_Color4u8( 0, 0, 0, 0xff );
			GX_Position3f32( sunrays[i*4+1].x, sunrays[i*4+1].y, 0.0f );
			GX_Color4u8( 0, 0, 0, 0xff );
			GX_Position3f32( sunrays[i*4+2].x, sunrays[i*4+2].y, 0.0f );
			GX_Color4u8( 0, 0, 0, 0xff );
		GX_End();
	}
	

	GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);

	GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
  	GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
}
Пример #22
0
void draw_petal( f32 ca, f32 sa, f32 scx, f32 scy, f32 sx, f32 sy, f32 z, u8 *col, f32 *smx, f32 *smy, f32 *smr )
{
	int i;

	if( smx )
	{
		*smx =  18.8f * scy * sa + sx;
		*smy = -18.8f * scy * ca + sy;
		*smr =  16.0f * scy;
	}

	if( ( scx < 0.1f ) || ( scy < 0.1f ) )
		return;

	for( i=0; i<NUM_PETAL_VERTICES; i++ )
	{
		petal[i].sx = (petal[i].x*scx*ca - petal[i].y*scy*sa) + sx;
		petal[i].sy = (petal[i].x*scx*sa + petal[i].y*scy*ca) + sy;
	}
	
	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, NUM_PETAL_POLYS*3 );
	for( i=0; i<NUM_PETAL_POLYS*3; i++ )
	{
		GX_Position3f32( petal[petal_polys[i]].sx, petal[petal_polys[i]].sy, z );
		GX_Color4u8( col[0], col[1], col[2], 0xff );
	}
	GX_End();

	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, NUM_PETAL_EDGES );
	for( i=0; i<NUM_PETAL_EDGES; i++ )
	{
		GX_Position3f32( petal[petal_edges[i]].sx, petal[petal_edges[i]].sy, z );
		GX_Color4u8( 0, 0, 0, 0xff );
	}
	GX_End();
}
Пример #23
0
/****************************************************************************
 * Menu_DrawRectangle
 *
 * Draws a rectangle at the specified coordinates using GX
 ***************************************************************************/
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled)
{
	GX_LoadProjectionMtx(FSProjection2D, GX_ORTHOGRAPHIC);
	GX_LoadPosMtxImm(FSModelView2D, GX_PNMTX0);

	GX_SetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
	GX_ClearVtxDesc();
	GX_InvVtxCache();
	GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);

	u8 fmt;
	long n;
	int i;
	f32 x2 = x + width;
	f32 y2 = y + height;
	guVector v[] = { { x, y, 0.0f }, { x2, y, 0.0f }, { x2, y2, 0.0f }, { x, y2, 0.0f }, { x, y, 0.0f } };

	if (!filled)
	{
		fmt = GX_LINESTRIP;
		n = 5;
	}
	else
	{
		fmt = GX_TRIANGLEFAN;
		n = 4;
	}

	GX_Begin(fmt, GX_VTXFMT0, n);
	for (i = 0; i < n; i++)
	{
		GX_Position3f32(v[i].x, v[i].y, v[i].z);
		GX_Color4u8(color.r, color.g, color.b, color.a);
	}
	GX_End();
	GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
}
Пример #24
0
void DrawImage(int textureId, int x, int y, int width, int height, int depth, float s1, float s2, float t1, float t2, int centered)
{
	drawInit();
	GX_SetTevOp (GX_TEVSTAGE0, GX_REPLACE);
	GX_InvalidateTexAll();

	switch(textureId)
	{
	case TEX_BACKDROP:
		GX_LoadTexObj(&backdropTexObj, GX_TEXMAP0);
		break;
	case TEX_GCDVDSMALL:
		GX_LoadTexObj(&gcdvdsmallTexObj, GX_TEXMAP0);
		break;
	case TEX_SDSMALL:
		GX_LoadTexObj(&sdsmallTexObj, GX_TEXMAP0);
		break;
	case TEX_HDD:
		GX_LoadTexObj(&hddTexObj, GX_TEXMAP0);
		break;
	case TEX_QOOB:
		GX_LoadTexObj(&qoobTexObj, GX_TEXMAP0);
		break;
	case TEX_WODEIMG:
		GX_LoadTexObj(&wodeimgTexObj, GX_TEXMAP0);
		break;
	case TEX_USBGECKO:
		GX_LoadTexObj(&usbgeckoTexObj, GX_TEXMAP0);
		break;
	case TEX_WIIKEY:
		GX_LoadTexObj(&wiikeyTexObj, GX_TEXMAP0);
		break;
	case TEX_SYSTEM:
		GX_LoadTexObj(&systemTexObj, GX_TEXMAP0);
		break;
	case TEX_MEMCARD:
		GX_LoadTexObj(&memcardTexObj, GX_TEXMAP0);
		break;
	case TEX_SAMBA:
		GX_LoadTexObj(&sambaTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNNOHILIGHT:
		GX_LoadTexObj(&btnnohilightTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNHILIGHT:
		GX_LoadTexObj(&btnhilightTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNDEVICE:
		GX_LoadTexObj(&btndeviceTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNSETTINGS:
		GX_LoadTexObj(&btnsettingsTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNINFO:
		GX_LoadTexObj(&btninfoTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNREFRESH:
		GX_LoadTexObj(&btnrefreshTexObj, GX_TEXMAP0);
		break;
	case TEX_BTNEXIT:
		GX_LoadTexObj(&btnexitTexObj, GX_TEXMAP0);
		break;
	case TEX_NTSCJ:
		GX_LoadTexObj(&ntscjTexObj, GX_TEXMAP0);
		break;
	case TEX_NTSCU:
		GX_LoadTexObj(&ntscuTexObj, GX_TEXMAP0);
		break;
	case TEX_PAL:
		GX_LoadTexObj(&palTexObj, GX_TEXMAP0);
		break;
	case TEX_CHECKED:
		GX_LoadTexObj(&checkedTexObj, GX_TEXMAP0);
		break;
	case TEX_UNCHECKED:
		GX_LoadTexObj(&uncheckedTexObj, GX_TEXMAP0);
		break;
	}	

	if(centered)
	{
		x = (int) x - width/2;
	}
	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
		GX_Position3f32((float) x,(float) y,(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s1,t1);
		GX_Position3f32((float) (x+width),(float) y,(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s2,t1);
		GX_Position3f32((float) (x+width),(float) (y+height),(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s2,t2);
		GX_Position3f32((float) x,(float) (y+height),(float) depth );
		GX_Color4u8(255, 255, 255, 255);
		GX_TexCoord2f32(s1,t2);
	GX_End();
}
Пример #25
0
int main() {
    int startx=0, starty=0;
    int x=0, y=0;
    int dirx=0, diry=0;
    int cptx=0, cpty=0;
    int bgx=-32, bgy=-32;
    float idperso=0;
    int i=0;
    float sinnonameno=0, oldsinnonameno=0;
    float camZ=1400.0f;
    float a=0;

    GRRLIB_Init();
    GRRLIB_Settings.antialias = false;
    WPAD_Init();
    GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
    GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1);
    GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
    GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso);
    GRRLIB_InitTileSet(tex_perso, 64, 64, 0);
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
    GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno);
    GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0);

    GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)  break;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS)  camZ+=20.0f;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS)  camZ-=20.0f;

        if((dirx==0) && (diry==0)) {
            if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;}
        }

        if((dirx==0) && (diry==0)) {
            idperso=0;
        }

        if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
        }
        else{
            dirx=0;
            diry=-4;
        }

        if(dirx<0) {
            if((Map1Info[7+starty][12+startx]==8) || (Map1Info[7+starty][12+startx]==2) || (Map1Info[8+starty][12+startx]==8) || (Map1Info[8+starty][12+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>7)
                    idperso=1;
            }
        }

        if(dirx>0) {
            if((Map1Info[7+starty][9+startx]==8) || (Map1Info[7+starty][9+startx]==2) || (Map1Info[8+starty][9+startx]==8) || (Map1Info[8+starty][9+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>14)
                    idperso=8;
           }
        }

        if(diry<0) {
            if((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) {
                diry=0;
            }
        }

        if(diry!=0) {
            idperso++;
            if(idperso>22)
                idperso=16;
        }

        cptx+=dirx;
        if(dirx>0)
            bgx++;
        else if(dirx<0)
            bgx--;
        if((bgx>-1) || (bgx<-63))
            bgx=-32;

        if(cptx==32) {
            cptx=0;
            dirx=0;
            startx--;
        }
        else if(cptx==-32) {
            cptx=0;
            dirx=0;
            startx++;
        }

        cpty+=diry;
        if(diry>0)
            bgy++;
        else if(diry<0)
            bgy--;
        if((bgy>-1) ||(bgy<-63))
            bgy=-32;

        if(cpty==32) {
            cpty=0;
            diry=0;
            starty--;
        }
        else if(cpty==-32) {
            cpty=0;
            if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
                diry=0;
            }
            starty++;
        }
        GRRLIB_DrawImg(bgx, bgy, tex_bg, 0, 1, 1, 0xFFFFFFFF);

        for(y=0;y<=(17);y++) {
            for(x=0;x<=(21);x++) {
            if(Map1Data[y+starty][x+startx] != 0) {
                GRRLIB_DrawTile(x*TileMap1Width+cptx-TileMap1Width,y*TileMap1Height+cpty-TileMap1Height,tex_tile1,0,1,1,0xFFFFFFFF,Map1Data[y+starty][x+startx]-1);
            }
            }
        }
        GRRLIB_DrawTile(TileMap1Width*9,TileMap1Height*6,tex_perso,0,1,1,0xFFFFFFFF,(int)idperso);

        oldsinnonameno=sinnonameno;
        for(i=0; i<8; i++) {
            GRRLIB_DrawTile(TileMap1Width*(6+i),(TileMap1Height*10)+sin(sinnonameno)*64,tex_nonameno,0,1,1,0xFFFFFFFF,i);
            sinnonameno+=0.4F;
        }
        sinnonameno=oldsinnonameno+0.08F;

        GRRLIB_Screen2Texture(0, 0, tex_screen, GX_TRUE);


        GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
        GRRLIB_3dMode(0.1,3000,45,1,0);
        GRRLIB_SetTexture(tex_screen,0);
        GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 16);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();

        a+=0.2f;

        GRRLIB_Render();
    }

    GRRLIB_FreeTexture(tex_tile1);
    GRRLIB_FreeTexture(tex_perso);
    GRRLIB_FreeTexture(tex_bg);
    GRRLIB_FreeTexture(tex_nonameno);
    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_Exit();
    exit(0);
}
Пример #26
0
void
reduce_cubemap (cubemap_info *cubemap, int subdiv)
{
  int x, y, face;
  const u32 vtxfmt = GX_VTXFMT0;
  Mtx mvtmp;
  Mtx44 ortho;
  object_loc rect_loc;
  scene_info rect_scene;
  int half_subdiv = subdiv / 2;
  float scale_factor = 1.0 / ((float) half_subdiv - 0.5);
  
  /* Using an even number of subdivisions and spreading evenly from -1...1
     ensures we don't try to evaluate the singularity point at the back of the
     sphere.  */
  assert ((subdiv & 1) == 0);
  
  scene_set_pos (&rect_scene, (guVector) { 0, 0, -5 });
  scene_set_lookat (&rect_scene, (guVector) { 0, 0, 0 });
  scene_set_up (&rect_scene, (guVector) { 0, 1, 0 });
  
  scene_update_camera (&rect_scene);
  
  guOrtho (ortho, -1, 1, -1, 1, 1, 15);
  
  object_loc_initialise (&rect_loc, GX_PNMTX0);
  
  guMtxIdentity (mvtmp);
  
  object_set_matrices (&rect_scene, &rect_loc, rect_scene.camera, mvtmp, NULL,
		       ortho, GX_ORTHOGRAPHIC);
  
  GX_ClearVtxDesc ();
  GX_SetVtxDesc (GX_VA_POS, GX_DIRECT);
  GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
  
  GX_SetVtxAttrFmt (vtxfmt, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
  GX_SetVtxAttrFmt (vtxfmt, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
  
  GX_SetCullMode (GX_CULL_BACK);
  
  rendertarget_texture (cubemap->sphsize, cubemap->sphsize, cubemap->sphfmt,
			GX_FALSE, GX_PF_RGB8_Z24, GX_ZC_LINEAR);
  
  for (face = 0; face < 6; face++)
    {
      shader_load (cubemap->face_shader[face]);

      for (x = -half_subdiv; x < half_subdiv - 1; x++)
	{
          float a = ((float) x + 0.5) * scale_factor;
          float a1 = ((float) x + 1.5) * scale_factor;

	  GX_Begin (GX_TRIANGLESTRIP, vtxfmt, subdiv * 2);

	  for (y = -half_subdiv; y < half_subdiv; y++)
	    {
	      float b = ((float) y + 0.5) * scale_factor;
	      guVector tmp;

	      face_to_sphere (&tmp, face, a, b);
	      GX_Position3f32 (tmp.x, tmp.y, tmp.z);
	      GX_TexCoord2f32 ((a + 1.0) / 2.0, (b + 1.0) / 2.0);

	      face_to_sphere (&tmp, face, a1, b);
	      GX_Position3f32 (tmp.x, tmp.y, tmp.z);
	      GX_TexCoord2f32 ((a1 + 1.0) / 2.0, (b + 1.0) / 2.0);
	    }

	  GX_End ();
	}
    }
  
  GX_CopyTex (cubemap->sphtexels, GX_TRUE);
  GX_PixModeSync ();
}
Пример #27
0
void Textbox::Draw(const BannerResources& resources, u8 parent_alpha, const float ws_scale, Mtx &modelview) const
{
	if(!text)
		return;

	if(header->font_index >= resources.fonts.size())
		return;

	WiiFont *font = resources.fonts[header->font_index];
	if(!font->IsLoaded())
		return;

	// Ugly...but doing it by going through all panes is more ugly
	// TODO: move it to somewhere else
	if(lineWidths.empty())
		((Textbox *) this)->SetTextWidth(font);

	if(lineWidths.empty())
		return;

	SetupGX(resources);

	GX_LoadPosMtxImm(modelview, GX_PNMTX0);

	// Setup text color
	GXColor color0 = { header->color[0].r,
					   header->color[0].g,
					   header->color[0].b,
					   MultiplyAlpha(header->color[0].a, parent_alpha) };

	GXColor color1 = { header->color[1].r,
					   header->color[1].g,
					   header->color[1].b,
					   MultiplyAlpha(header->color[1].a, parent_alpha) };

	u32 lastSheetIdx = 0xffff;
	float scale = header->font_size /(float)font->CharacterHeight();

	// use complete text width if not aligned to middle
	float textWidth = (GetAlignHor() == 1) ? lineWidths[0] : frameWidth;

	// position offset calculation for first line...why the hell is it that complex?
	float xPos = -0.5f * ( GetOriginX() * GetWidth() * ws_scale +
							GetAlignHor() * (-GetWidth()  * ws_scale + textWidth) );
	float yPos = -0.5f * ( GetAlignVer() * -frameHeight +
							GetHeight() * (GetAlignVer() - (2 - GetOriginY())) )
						 - header->font_size;

	// store the character width here for later use, it's constant over the text
	float charWidth = scale * (float)font->CharacterWidth();
	int lineNumber = 0;

	for(const u16 *txtString = text; *txtString != 0; txtString++)
	{
		if(*txtString == '\n')
		{
			lineNumber++;
			// use complete text width if not aligned to middle
			textWidth = (GetAlignHor() == 1) ? lineWidths[lineNumber] : frameWidth;
			// calculate text position depending on line width
			xPos = -0.5f * (GetOriginX() * GetWidth() * ws_scale +
							GetAlignHor() * (-GetWidth() * ws_scale + textWidth));
			// go one line down
			yPos -= (header->font_size + header->space_line);
			continue;
		}

		const WiiFont::CharInfo *charInfo = font->GetCharInfo(*txtString);
		if(!charInfo)
			continue;

		if(charInfo->sheetIdx != lastSheetIdx)
		{
			lastSheetIdx = charInfo->sheetIdx;

			if(!font->Apply(charInfo->sheetIdx))
				continue;
		}

		if(charInfo->unk)
			xPos += scale * (float)charInfo->advanceKerning;

		GX_Begin(GX_QUADS, GX_VTXFMT0, 4);

		GX_Position3f32(xPos, yPos, 0.f);
		GX_Color4u8(color1.r, color1.g, color1.b, color1.a);
		GX_TexCoord2f32(charInfo->s1, charInfo->t2);

		GX_Position3f32(xPos + charWidth, yPos, 0.f);
		GX_Color4u8(color1.r, color1.g, color1.b, color1.a);
		GX_TexCoord2f32(charInfo->s2, charInfo->t2);

		GX_Position3f32(xPos + charWidth, yPos + header->font_size, 0.f);
		GX_Color4u8(color0.r, color0.g, color0.b, color0.a);
		GX_TexCoord2f32(charInfo->s2, charInfo->t1);

		GX_Position3f32(xPos, yPos + header->font_size, 0.f);
		GX_Color4u8(color0.r, color0.g, color0.b, color0.a);
		GX_TexCoord2f32(charInfo->s1, charInfo->t1);

		GX_End();

		xPos += scale * (float)charInfo->advanceGlyphX;
	}
}
Пример #28
0
void SendVertex(guVector& p, u32 color) {
	GX_Position3f32(p.x, p.y, p.z);
	GX_Color1u32(color);
}
Пример #29
0
int main(int argc,char **argv) {

    f32 yscale,zt = 0;
    u32 xfbHeight;
    u32 fb = 0;
    f32 rquad = 0.0f;
    u32 first_frame = 1;
    GXTexObj texture;
    Mtx view; // view and perspective matrices
    Mtx model, modelview;
    Mtx44 perspective;
    void *gpfifo = NULL;
    GXColor background = {0, 0, 0, 0xff};
    guVector cam = {0.0F, 0.0F, 0.0F},
             up = {0.0F, 1.0F, 0.0F},
             look = {0.0F, 0.0F, -1.0F};
    TPLFile crateTPL;

    VIDEO_Init();
    WPAD_Init();

    rmode = VIDEO_GetPreferredMode(NULL);

    // allocate the fifo buffer
    gpfifo = memalign(32,DEFAULT_FIFO_SIZE);
    memset(gpfifo,0,DEFAULT_FIFO_SIZE);

    // allocate 2 framebuffers for double buffering
    frameBuffer[0] = SYS_AllocateFramebuffer(rmode);
    frameBuffer[1] = SYS_AllocateFramebuffer(rmode);

    // configure video
    VIDEO_Configure(rmode);
    VIDEO_SetNextFramebuffer(frameBuffer[fb]);
    VIDEO_Flush();
    VIDEO_WaitVSync();
    if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

    fb ^= 1;

    // init the flipper
    GX_Init(gpfifo,DEFAULT_FIFO_SIZE);

    // clears the bg to color and clears the z buffer
    GX_SetCopyClear(background, 0x00ffffff);

    // other gx setup
    GX_SetViewport(0,0,rmode->fbWidth,rmode->efbHeight,0,1);
    yscale = GX_GetYScaleFactor(rmode->efbHeight,rmode->xfbHeight);
    xfbHeight = GX_SetDispCopyYScale(yscale);
    GX_SetScissor(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopySrc(0,0,rmode->fbWidth,rmode->efbHeight);
    GX_SetDispCopyDst(rmode->fbWidth,xfbHeight);
    GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter);
    GX_SetFieldMode(rmode->field_rendering,((rmode->viHeight==2*rmode->xfbHeight)?GX_ENABLE:GX_DISABLE));

    if (rmode->aa)
        GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
    else
        GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);

    GX_SetCullMode(GX_CULL_NONE);
    GX_CopyDisp(frameBuffer[fb],GX_TRUE);
    GX_SetDispCopyGamma(GX_GM_1_0);

    // setup the vertex attribute table
    // describes the data
    // args: vat location 0-7, type of data, data format, size, scale
    // so for ex. in the first call we are sending position data with
    // 3 values X,Y,Z of size F32. scale sets the number of fractional
    // bits for non float data.
    GX_ClearVtxDesc();
    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGB8, 0);

    GX_InvVtxCache();
    GX_InvalidateTexAll();
    TPL_OpenTPLFromMemory(&crateTPL, (void *)crate_tpl,crate_tpl_size);
    TPL_GetTexture(&crateTPL,crate,&texture);

    // setup our camera at the origin
    // looking down the -z axis with y up
    guLookAt(view, &cam, &up, &look);

    // setup our projection matrix
    // this creates a perspective matrix with a view angle of 90,
    // and aspect ratio based on the display resolution
    f32 w = rmode->viWidth;
    f32 h = rmode->viHeight;
    guPerspective(perspective, 45, (f32)w/h, 0.1F, 300.0F);
    GX_LoadProjectionMtx(perspective, GX_PERSPECTIVE);

    guVector cubeAxis = {1,1,1};

    while(1) {

        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
        else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_UP) zt -= 0.25f;
        else if (WPAD_ButtonsHeld(0)&WPAD_BUTTON_DOWN) zt += 0.25f;

        // set number of rasterized color channels
        GX_SetNumChans(1);

        //set number of textures to generate
        GX_SetNumTexGens(1);

        // setup texture coordinate generation
        // args: texcoord slot 0-7, matrix type, source to generate texture coordinates from, matrix to use
        GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);

        GX_SetTevOp(GX_TEVSTAGE0,GX_REPLACE);
        GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

        GX_LoadTexObj(&texture, GX_TEXMAP0);

        guMtxIdentity(model);
        guMtxRotAxisDeg(model, &cubeAxis, rquad);
        guMtxTransApply(model, model, 0.0f,0.0f,zt-7.0f);
        guMtxConcat(view,model,modelview);
        // load the modelview matrix into matrix memory
        GX_LoadPosMtxImm(modelview, GX_PNMTX3);
        GX_SetCurrentMtx(GX_PNMTX3);

        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);			// Draw a Cube

        GX_Position3f32(-1.0f, 1.0f, -1.0f);	// Top Left of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-1.0f, 1.0f, 1.0f);	// Top Right of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(-1.0f, -1.0f, 1.0f);	// Bottom Right of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(- 1.0f, -1.0f, -1.0f);		// Bottom Left of the quad (top)
        GX_Color3f32(0.0f,1.0f,0.0f);			// Set The Color To Green
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( 1.0f,1.0f, -1.0f);	// Top Left of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f, -1.0f);	// Top Right of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f,1.0f);	// Bottom Right of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f,1.0f,1.0f);	// Bottom Left of the quad (bottom)
        GX_Color3f32(1.0f,0.5f,0.0f);			// Set The Color To Orange
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( -1.0f, -1.0f, 1.0f);		// Top Right Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f, -1.0f, 1.0f);	// Top Left Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f,-1.0f, -1.0f);	// Bottom Left Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( -1.0f,-1.0f, -1.0f);	// Bottom Right Of The Quad (Front)
        GX_Color3f32(1.0f,0.0f,0.0f);			// Set The Color To Red
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( -1.0f,1.0f,1.0f);	// Bottom Left Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-1.0f,1.0f,-1.0f);	// Bottom Right Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(1.0f, 1.0f,-1.0f);	// Top Right Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f, 1.0f,1.0f);	// Top Left Of The Quad (Back)
        GX_Color3f32(1.0f,1.0f,0.0f);			// Set The Color To Yellow
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32(1.0f, -1.0f, -1.0f);	// Top Right Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(1.0f, 1.0f,-1.0f);	// Top Left Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(-1.0f,1.0f,-1.0f);	// Bottom Left Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-1.0f,-1.0f, -1.0f);	// Bottom Right Of The Quad (Left)
        GX_Color3f32(0.0f,0.0f,1.0f);			// Set The Color To Blue
        GX_TexCoord2f32(0.0f,1.0f);

        GX_Position3f32( 1.0f, -1.0f,1.0f);	// Top Right Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32( -1.0f, -1.0f, 1.0f);		// Top Left Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32( -1.0f,1.0f, 1.0f);	// Bottom Left Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32( 1.0f,1.0f,1.0f);	// Bottom Right Of The Quad (Right)
        GX_Color3f32(1.0f,0.0f,1.0f);			// Set The Color To Violet
        GX_TexCoord2f32(0.0f,1.0f);

        GX_End();									// Done Drawing The Quad

        GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
        GX_SetColorUpdate(GX_TRUE);
        GX_CopyDisp(frameBuffer[fb],GX_TRUE);

        GX_DrawDone();

        VIDEO_SetNextFramebuffer(frameBuffer[fb]);
        if(first_frame) {
            first_frame = 0;
            VIDEO_SetBlack(FALSE);
        }
        VIDEO_Flush();
        VIDEO_WaitVSync();
        fb ^= 1;

        rquad -= 0.15f;				// Decrease The Rotation Variable For The Quad     ( NEW )
    }
}
Пример #30
0
void GuiFrameImage::CreateDrawList()
{
	GX_BeginDispList(DrawList, DrawListSize+64);

	GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
	GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);

	oldWidth = GetWidth();
	oldHeight = GetHeight();
	oldX = GetLeft();
	oldY = GetTop();
	oldZ = 0;
	oldAlpha = GetAlpha();

	f32 alpha = oldAlpha;
	f32 z = oldZ;

	f32 x1 = oldX;
	f32 y1 = oldY;
	f32 x2 = x1+oldWidth;
	f32 y2 = y1+oldHeight;

	//! Upper QUAD
	GX_Begin(GX_QUADS, GX_VTXFMT0,4);
		GX_Position3f32(x1+Margin, y1, z);
		GX_Color4u8(UpperQuadUpper.r,UpperQuadUpper.g,UpperQuadUpper.b,alpha);

		GX_Position3f32(x2-Margin, y1, z);
		GX_Color4u8(UpperQuadUpper.r,UpperQuadUpper.g,UpperQuadUpper.b,alpha);

		GX_Position3f32(x2-Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		GX_Position3f32(x1+Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);
	GX_End();

	//! Upper/Left Corner Circle
	GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, Precision+1);
	{
		f32 deg;
		int r = SideQuadUpper.r;
		int g = SideQuadUpper.g;
		int b = SideQuadUpper.b;
		f32 r_p = (float) (UpperQuadUpper.r - r)/(float) (Precision-1);
		f32 g_p = (float) (UpperQuadUpper.g - g)/(float) (Precision-1);
		f32 b_p = (float) (UpperQuadUpper.b - b)/(float) (Precision-1);
		GX_Position3f32(x1+Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(180+i*90/(f32)(Precision-1));
			GX_Position3f32(x1+Margin+Margin*cos(deg), y1+Margin+Margin*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i,alpha);
		}
	}
	GX_End();

	//! Left QUAD
	GX_Begin(GX_QUADS, GX_VTXFMT0,4);
		GX_Position3f32(x1, y1+Margin, z);
		GX_Color4u8(SideQuadUpper.r,SideQuadUpper.g,SideQuadUpper.b,alpha);

		GX_Position3f32(x1+Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		GX_Position3f32(x1, y2-Margin, z);
		GX_Color4u8(SideQuadLower.r,SideQuadLower.g,SideQuadLower.b,alpha);
	GX_End();

	//! Lower Left Corner Circle
	GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, Precision*2+2);
	{
		//! Transparent shadow
		f32 deg;
		int r = ShadowLower.r;
		int g = ShadowLower.g;
		int b = ShadowLower.b;
		f32 a = 0.1f*alpha;
		f32 r_p = (float) (SideQuadLower.r - r)/(float) (Precision-1);
		f32 g_p = (float) (SideQuadLower.g - g)/(float) (Precision-1);
		f32 b_p = (float) (SideQuadLower.b - b)/(float) (Precision-1);
		f32 a_p = (float) (alpha - a)/(float) (Precision-1);
		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(90+i*90/(f32)(Precision-1));
			GX_Position3f32(x1+Margin+Margin*cos(deg), y2-Margin+Margin*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i, a+a_p*i);
		}

		//! Opaque
		r = ShadowUpper.r;
		g = ShadowUpper.g;
		b = ShadowUpper.b;
		r_p = (float) (SideQuadLower.r - r)/(float) (Precision-1);
		g_p = (float) (SideQuadLower.g - g)/(float) (Precision-1);
		b_p = (float) (SideQuadLower.b - b)/(float) (Precision-1);

		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(90+i*90/(f32)(Precision-1));
			GX_Position3f32(x1+Margin+Margin*cos(deg), y2-Margin+(Margin-ShadowWidth)*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i, alpha);
		}
	}
	GX_End();

	//! Lower QUAD
	GX_Begin(GX_QUADS, GX_VTXFMT0,8);
		//! Transparent shadow quad
		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(ShadowUpper.r,ShadowUpper.g,ShadowUpper.b,alpha);

		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(ShadowUpper.r,ShadowUpper.g,ShadowUpper.b,alpha);

		GX_Position3f32(x2-Margin, y2, z);
		GX_Color4u8(ShadowLower.r,ShadowLower.g,ShadowLower.b,0.1f*alpha);

		GX_Position3f32(x1+Margin, y2, z);
		GX_Color4u8(ShadowLower.r,ShadowLower.g,ShadowLower.b,0.1f*alpha);

		//! Opaque quad
		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		GX_Position3f32(x2-Margin, y2-ShadowWidth, z);
		GX_Color4u8(ShadowUpper.r,ShadowUpper.g,ShadowUpper.b,alpha);

		GX_Position3f32(x1+Margin, y2-ShadowWidth, z);
		GX_Color4u8(ShadowUpper.r,ShadowUpper.g,ShadowUpper.b,alpha);
	GX_End();

	//! Lower Right Corner Circle
	GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, Precision*2+2);
	{
		f32 deg;
		int r = SideQuadLower.r;
		int g = SideQuadLower.g;
		int b = SideQuadLower.b;
		f32 a = alpha;
		f32 r_p = (float) (ShadowLower.r - r)/(float) (Precision-1);
		f32 g_p = (float) (ShadowLower.g - g)/(float) (Precision-1);
		f32 b_p = (float) (ShadowLower.b - b)/(float) (Precision-1);
		f32 a_p = (float) (0.1f*alpha - a)/(float) (Precision-1);
		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(i*90/(f32)(Precision-1));
			GX_Position3f32(x2-Margin+Margin*cos(deg), y2-Margin+Margin*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i, a+a_p*i);
		}

		r_p = (float) (ShadowUpper.r - r)/(float) (Precision-1);
		g_p = (float) (ShadowUpper.g - g)/(float) (Precision-1);
		b_p = (float) (ShadowUpper.b - b)/(float) (Precision-1);

		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(i*90/(f32)(Precision-1));
			GX_Position3f32(x2-Margin+Margin*cos(deg), y2-Margin+(Margin-ShadowWidth)*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i, alpha);
		}
	}
	GX_End();

	//! Right QUAD
	GX_Begin(GX_QUADS, GX_VTXFMT0,4);
		GX_Position3f32(x2-Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		GX_Position3f32(x2, y1+Margin, z);
		GX_Color4u8(SideQuadUpper.r,SideQuadUpper.g,SideQuadUpper.b,alpha);

		GX_Position3f32(x2, y2-Margin, z);
		GX_Color4u8(SideQuadLower.r,SideQuadLower.g,SideQuadLower.b,alpha);

		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);
	GX_End();

	//! Upper/Left Corner Circle
	GX_Begin(GX_TRIANGLEFAN, GX_VTXFMT0, Precision+1);
	{
		f32 deg;
		int r = UpperQuadUpper.r;
		int g = UpperQuadUpper.g;
		int b = UpperQuadUpper.b;
		f32 r_p = (float) (SideQuadUpper.r - r)/(float) (Precision-1);
		f32 g_p = (float) (SideQuadUpper.g - g)/(float) (Precision-1);
		f32 b_p = (float) (SideQuadUpper.b - b)/(float) (Precision-1);
		GX_Position3f32(x2-Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		for(int i = 0; i < Precision; ++i)
		{
			deg = DegToRad(270+i*90/(f32)(Precision-1));
			GX_Position3f32(x2-Margin+Margin*cos(deg), y1+Margin+Margin*sin(deg), z);
			GX_Color4u8(r+r_p*i, g+g_p*i, b+b_p*i,alpha);
		}
	}
	GX_End();

	//! Main QUAD
	GX_Begin(GX_QUADS, GX_VTXFMT0,4);
		GX_Position3f32(x1+Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		GX_Position3f32(x2-Margin, y1+Margin, z);
		GX_Color4u8(MainQuadUpper.r,MainQuadUpper.g,MainQuadUpper.b,alpha);

		GX_Position3f32(x2-Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);

		GX_Position3f32(x1+Margin, y2-Margin, z);
		GX_Color4u8(MainQuadLower.r,MainQuadLower.g,MainQuadLower.b,alpha);
	GX_End();

	GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);

	DrawListSize = GX_EndDispList();
}