Beispiel #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;
}
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);
}
Beispiel #3
0
static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor color)
{
  /* reintialize texture object */
  GXTexObj texobj;
  GX_InitTexObj(&texobj, fontTexture, fontHeader->cell_width, fontHeader->cell_height, GX_TF_I4, GX_CLAMP, GX_CLAMP, GX_FALSE);
  GX_LoadTexObj(&texobj, GX_TEXMAP0);

  /* reinitialize font texture data */
  memset(fontTexture,0,fontHeader->cell_width * fontHeader->cell_height / 2);
  GetFontTexel(c,fontTexture,0,fontHeader->cell_width/2);
  DCFlushRange(fontTexture, fontHeader->cell_width * fontHeader->cell_height / 2);
  GX_InvalidateTexAll();

  /* adjust texture width */
  s32 width = (fontHeader->cell_width * size) / fontHeader->cell_height;

  /* GX rendering */
  GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
  GX_Position2s16(xpos, ypos - size);
  GX_Color4u8(color.r, color.g, color.b, 0xff);
  GX_TexCoord2f32(0.0, 0.0);
  GX_Position2s16(xpos + width, ypos - size);
  GX_Color4u8(color.r, color.g, color.b, 0xff);
  GX_TexCoord2f32(1.0, 0.0);
  GX_Position2s16(xpos + width, ypos);
  GX_Color4u8(color.r, color.g, color.b, 0xff);
  GX_TexCoord2f32(1.0, 1.0);
  GX_Position2s16(xpos, ypos);
  GX_Color4u8(color.r, color.g, color.b, 0xff);
  GX_TexCoord2f32(0.0, 1.0);
  GX_End ();
  GX_DrawDone();
}
Beispiel #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();
	}
}
Beispiel #5
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();
}
Beispiel #6
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();
}
Beispiel #7
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);
}
Beispiel #8
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();
}
Beispiel #9
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 ();
	}
}
Beispiel #10
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 ();
	}
}
Beispiel #11
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();
}
Beispiel #12
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);
}
Beispiel #13
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();
}
Beispiel #14
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);
}
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);
}
Beispiel #16
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();
}
Beispiel #17
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);
}
Beispiel #18
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();
}
Beispiel #19
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);
}
Beispiel #20
0
void Menu_DrawDiskCover(f32 xpos, f32 ypos, f32 zpos, u16 width, u16 height, u16 distance, u8 data[], f32 deg_alpha,
		f32 deg_beta, f32 scaleX, f32 scaleY, u8 alpha, bool shadow)
{
	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);

	f32 cos_beta = cos(DegToRad( deg_beta ));
	f32 s_offset_y = (zpos + (cos_beta * distance)) * tan(DegToRad( 5 ));
	f32 s_offset_x = (cos_beta < 0 ? -cos_beta : cos_beta) * s_offset_y;
	f32 s_offset_z = (s_offset_y < 0 ? 0 : s_offset_y) * 2;

	Mtx m, m1, m2, m3, m4, mv;
	width *= .5;
	height *= .5;
	guMtxIdentity(m4);
	guMtxTransApply(m4, m4, 0, 0, distance);

	guMtxIdentity(m1);
	guMtxScaleApply(m1, m1, scaleX, scaleY, 1.0);
	guVector axis2 = (guVector) {0 , 1, 0};
	guMtxRotAxisDeg ( m2, &axis2, deg_beta );
	guVector axis = (guVector) {0 , 0, 1};
	guMtxRotAxisDeg ( m3, &axis, deg_alpha );
	guMtxConcat(m3, m4, m3); // move distance then rotate z-axis
	guMtxConcat(m2, m3, m2); // rotate y-axis
	guMtxConcat(m1, m2, m); // scale

	if (shadow)
		guMtxTransApply(m, m, xpos + width + 0.5 + s_offset_x, ypos + height + 0.5 + s_offset_y, zpos - s_offset_z);
	else
	guMtxTransApply(m, m, xpos + width + 0.5, ypos + height + 0.5, zpos);

	guMtxConcat(FSModelView2D, m, mv);
	GX_LoadPosMtxImm(mv, GX_PNMTX0);

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

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

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

		GX_Position3f32(-width, height, 0);
		GX_Color4u8(0, 0, 0, alpha);
		GX_TexCoord2f32(0, 1);
	}
	else
	{
		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();
}
Beispiel #21
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();
}
Beispiel #22
0
void draw_butterfly( f32 angle, f32 wscale, f32 sx, f32 sy, f32 z, u8 *col1, u8 *col2, u8 *col3, s32 small )
{
	s32 i;
	f32 ca, sa;
	struct vtx *a, *b, *c;
	struct vtx *bs;
  
	if( small )
		bs = &bbfly[0];
	else
		bs = &bfly[0];

	ca = cos( angle );
	sa = sin( angle );
  
	for( i=0; i<NUM_BUTTERFLY_VERTICES; i++ )
	{
		bs[i].f1 = 1;
		bs[i].f2 = 1;
	}
  
	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, NUM_BF_BODY_POLYS*3 );
	for( i=0; i<NUM_BF_BODY_POLYS; i++ )
	{
		a = &bs[bf_body_polys[i*3]];
		b = &bs[bf_body_polys[i*3+1]];
		c = &bs[bf_body_polys[i*3+2]];
   
		if( a->f1 )
		{
			a->f1 = 0;
			a->sx = (a->x*ca - a->y*sa) + sx;
			a->sy = (a->x*sa + a->y*ca) + sy;
		}
    
		if( b->f1 )
		{
			b->f1 = 0;
			b->sx = (b->x*ca - b->y*sa) + sx;
			b->sy = (b->x*sa + b->y*ca) + sy;
		}
    
		if( c->f1 )
		{
			c->f1 = 0;
			c->sx = (c->x*ca - c->y*sa) + sx;
			c->sy = (c->x*sa + c->y*ca) + sy;
		}
    
		GX_Position3f32( a->sx, a->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
		GX_Position3f32( b->sx, b->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
		GX_Position3f32( c->sx, c->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
	}
	GX_End();
  
	// Bodge to give a slight "3D" look
	if( angle > 0.0f )
	{
		draw_bf_leftwing( ca, sa, wscale, sx, sy, z, col2, col3, bs );
		draw_bf_rightwing( ca, sa, wscale-0.8f, sx, sy, z, col2, col3, bs );
	} else {
		draw_bf_rightwing( ca, sa, wscale, sx, sy, z, col2, col3, bs );
		draw_bf_leftwing( ca, sa, wscale-0.8f, sx, sy, z, col2, col3, bs );
	}
}
void WiiPointer::Draw(GuiTrigger *t)
{
	if(t && pointerImg)
	{
		if(t->wpad.ir.valid)
		{
			lastActivity = 0;
			posX = t->wpad.ir.x;
			posY = t->wpad.ir.y;
			angle = t->wpad.ir.angle;
		}
		else
		{
			angle = 0.0f;
			// GC PAD
			// x-axis
			if(t->pad.stickX < -PADCAL)
			{
				posX += (t->pad.stickX + PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			else if(t->pad.stickX > PADCAL)
			{
				posX += (t->pad.stickX - PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			// y-axis
			if(t->pad.stickY < -PADCAL)
			{
				posY -= (t->pad.stickY + PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			else if(t->pad.stickY > PADCAL)
			{
				posY -= (t->pad.stickY - PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}

			//Wii u pro x-axis
			if(t->wupcdata.stickX < -WUPCCAL)
			{
				posX += (t->wupcdata.stickX + WUPCCAL) * Settings.PointerSpeed/8;
				lastActivity = 0;
			}
			else if(t->wupcdata.stickX > WUPCCAL)
			{
				posX += (t->wupcdata.stickX - WUPCCAL) * Settings.PointerSpeed/8;
				lastActivity = 0;
			}
			//Wii u pro y-axis
			if(t->wupcdata.stickY < -WUPCCAL)
			{
				posY -= (t->wupcdata.stickY + WUPCCAL) * Settings.PointerSpeed/8;
				lastActivity = 0;
			}
			else if(t->wupcdata.stickY > WUPCCAL)
			{
				posY -= (t->wupcdata.stickY - WUPCCAL) * Settings.PointerSpeed/8;
				lastActivity = 0;
			}

			int wpadX = t->WPAD_Stick(0, 0);
			int wpadY = t->WPAD_Stick(0, 1);

			// Wii Extensions
			// x-axis
			if(wpadX < -PADCAL)
			{
				posX += (wpadX + PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			else if(wpadX > PADCAL)
			{
				posX += (wpadX - PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			// y-axis
			if(wpadY < -PADCAL)
			{
				posY -= (wpadY + PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}
			else if(wpadY > PADCAL)
			{
				posY -= (wpadY - PADCAL) * Settings.PointerSpeed;
				lastActivity = 0;
			}

			if(t->pad.btns_h || t->wpad.btns_h || t->wupcdata.btns_h)
				lastActivity = 0;

			posX = LIMIT(posX, -50.0f, screenwidth+50.0f);
			posY = LIMIT(posY, -50.0f, screenheight+50.0f);

			if(lastActivity < 2) { // (3s on 60Hz and 3.6s on 50Hz)
				t->wpad.ir.valid = 1;
				t->wpad.ir.x = posX;
				t->wpad.ir.y = posY;
			}
		}

		if(t->wpad.ir.valid)
		{
			GXTexObj texObj;
			GX_InitTexObj(&texObj, pointerImg->GetImage(), pointerImg->GetWidth(), pointerImg->GetHeight(), 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 mv;
			guMtxIdentity(mv);
			guMtxRotDeg (mv, 'z', angle);
			guMtxTransApply(mv, mv, posX, posY, 9900.f);
			guMtxConcat(FSModelView2D, mv, mv);

			GX_LoadProjectionMtx(projection, GX_ORTHOGRAPHIC);
			GX_LoadPosMtxImm(mv, GX_PNMTX0);

			// pointer is pointing to center of the texture
			f32 width = 0.5f * pointerImg->GetWidth();
			f32 height = 0.5f * pointerImg->GetHeight();

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

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

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

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

			GX_End();
		}
	}

	++lastActivity;
}
Beispiel #24
0
void draw_bf_rightwing( f32 ca, f32 sa, f32 wscale, f32 sx, f32 sy, f32 z, u8 *col1, u8 *col2, struct vtx *bs )
{
	s32 i;
	struct vtx *a, *b, *c;
	
	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, NUM_BF_RWING_POLYS*3 );
	for( i=0; i<NUM_BF_RWING_POLYS; i++ )
	{
		a = &bs[bf_rwing_polys[i*3]];
		b = &bs[bf_rwing_polys[i*3+1]];
		c = &bs[bf_rwing_polys[i*3+2]];

		if( a->f2 )
		{
			a->f2 = 0;
			a->sx = (a->x*wscale*ca - a->y*sa) + sx;
			a->sy = (a->x*wscale*sa + a->y*ca) + sy;
		}

		if( b->f2 )
		{
			b->f2 = 0;
			b->sx = (b->x*wscale*ca - b->y*sa) + sx;
			b->sy = (b->x*wscale*sa + b->y*ca) + sy;
		}

		if( c->f2 )
		{
			c->f2 = 0;
			c->sx = (c->x*wscale*ca - c->y*sa) + sx;
			c->sy = (c->x*wscale*sa + c->y*ca) + sy;
		}

		GX_Position3f32( a->sx, a->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
		GX_Position3f32( b->sx, b->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
		GX_Position3f32( c->sx, c->sy, z );
		GX_Color4u8( col1[0], col1[1], col2[2], 0xff );
	}
	GX_End();

	GX_Begin( GX_TRIANGLES, GX_VTXFMT0, NUM_BF_RPTRN_POLYS*3 );
	for( i=0; i<NUM_BF_RPTRN_POLYS; i++ )
	{
		a = &bs[bf_rptrn_polys[i*3]];
		b = &bs[bf_rptrn_polys[i*3+1]];
		c = &bs[bf_rptrn_polys[i*3+2]];

		if( a->f2 )
		{
			a->f2 = 0;
			a->sx = (a->x*wscale*ca - a->y*sa) + sx;
			a->sy = (a->x*wscale*sa + a->y*ca) + sy;
		}

		if( b->f2 )
		{
			b->f2 = 0;
			b->sx = (b->x*wscale*ca - b->y*sa) + sx;
			b->sy = (b->x*wscale*sa + b->y*ca) + sy;
		}

		if( c->f2 )
		{
			c->f2 = 0;
			c->sx = (c->x*wscale*ca - c->y*sa) + sx;
			c->sy = (c->x*wscale*sa + c->y*ca) + sy;
		}

		GX_Position3f32( a->sx, a->sy, z );
		GX_Color4u8( col2[0], col2[1], col2[2], 0xff );
		GX_Position3f32( b->sx, b->sy, z );
		GX_Color4u8( col2[0], col2[1], col2[2], 0xff );
		GX_Position3f32( c->sx, c->sy, z );
		GX_Color4u8( col2[0], col2[1], col2[2], 0xff );
	}
	GX_End();

	GX_Begin( GX_LINESTRIP, GX_VTXFMT0, NUM_BF_RWING_EDGES );
	for( i=0; i<NUM_BF_RWING_EDGES; i++ )
	{
		GX_Position3f32( bs[bf_rwing_edges[i]].sx, bs[bf_rwing_edges[i]].sy, z );
		GX_Color4u8( 0, 0, 0, 0xff );
	}
	GX_End();
}
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;
	}
}
Beispiel #26
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();
}
Beispiel #27
0
MF_API void MFSetColour(float r, float g, float b, float a)
{
	GX_Color4u8((uint8)(r*255.0f), (uint8)(g*255.0f), (uint8)(b*255.0f), (uint8)(a*255.0f));
}
void BoxCover::Draw()
{
	u8 BoxAlpha = (int) (alpha+alphaDyn) & 0xFF;

	GX_LoadProjectionMtx(projection, GX_PERSPECTIVE);

	GX_ClearVtxDesc();
	GX_InvVtxCache();
	GX_SetVtxDesc(GX_VA_POS, GX_INDEX8);
	GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
	GX_SetVtxDesc(GX_VA_TEX0, GX_INDEX8);

	//! don't draw inside of the box
	GX_SetCullMode(GX_CULL_FRONT);

	Mtx	modelView;
	Mtx	modelView2;
	Mtx	modelView3;

	guVector cubeAxis = {0,0,1};
	guVector cubeAxis2 = {0,1,0};
	guVector cubeAxis3 = {1,0,0};
	guMtxIdentity(modelView);
	guMtxRotAxisDeg(modelView3, &cubeAxis3, RotX-Animation2);
	guMtxRotAxisDeg(modelView2, &cubeAxis2, RotY+Animation2+xoffsetDyn/2.0f);
	guMtxRotAxisDeg(modelView, &cubeAxis, RotZ-Animation);
	guMtxConcat(modelView3, modelView2, modelView2);
	guMtxConcat(modelView2, modelView, modelView);
	if(Settings.widescreen)
		guMtxScaleApply(modelView, modelView, Settings.WSFactor, 1.0f, 1.0f);
	guMtxTransApply(modelView, modelView, PosX+xoffsetDyn/680.0f+movePosX, PosY+yoffsetDyn/680.0f+movePosY, PosZ);
	guMtxConcat(view,modelView,modelView);

	GX_LoadPosMtxImm(modelView,	GX_PNMTX0);

	//! Border quads
	GX_LoadTexObj(&boxBorderTex, GX_TEXMAP0);
	GX_InvalidateTexAll();

	GX_SetArray(GX_VA_POS, (void *) &g_boxMeshQ[0].pos, sizeof(g_boxMeshQ[0]));
	GX_SetArray(GX_VA_TEX0, (void *) &g_boxMeshQ[0].texCoord, sizeof(g_boxMeshQ[0]));

	GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxMeshQSize);
	for (u32 j = 0; j < g_boxMeshQSize; ++j)
	{
		GX_Position1x8(j);
		GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha);
		GX_TexCoord1x8(j);
	}
	GX_End();

	//! Border triangles
	GX_SetArray(GX_VA_POS, (void *) &g_boxMeshT[0].pos, sizeof(g_boxMeshT[0]));
	GX_SetArray(GX_VA_TEX0, (void *) &g_boxMeshT[0].texCoord, sizeof(g_boxMeshT[0]));

	GX_Begin(GX_TRIANGLES, GX_VTXFMT0, g_boxMeshTSize);
	for (u32 j = 0; j < g_boxMeshTSize; ++j)
	{
		GX_Position1x8(j);
		GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha);
		GX_TexCoord1x8(j);
	}
	GX_End();

	//! Back Cover (Might be flat)
	GX_LoadTexObj(flatCover ? &defaultBoxTex : &coverTex, GX_TEXMAP0);
	GX_InvalidateTexAll();

	GX_SetArray(GX_VA_POS, (void *) &g_boxBackCoverMesh[0].pos, sizeof(g_boxBackCoverMesh[0]));
	GX_SetArray(GX_VA_TEX0, (void *) &g_boxBackCoverMesh[0].texCoord, sizeof(g_boxBackCoverMesh[0]));

	GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxBackCoverMeshSize);
	for (u32 j = 0; j < g_boxBackCoverMeshSize; ++j)
	{
		GX_Position1x8(j);
		if(flatCover)
			GX_Color4u8(boxColor.r, boxColor.g, boxColor.b, BoxAlpha);
		else
			GX_Color4u8(0xff, 0xff, 0xff, BoxAlpha);
		GX_TexCoord1x8(j);
	}
	GX_End();

	if(flatCover)
	{
		//! Front Flat Cover
		GX_LoadTexObj(&coverTex, GX_TEXMAP0);
		GX_InvalidateTexAll();

		GX_SetArray(GX_VA_POS, (void *) &g_flatCoverMesh[0].pos, sizeof(g_flatCoverMesh[0]));
		GX_SetArray(GX_VA_TEX0, (void *) &g_flatCoverMesh[0].texCoord, sizeof(g_flatCoverMesh[0]));

		GX_Begin(GX_QUADS, GX_VTXFMT0, g_flatCoverMeshSize);
		for (u32 j = 0; j < g_flatCoverMeshSize; ++j)
		{
			GX_Position1x8(j);
			GX_Color4u8(0xff, 0xff, 0xff, 0xff);
			GX_TexCoord1x8(j);
		}
		GX_End();
	}
	else
	{
		//! Front Cover
		GX_SetArray(GX_VA_POS, (void *) &g_boxCoverMesh[0].pos, sizeof(g_boxCoverMesh[0]));
		GX_SetArray(GX_VA_TEX0, (void *) &g_boxCoverMesh[0].texCoord, sizeof(g_boxCoverMesh[0]));

		GX_Begin(GX_QUADS, GX_VTXFMT0, g_boxCoverMeshSize);
		for (u32 j = 0; j < g_boxCoverMeshSize; ++j)
		{
			GX_Position1x8(j);
			GX_Color4u8(0xff, 0xff, 0xff, BoxAlpha);
			GX_TexCoord1x8(j);
		}
		GX_End();
	}

	//! stop cull
	GX_SetCullMode(GX_CULL_NONE);

	UpdateEffects();
}
Beispiel #29
0
/*
===============
R_DrawParticles
===============
*/
void R_DrawParticles (void)
{
	particle_t		*p, *kill;
	float			grav;
	int				i;
	float			time2, time3;
	float			time1;
	float			dvel;
	float			frametime;
// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Support for GX hardware:
//#ifdef GLQUAKE
#ifdef GXQUAKE
	unsigned char	*at;
	unsigned char	theAlpha;
	vec3_t			up, right;
	float			scale;

    GX_Bind(particletexture);
	GX_SetBlendMode(GX_BM_BLEND, gxu_blend_src_value, gxu_blend_dst_value, GX_LO_NOOP); 
	GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);

	VectorScale (vup, 1.5, up);
	VectorScale (vright, 1.5, right);
#elif GLQUAKE
// <<< FIX
	unsigned char	*at;
	unsigned char	theAlpha;
	vec3_t			up, right;
	float			scale;
	qboolean		alphaTestEnabled;
    
	GL_Bind(particletexture);
	alphaTestEnabled = glIsEnabled(GL_ALPHA_TEST);
	
	if (alphaTestEnabled)
		glDisable(GL_ALPHA_TEST);
	glEnable (GL_BLEND);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glBegin (GL_TRIANGLES);

	VectorScale (vup, 1.5, up);
	VectorScale (vright, 1.5, right);
#else
	D_StartParticles ();

	VectorScale (vright, xscaleshrink, r_pright);
	VectorScale (vup, yscaleshrink, r_pup);
	VectorCopy (vpn, r_ppn);
#endif

	frametime = host_frametime;
	time3 = frametime * 15;
	time2 = frametime * 10; // 15;
	time1 = frametime * 5;
	grav = frametime * 800 * 0.05;
	dvel = 4*frametime;
	
	for ( ;; ) 
	{
		kill = active_particles;
		if (kill && kill->die < cl.time)
		{
			active_particles = kill->next;
			kill->next = free_particles;
			free_particles = kill;
			continue;
		}
		break;
	}

	for (p=active_particles ; p ; p=p->next)
	{
		for ( ;; )
		{
			kill = p->next;
			if (kill && kill->die < cl.time)
			{
				p->next = kill->next;
				kill->next = free_particles;
				free_particles = kill;
				continue;
			}
			break;
		}

// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Support for GX hardware:
//#ifdef GLQUAKE
#ifdef GXQUAKE
		// hack a scale up to keep particles from disapearing
		scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
			+ (p->org[2] - r_origin[2])*vpn[2];
		if (scale < 20)
			scale = 1;
		else
			scale = 1 + scale * 0.004;
		at = (byte *)&d_8to24table[(int)p->color];
		if (p->type==pt_fire)
			theAlpha = 255*(6-p->ramp)/6;
//			theAlpha = 192;
//		else if (p->type==pt_explode || p->type==pt_explode2)
//			theAlpha = 255*(8-p->ramp)/8;
		else
			theAlpha = 255;
		gxu_cur_r = *at;
		gxu_cur_g = *(at+1);
		gxu_cur_b = *(at+2);
		gxu_cur_a = theAlpha;
//		glColor3ubv (at);
//		glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
		GX_Begin (GX_TRIANGLES, gxu_cur_vertex_format, 3);
		GX_Position3f32(p->org[0], p->org[1], p->org[2]);
		GX_Color4u8(gxu_cur_r, gxu_cur_g, gxu_cur_b, gxu_cur_a);
		GX_TexCoord2f32 (0,0);
		GX_Position3f32(p->org[0] + up[0]*scale, p->org[1] + up[1]*scale, p->org[2] + up[2]*scale);
		GX_Color4u8(gxu_cur_r, gxu_cur_g, gxu_cur_b, gxu_cur_a);
		GX_TexCoord2f32 (1,0);
		GX_Position3f32(p->org[0] + right[0]*scale, p->org[1] + right[1]*scale, p->org[2] + right[2]*scale);
		GX_Color4u8(gxu_cur_r, gxu_cur_g, gxu_cur_b, gxu_cur_a);
		GX_TexCoord2f32 (0,1);
		GX_End();

#elif GLQUAKE
// <<< FIX
		// hack a scale up to keep particles from disapearing
		scale = (p->org[0] - r_origin[0])*vpn[0] + (p->org[1] - r_origin[1])*vpn[1]
			+ (p->org[2] - r_origin[2])*vpn[2];
		if (scale < 20)
			scale = 1;
		else
			scale = 1 + scale * 0.004;
		at = (byte *)&d_8to24table[(int)p->color];
		if (p->type==pt_fire)
			theAlpha = 255*(6-p->ramp)/6;
//			theAlpha = 192;
//		else if (p->type==pt_explode || p->type==pt_explode2)
//			theAlpha = 255*(8-p->ramp)/8;
		else
			theAlpha = 255;
		glColor4ub (*at, *(at+1), *(at+2), theAlpha);
//		glColor3ubv (at);
//		glColor3ubv ((byte *)&d_8to24table[(int)p->color]);
		glTexCoord2f (0,0);
		glVertex3fv (p->org);
		glTexCoord2f (1,0);
		glVertex3f (p->org[0] + up[0]*scale, p->org[1] + up[1]*scale, p->org[2] + up[2]*scale);
		glTexCoord2f (0,1);
		glVertex3f (p->org[0] + right[0]*scale, p->org[1] + right[1]*scale, p->org[2] + right[2]*scale);

#else
		D_DrawParticle (p);
#endif

		p->org[0] += p->vel[0]*frametime;
		p->org[1] += p->vel[1]*frametime;
		p->org[2] += p->vel[2]*frametime;
		
		switch (p->type)
		{
		case pt_static:
			break;
		case pt_fire:
			p->ramp += time1;
			if (p->ramp >= 6)
				p->die = -1;
			else
				p->color = ramp3[(int)p->ramp];
			p->vel[2] += grav;
			break;

		case pt_explode:
			p->ramp += time2;
			if (p->ramp >=8)
				p->die = -1;
			else
				p->color = ramp1[(int)p->ramp];
			for (i=0 ; i<3 ; i++)
				p->vel[i] += p->vel[i]*dvel;
			p->vel[2] -= grav;
			break;

		case pt_explode2:
			p->ramp += time3;
			if (p->ramp >=8)
				p->die = -1;
			else
				p->color = ramp2[(int)p->ramp];
			for (i=0 ; i<3 ; i++)
				p->vel[i] -= p->vel[i]*frametime;
			p->vel[2] -= grav;
			break;

		case pt_blob:
			for (i=0 ; i<3 ; i++)
				p->vel[i] += p->vel[i]*dvel;
			p->vel[2] -= grav;
			break;

		case pt_blob2:
			for (i=0 ; i<2 ; i++)
				p->vel[i] -= p->vel[i]*dvel;
			p->vel[2] -= grav;
			break;

		case pt_slowgrav:
		case pt_grav:
			p->vel[2] -= grav;
			break;
		}
	}

// >>> FIX: For Nintendo Wii using devkitPPC / libogc
// Support for GX hardware:
//#ifdef GLQUAKE
#ifdef GXQUAKE
	GX_SetBlendMode(GX_BM_NONE, gxu_blend_src_value, gxu_blend_dst_value, GX_LO_NOOP); 
	GX_SetTevOp(GX_TEVSTAGE0, GX_REPLACE);
#elif GLQUAKE
// <<< FIX
	glEnd ();
	glDisable (GL_BLEND);
	if (alphaTestEnabled)
		glEnable(GL_ALPHA_TEST);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#else
	D_EndParticles ();
#endif
}