View Single Post
Old 09-20-2011   #4
ThatOtherPerson
Homebrew Developer
 
ThatOtherPerson's Avatar
 
Join Date: Jun 2009
Posts: 66
Likes: 0
Liked 65 Times in 20 Posts
Mentioned: 3 Post(s)
Tagged: 0 Thread(s)
I have no problem with deciding when and where to place blood or their alpha value. I already have that implemented and it is working pretty well in a build that I have running on Windows using OpenGL for rendering (before anyone asks yeah I'll be releasing Windows versions eventually).



My problem comes when I get to that "Draw(blood)" part you mentioned.

This is what I've got now. It is imperfect when fewer then the maximum number of decals are in existence but whatever I'm content with it, it doesn't take long for 500 blood or corpse sprites to be spawned and I can improve upon it later.

Code:
#ifdef WIN
glBindTexture(GL_TEXTURE_2D,persontexture);
#endif
#ifdef PS3
usetexture(persontexture_image);
#endif
for(int a=0;a<decalcount;a++){
	#ifdef WIN
	glColor4f(1.f,1.f,1.f,(float)a/(float)maxdecalcount); 
	#endif
	draw2dquad(
		decallist[a].posx,
		decallist[a].posy,
		0.75f,0.75f,
		decaltexturecoords[decallist[a].type],
		1,decallist[a].angle);
}
#ifdef WIN
glColor4f(1.f,1.f,1.f,1.f); 
#endif
With this being the PS3 version of that draw2dquad function

Code:
void draw2dquad(float posx,float posy,float sizex,float sizey,float *texturecoords,bool centerandrotate,float angle){
	#ifdef PS3
	if(centerandrotate==0){
		float verts[]={
			posx,		posy+sizey,
			posx+sizex,	posy+sizey,
			posx+sizex,	posy,
			posx,		posy,};
		realityVertexBegin(context,REALITY_QUADS);{
			for(int b=0;b<4;b++){
				realityTexCoord2f(context,texturecoords[b*2],texturecoords[b*2+1]);
				realityVertex4f(context,verts[b*2],verts[b*2+1],0.0,1.0);
			}
		}
		realityVertexEnd(context);
	}else if(angle==0){
		sizex*=0.5f;
		sizey*=0.5f;
		float verts[]={
			posx-sizex,	posy+sizey,
			posx+sizex,	posy+sizey,
			posx+sizex,	posy-sizey,
			posx-sizex,	posy-sizey,};
		realityVertexBegin(context,REALITY_QUADS);{
			for(int b=0;b<4;b++){
				realityTexCoord2f(context,texturecoords[b*2],texturecoords[b*2+1]);
				realityVertex4f(context,verts[b*2],verts[b*2+1],0.0,1.0);
			}
		}
		realityVertexEnd(context);
	}else{
		angle*=-1;
		sizex*=0.5f;
		sizey*=0.5f;
		float vertsunrotated[]={
			0-sizex,	0+sizey,
			0+sizex,	0+sizey,
			0+sizex,	0-sizey,
			0-sizex,	0-sizey,};
		float verts[]={
			posx+vertsunrotated[1]*sin(angle)+vertsunrotated[0]*cos(angle),	posy+vertsunrotated[1]*cos(angle)-vertsunrotated[0]*sin(angle),
			posx+vertsunrotated[3]*sin(angle)+vertsunrotated[2]*cos(angle),	posy+vertsunrotated[3]*cos(angle)-vertsunrotated[2]*sin(angle),
			posx+vertsunrotated[5]*sin(angle)+vertsunrotated[4]*cos(angle),	posy+vertsunrotated[5]*cos(angle)-vertsunrotated[4]*sin(angle),
			posx+vertsunrotated[7]*sin(angle)+vertsunrotated[6]*cos(angle),	posy+vertsunrotated[7]*cos(angle)-vertsunrotated[6]*sin(angle),};
		realityVertexBegin(context,REALITY_QUADS);{
			for(int b=0;b<4;b++){
				realityTexCoord2f(context,texturecoords[b*2],texturecoords[b*2+1]);
				realityVertex4f(context,verts[b*2],verts[b*2+1],0.0,1.0);
			}
		}
		realityVertexEnd(context);
	}
	#endif
}
Yeah I know there is undoubtedly a lot of room for optimization especially when it comes to dealing with rotated sprites but the relevant part is that I obviously can't use glColor4f without OpenGL so I need a PS3 specific alternative.
__________________

Last edited by ThatOtherPerson; 09-20-2011 at 02:43 AM.
ThatOtherPerson is offline   Reply With Quote
Likes: (2)