Skip to main content
gamedev.net
🔒 Locked

implementing textures

Started by jre2 1 reply 350+ views
Original Post
jre2
jre2
Hi, I have a question about implementing textures in my game. I know that one way to do it is to have a map array where each tile stores an integer value which tells us which texture goes there, for ex: map[10][10] = {1,1,2,2,1,1...}; etc... then, in our program, each integer represents a particular texture, and the textures can either be separate as in: 1 corresponds to grass.bmp, 2 corresponds to mountains.bmp or they can be stored in one large bitmap and have some sort of offset.... anyways, I was wondering how some games handle maps made by users that contain their own imported textures? It doesn''t seem like you can simply map to an integer like above. How can you ensure that each texture is mapped to a unique integer? Any ideas? Thanks, John
ancientcoder
ancientcoder
You could create two keys in your structure. One for the bitmap and then another for
a bitmap table.

For example a user creates a new map. The user assigns textures from your generic table.
Now they want to add new textures so you could now create a table based upon the name
of the user or something they type in. This is your bitmap table key.

Your structure now has the table name and the index key which is local to that bitmap
table.

Basically you can allow your user to create a library of textures. Of course it doesn''t
stop two users creating the same library name so you might want to take a different
approach which works around a GUID. A GUID is a unique key and there is a an API within
Windows that let''s you create one. This way you could use the GUID as a filename for
the libary that the user created. You could ditch the other key and use this alone but
it makes sharing Bitmap tables easier rather than one big table and stops you having
to create a GUID for each bitmap.

Of course,as always, it depends on your application.


Janju
Janju
Hi maybe this might intrest u ... i wrote it lately.
MapD3D.zip

It''s from a tutorial i am working on ... but i am a beginner also. I am trying to make a FFT engine with D3D but there is not much done yet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.