How to structure texture loading?

I know the basics of texture loading and all, but how should I structure it? I’ve been looking at slick2Ds way and it seems kinda… specific. I don’t really want 20 different enum types just for basic interpolation specification. I was also thinking of how I would structure sprite sheets, which would be a pain to implement with the current ‘mesh’ system (variable shapes and all). Is there any real good way to structure a texture loading system? Also, how would I go about storing square texture-uvs for ‘meshes’ to manipulate?

EDIT: By “square texture-uvs”, I mean when I use sprite sheets and want a mesh to transform its texture-uvs to match the correct ‘sub-texture’. But I can’t think of a way to to that.

Lets say you have a UV for your mesh that is already normalized into the range of 0…1, and you have a spritesheet which contains that texture.
To transform the Mesh-UV so it takes its texture from a given spritesheet-piece, do this:


vec2f[] meshUV = ...?; // The UV of your Mesh.
rectangle spriteUV = ...?; // Section of the spritesheet you want to use

// make a copy of your Mesh-UV (you dont have to, but its better in some cases to not override your original data)
vc2f finalUV = copy(meshUV);

// Transform the UV
for(int i = 0; i < meshUV.length; i++)
{
    finalUV[i].x = linearInterpolation(spriteUV.minX, spriteUV.maxX, meshUV[i].x);
    finalUV[i].y = linearInterpolation(spriteUV.minY, spriteUV.maxY, meshUV[i].y);
}

// done!

I hope this helps.

Have a nice day!

  • Longor1996