Rel's 8 bit and 32 bit Texture Packer



Relminator(Richard Eric M. Lope BSN RN) 2010-2012
http://rel.phatcode.net

Makes a texture atlas of your spritesheets using this algorithm:
http://www.blackpawn.com/texts/lightmaps/default.html



Usage: Double-Click "Texture_Packer_GUI.EXE"

or...

Usage: Texture_packer width height filename bpp savemode margin

   width    -> Width of the resulting packed texture
   height   -> Height of the resulting packed texture
   filename -> Filename of the texture file to be saved (no extension)
   bpp      -> Bits per pixel to save the texture
   savemode -> 0 = BMP,   1 = PNG
   margin   -> Margins(in pixels) between images(needed when textures are filtered to prevent "bleeding". Default = 0)
			-> Note that margin values won'y change the size of your individual sprites.  It would only
			   give a little margin between tiles so as to prevent "bleeding" between images when using
			   bilinear filtering.
			   
Use Texture_Packer_GUI.exe to launch application

See convert.bat for more details.


HOW TO USE:

1. Put a bunch of BMPs(any depth) and/or PNGs(32 bit) in the "/images" folder (any bmp/png name would work
	as long as it has a ".bmp"/".png" extension).
2. Double click "Texture_Packer_GUI.EXE" or Double click convert.bat
3. See the results in "/textures" folder.

RESULTING FILES (in /textures directory):

1. filename.[bmp/png] -> texture to be loaded on your game
2. filename_idx.[bmp/png] -> same file above but with the index numbers
			of each sprite frame (makes the coder's work easier.)
3. filename_idx_h.bmp -> a horizontal bmp with sprites + index which I use
			to reference my tiles on the tileset (even makes the
			coder's work easier.)
4. uvcoord_filename.bi -> FreeBasic include file that contains the coordinates,
 			frame, width and height of each sprite in the texture
			pack.
	load:
	
	
	for i as integer = 0 to TEXTUREPACK_NUM_IMAGES - 1
		j = i * 4
		u = texturepack_texcoords(j)		' s or x
		v = texturepack_texcoords(j+1)		' t or y
		width = texturepack_texcoords(j+2)
		height = texturepack_texcoords(j+3)
	next i

5. uvcoord_filename.h -> C/C++ include file that contains the coordinates,
 			frame, width and height of each sprite in the texture
			pack.
	load:
	
	
	for (int i = 0; i < TEXTUREPACK_NUM_IMAGES; i++)
	{
		int j = i * 4;
		int u = texturepack_texcoords[j];		// s or x
		int v = texturepack_texcoords[j+1];		// t or y
		int width = texturepack_texcoords[j+2];
		int height = texturepack_texcoords[j+3];
	}
	
6. uvcoord_filename.txt -> same as above (parse it yourself. ;*))



OPENGL

To load the autogenerated coordinates in OpenGL use something like this:
	for ( i = 0; i < numframes; i++)
	{
		int j = i * 4; // texcoords array is u_off, wid, hei
		sprite[i].textureID = textureID;
		sprite[i].width = texcoords[j+2];
		sprite[i].height = texcoords[j+3];
		sprite[i].u_off = texcoords[j] / (float)width;				// set x-coord
		sprite[i].v_off = texcoords[j+1] / (float)height;			// y-coord
		sprite[i].u_width = texcoords[j+2] / (float)width;			// set x-coord
		sprite[i].v_height = texcoords[j+3] / (float)height;		// y-coord

	}


LIMITATIONS:

1. Only one texture pack per spritesheet



TODO:

Resolve all the LIMITATIONS


FAQS:

What this does?
	This is a program to pack multiple textures in one single
	big texture (preferably power of 2)

Why make this?
	I need a texture packer for my DS game (Space Impakto DS)
	Link: http://rel.betterwebber.com/junk.php?id=101
	And I cannot find an 8 bit texture packer

Why pack my textures?
	1. For speed in rendering on HW based renderings.
		ie: Less glBindTexture
	2. Lessens memory use.
	3. Spritesheets are easier to manage since this application
		also spits out UV coordinates in C/CPP, BASIC and TEXT.

What is the license for the sources?
	I'm releasing the source via the "use or abuse" license.


Credits:

Richard Eric M. Lope BSN RN (code/sprites)
Adigun Azikiwie Polack (sprites)
Jim Scott (Original Heuristic/Algo for lightmap packing)
v1ctor and co. (Freebasic)
Simon Nash aka yetifoot for fbPNG
Jean-Jacques Druelle (Panoramic)
MS and NTS for Portable VB 6 (Wow! Last time I used this(VB4) Kobe Bryant was still in High School)



Changes

ver 0.5(07-15-2012) Happy Birthday Mom! 
* Added ability to set margins between sprites
* New VB6 based GUI (no choice here since it's the only RAD tool this laptop has)
* Added an ability to choose images folder in the GUI

ver 0.4
* Added png support

ver 0.3
* Added support for 32 bit (also converts from 8 bit to 32 bit) images.
* Added GUI launcher.

ver 0.2
* Added a horizontal BMP index for programmer's use to easily 
	reference the images.

ver 0.1 
* Initial release