my simple game engine i'm working on has 2 image handling classes, one is i think g_spritesheet and the other is g_material or something along those lines, you can load stuff into spritesheet, specify a cell size, then load images into the other based on xx yy -- the xxth tile from the left and the yyth tile from the top, aswell, optionally telling it how many cells to take from
-it's not a great implementation, and i will probably combine the classes at one point and have g_material able to handle the functions
anyhow, the spritesheet is structured like this
{
GLuint tex;
GLubyte *data;
ILuint iltex;
public:
bool loaded;
unsigned int w;
unsigned int h;
unsigned int gridsize;
g_spritesheet(){loaded=0;};
g_spritesheet(char*,GLuint);
g_spritesheet(char*);
void load (char*,GLuint);
GLuint getimage();
GLuint getsprite(unsigned short,unsigned short);
GLuint getsprite(unsigned short,unsigned short,unsigned short,unsigned short);
void draw (int x, int y);
};
and the materials (its actually g_texture)
class g_texture
{
private:
char* name;
ILuint iltex;
GLubyte *data;
GLuint tex;
float xoffset, yoffset;
int w, h;
public:
bool loaded;
g_texture(char* nam, bool unused)
{
name=nam;
tex=0; w=0; h=1; loaded=0;
xoffset=0;
yoffset=0;
}
g_texture()
{
tex=0; w=0; h=1; loaded=0;
xoffset=0;
yoffset=0;
}
g_texture(char*);
bool compchars(char*);
void load(char*);
void load(g_spritesheet*,GLuint,GLuint);
void load(g_spritesheet*);
void draw(int,int); //int x, int y
void draw(int,int,float);//x, y, dir
void setoffset(float,float);
};
i'll probably redo both of these classes as i know what im doing a bit better now, but i hope it gives you an idea
if you want better explanation, just ask in this thread
if you want more code from my system, just send me a msg
edit: oh also these use PNG's loaded by DevIL
Edited by Ussyless, 18 February 2013 - 12:15 PM.