Loading a strip of sprites

BlitzMax Forums/OpenGL Module/Loading a strip of sprites

Ryan Burnside(Posted 2007) [#1]
Could somebody please tell me the best way to load an entire strip animation into OpenGL using Blitzmax?

I would just prefer to use a strip image of a 2d sprite rather than say 6 individual files loaded as pixmaps upon initialization. As far as I know pixmaps can't contain frames or be rectangular in demension.

I have a 16 frame sprite it's saved as a png file. I understand how to apply textures to polygons but how can one allow for a frame strip as a png file? I know that the transparency mask is easly defined in Blitzmax I'm sure I'll need that done in OpenGL aswell.

Thanks,
Ryan


RiK(Posted 2007) [#2]
LoadAnimImage

Function LoadAnimImage:TImage( url:Object,cell_width,cell_height,first_cell,cell_count,flags=-1 )


LoadAnimImage extracts multiple image frames from a single, larger image. url can be either a string or an existing pixmap.

See LoadImage for valid flags values.


Ryan Burnside(Posted 2007) [#3]
Thanks Rik, I was under the impression that you could only use Pixmaps for images. Am I mistaken?

I've found learning OpenGL within Blitzmax frusterating. It seems that there is even less documentation for OpenGL in Blitzmax. Some commands you must know and there is no master list. Other times commands have to be done differently.


Ryan Burnside(Posted 2007) [#4]
I still need some help with this.

Don't many people use OpenGL with blitzmax?


ninjarat(Posted 2007) [#5]
Pixmaps can have any dimensions whatsoever. Now on to the main event!


Animated Images 101:

So you want to load an image strip? Well, BlitzMax has you covered for that, but if you want to load a strip of images, and then get the Pixmaps, you'll need to know how the TImage Class works. First use this to load the strip:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)


Now you must extract the pixmaps. You'll need to access the pixmap field of the TImage Class on the instance 'myanimation' you created previously. This is the BRL code used to define a TImage (DO NOT INCORPORATE IN TO YOUR OWN CODE, IT'S AUTOMATICALLY DONE FOR YOU):



As you can see, one of the field vars is 'pixmaps', a TPixmap Array. You'll need to get these manually. Ahem, Mark, ahem, Simon, there needs to be a BRL function for returning that. Or maybe not. Your program will look something like this now:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)
Local pixmaps:TPixmap[]=myanimation.pixmaps


There! Pixmaps loaded! All you have to do now, is do whatever you want with the resulting pixmaps. You can additionally turn each one in to a TImage for all the special rendering features that are provided with it. Like this:

Local myanimation:TImage=LoadAnimImage(myurl:Object,width,height,first,count,flags=-1)
Local pixmaps:TPixmap[]=myanimation.pixmaps
Local images:TImage[pixmaps.length]

For j=0 to pixmaps.length-1
	images[j]=LoadImage(pixmaps[j])
Next


Hope this helps! Now, as for loading them specifically with OpenGL, I dunno, but I know that OpenGL is much easier to understand than DirectX, so keep trying. You'll get it. ;)


Ryan Burnside(Posted 2007) [#6]
Thank yo very much. I will try to impliment this code when i get a chance...
Thanks again. :)