Archived

This topic is now archived and is closed to further replies.

MtSMox

Texture identifiers and managers

Recommended Posts

I''ve recently moved from DirectDraw to Direct3D. 2D to 3D. This has given me some graphical advantages, but also some difficulties. Because in the past I could just load a graphic file by name. Although I still can, it''s a texture now and can''t be any size. So I decided to put multiple sprites in one texture. But now the hard part begins. I also wanted to make a texture manager to control loading of the textures. The texture manager would deal with 2 things: Textures and TextureParts. A Texture would be the actual texture, with info on which sprites are in it. A TexturePart would be such a sprite (with xoffset, yoffset, xsize, ysize). No I want to load a sprite. I have to tell which texture it is in and which part is it. So I made custom files. 1 texturefile: filename.bmp number_parts part_coords_1 part_coords_2 ... This is loaded by the texture manager the first time a texture is loaded. 2 texturepartfile: texturefile index So the texturepartfile is a kind of pointer to the texturefile. The texture manager checks if the texturefile is loaded and if it is it returns the texturepart belonging to the index. If it isn''t loaded the texturefile is loaded as above. This works, but now if I want to load a sprite I have to make files and I can''t identify it with one thing, I have to use 2: texture file and index. Is there another way to do this? (and if my method isn''t clear, just tell me and I''ll try to clarify) Mox

Share this post


Link to post
Share on other sites
not sure if i got that right but i think you want to get the texture (many sprites in one texture) _and_ the info what sprites are in the texture and where they are located (on the texture)

just store it all in one file

but be warned if you use more than one sub part/texture:
if you do bilinear filtering the edges may be blended from the neighburing part and also you cant repeat the sprite (not sure how this applies to d3d (i just do ogl) but i think it doesnt work there either)


mfg Phreak
--
"Input... need input!" - Johnny Five, Short Circuit.

Share this post


Link to post
Share on other sites
Yes I want that info, but I also want to be able to easily load sprites. And that's the part I don't know how to do. Maybe I could also give each sprite a ID so I can pass that ID to load a sprite?
So a texture file would look something like this:
picturefile.bmp
num_sprites
ID
x, y, sizeX, sizeY
ID
x, y, sizeX, sizeY
...

And I won't do any filtering with these textures, because they're all for 2D.

[edit]
but perhaps the ID method is just like the index method, because if a ID isn't loaded yet you have to know the texturefile the ID is in. So I still can't load a sprite with a single ID.
That is actually what I want: Load a sprite with a single ID (int or string).
So should I make a central file with all the texture files and ID's in them or something?
[/edit]

Mox

[edited by - MtSMox on July 28, 2002 9:31:11 AM]

Share this post


Link to post
Share on other sites