[patch] less footprint to load PNG
3 posters
[patch] less footprint to load PNG
Hi,
this is a patch for sio2 1.4.0.
It loads .PNG images with less memory footprint (a probably it loads them a little faster).
It doesn't call sioImageFlip. Instead, it "flips" the image when it loads it.
this is a patch for sio2 1.4.0.
It loads .PNG images with less memory footprint (a probably it loads them a little faster).
It doesn't call sioImageFlip. Instead, it "flips" the image when it loads it.
- Code:
--- sio2_image.cc 2009-08-04 11:56:16.000000000 -0300
+++ sio2_image-patch.cc 2009-08-04 11:56:08.000000000 -0300
@@ -413,7 +413,7 @@
while( i < ( int )_SIO2image->height )
{
_png_bytep[ i ] = ( png_bytep )( _SIO2image->tex +
- ( _SIO2image->height - ( i + 1 ) ) *
+ i *
_SIO2image->width *
_SIO2image->bits );
++i;
@@ -428,7 +428,7 @@
&_png_infop, NULL );
free( _png_bytep );
- sio2ImageFlip( _SIO2image );
+// sio2ImageFlip( _SIO2image );
if( _SIO2image->bits == 4 )
{ sio2ImageRGBAtoBGRA( _SIO2image ); }
Re: [patch] less footprint to load PNG
Wow, Riq good to see you here... I was just thinking about using cocos2D for my HUD gui layer on top of SIO2; any chance you have a patch to support that :-) If not, a recommendation will do.
--yarri
--yarri
yarri- Posts : 81
Join date : 2009-04-10
Re: [patch] less footprint to load PNG
Hi yarri,
I'm not familiar with sio2's internals, so this is just a guess:
To mix cocos2d inside sio2:
- initialize cocos2d, but comment the opengl initialization (already done by sio2)
- don't run any scene
- modify Director.m so that you can insert an scene without running using the API
- from a sio2 timer, call Director#mainLoop
- also, sio2's openglview should be assigned to the Director (so both of them uses the same openglview)
- Director#mainLoop should have these lines commented:
- // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // don't clear the screen, let sio2 do it
- // [openGLView_ swapBuffers]; // don't swap the opengl buffers
- Director mainLoop should also have:
- save the current projection matrix (sio2 projection matrix)
- set cocos2d projection matrix
- (draw cocos2d scene)
- restore sio2 projection matrix
as I said, this is just a guess.
I'm not familiar with sio2's internals, so this is just a guess:
To mix cocos2d inside sio2:
- initialize cocos2d, but comment the opengl initialization (already done by sio2)
- don't run any scene
- modify Director.m so that you can insert an scene without running using the API
- from a sio2 timer, call Director#mainLoop
- also, sio2's openglview should be assigned to the Director (so both of them uses the same openglview)
- Director#mainLoop should have these lines commented:
- // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // don't clear the screen, let sio2 do it
- // [openGLView_ swapBuffers]; // don't swap the opengl buffers
- Director mainLoop should also have:
- save the current projection matrix (sio2 projection matrix)
- set cocos2d projection matrix
- (draw cocos2d scene)
- restore sio2 projection matrix
as I said, this is just a guess.
Re: [patch] less footprint to load PNG
Thanks, so far minimal changes to cocos2D. I'll try to work on an HUD example but having trouble with your new TouchDispatcher. I think I need to have SIO2 pass touches to cocos2D instead of the other way around. I'll upload a test case of cocos2D menus/buttons controlling the rate of the spinning square from SIO2 tutorial01. Hopefully.
--yarri
--yarri
yarri- Posts : 81
Join date : 2009-04-10
Re: [patch] less footprint to load PNG
Hey Yarri,
Am just curious about the use of Cocos2D on top of SIO2 - what does that give you for your hud versus using plain sio2 widgets?
Thanks for sharing this btw.
Cheers
--Frank
Am just curious about the use of Cocos2D on top of SIO2 - what does that give you for your hud versus using plain sio2 widgets?
Thanks for sharing this btw.
Cheers
--Frank
Francescu- Posts : 136
Join date : 2009-03-18
Re: [patch] less footprint to load PNG
Hi, for our games we have some simple sprite animations that I've written with SIO2widgets but it's tedious. The power of cocos2d is to do something like this to animate a sprite:
Someone posted similar capabilities for SIO2 v1.2:
https://sio2interactive.forumotion.net/sio2-engine-f3/sprite-additions-t502.htm
Without this type of sequence controller it's hard to have an animated HUD... think of "blooms" and "particle effects" around high score achievements, etc.
Thanks,
--yarri
- Code:
id action1 = [MoveTo actionWithDuration:2 position:ccp(100,100)];
id action2 = [MoveBy actionWithDuration:2 position: ccp(80,80)];
id action3 = [MoveBy actionWithDuration:2 position: ccp(0,80)];
[sprite runAction: [Sequence actions:action1, action2, action3, nil]];
Someone posted similar capabilities for SIO2 v1.2:
https://sio2interactive.forumotion.net/sio2-engine-f3/sprite-additions-t502.htm
Without this type of sequence controller it's hard to have an animated HUD... think of "blooms" and "particle effects" around high score achievements, etc.
Thanks,
--yarri
yarri- Posts : 81
Join date : 2009-04-10
Re: [patch] less footprint to load PNG
I see - interesting indeed.
I haven't looked at Cocos2D footprint but am wondering how this would add up with SIO2's one at runtime (memory footprint) and the downloadable footprint for the .app (size)...
Thanks.
PS: Might have been good to see Uprise's changes available as part of SIO2 or as an extension to it...
I haven't looked at Cocos2D footprint but am wondering how this would add up with SIO2's one at runtime (memory footprint) and the downloadable footprint for the .app (size)...
Thanks.
PS: Might have been good to see Uprise's changes available as part of SIO2 or as an extension to it...
Francescu- Posts : 136
Join date : 2009-03-18
Similar topics
» compiled footprint
» Load times
» SIO load checking
» Increase load performance
» Load image from net into SIO2material
» Load times
» SIO load checking
» Increase load performance
» Load image from net into SIO2material
Permissions in this forum:
You cannot reply to topics in this forum