forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PNG Images with Alpha effect slows down the script

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Wed Mar 25, 2009 4:48 am    Post subject: PNG Images with Alpha effect slows down the script Reply with quote

PNG Images with Alpha effect slows down the script i blit images after while true and use "mouse" in it. And if i blit 2 images one on other it slow down "mouse" movement

Quote:
while(1)
{

...

/////////////////////////////////////////////////////////////////////////////////
if ((x < 58 && y < 58) && (pad.Buttons & PSP_CTRL_CROSS)) {
pco = 1;
}
if(pco == 1)
{
blitAlphaImageToScreen(0 ,0 , 480, 246, pc, 0, 0);
if (x > 99 && x < 276 && y > 69 && y < 120)
{
blitImageToScreen(0 ,0 , 185, 60, hover, 100, 68);
}
if (x > 276 && x < 465 && y > 69 && y < 120)
{
blitImageToScreen(0 ,0 , 185, 60, hover, 286, 68);
}
blitAlphaImageToScreen(0 ,0 , 77, 50, ms, 105, 73);
printTextScreen(185, 90, "Memory Stick", black);
blitAlphaImageToScreen(0 ,0 , 70, 57, umd, 290, 70);
printTextScreen(362, 90, "UMD", black);
if(x > 420 && x < 472 && y < 18)
{
blitAlphaImageToScreen(0 ,0 , 42, 16, close, 431, 2);
if (pad.Buttons & PSP_CTRL_CROSS)
{
pco = 0;
}
}
}
/////////////////////////////////////////////////////////////////////////////////

...

blitAlphaImageToScreen(0 ,0 , 32, 32, cursor, x, y);



sceDisplayWaitVblankStart();
flipScreen();

...

}



... - means cutted script


Something
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Mar 25, 2009 7:06 am    Post subject: Reply with quote

An alpha blit has to read the existing pixels and perform a multiply per pixel, so it's bound to be slower than a straight blit which doesn't.

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Thu Mar 26, 2009 1:31 am    Post subject: Reply with quote

It looks like your using the graphics.c from LUAPlayer. This is very inefficient because each function call is a complete independent blitting process. You should learn to use the GU functions yourself.
Back to top
View user's profile Send private message
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Thu Mar 26, 2009 2:44 am    Post subject: Reply with quote

So what is the esiest way to use it without graphic.c ? :/ Becouse Gui have a lot of functions.... Or where is samples with it ? Found that some of people uses OSLib if i will use it would i have same problem?
Back to top
View user's profile Send private message Visit poster's website
Pihas



Joined: 25 Oct 2008
Posts: 60
Location: Lithuania

PostPosted: Thu Apr 02, 2009 11:16 pm    Post subject: Reply with quote

Quote:
void blitAlphaImageToScreen(int sx, int sy, int width, int height, Image* source, int dx, int dy)
{
if (!initialized) return;

sceKernelDcacheWritebackInvalidateAll();
guStart();
sceGuTexImage(0, source->textureWidth, source->textureHeight, source->textureWidth, (void*) source->data);
float u = 1.0f / ((float)source->textureWidth);
float v = 1.0f / ((float)source->textureHeight);
sceGuTexScale(u, v);

int j = 0;
while (j < width) {
Vertex* vertices = (Vertex*) sceGuGetMemory(2 * sizeof(Vertex));
int sliceWidth = 64;
if (j + sliceWidth > width) sliceWidth = width - j;
vertices[0].u = sx + j;
vertices[0].v = sy;
vertices[0].x = dx + j;
vertices[0].y = dy;
vertices[0].z = 0;
vertices[1].u = sx + j + sliceWidth;
vertices[1].v = sy + height;
vertices[1].x = dx + j + sliceWidth;
vertices[1].y = dy + height;
vertices[1].z = 0;
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, 0, vertices);
j += sliceWidth;
}
sceGuFinish();
sceGuSync(0, 0);

}

I use blitAlphaImageToScreen function after while true how to optimize this :/ tried to cut sceGuSync(0, 0); sceGuFinish(); to main.c but i had the same problem :/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group