Good or Bad Idea - Placing Texture2D inside class

Started by
1 comment, last by brandf 14 years, 8 months ago
There probably is a better way all together but here's what I've been doing. I've been keeping my textures inside several dictionaries and each polygon can hold a string to a texture. When I look up textures I use the polygon's string. I was thinking, wouldn't it be easier to just use a reference to the texture I'm using and avoid the lookup in general?
Advertisement
Bah, nevermind silly question! If the mesh were to be saved the texture data would be lost.
Here is how it's normally done:

the game has a collection of TextureResource's which hold the d3d/opengl texture & the textures name as a string.

the game also has a collection of Meshes which each have a Material and some materials reference a TextureResource and/or the texture directly using a pointer.

if you want to save a mesh, you can find out the texture name by looking for the texture in your resource collection.

This topic is closed to new replies.

Advertisement