Jump to content
  • Advertisement
Sign in to follow this  
Bonehed316

Wrapping the texture class

This topic is 4929 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Maybe this is a silly question, but what is a good way to make a wrapper for a texture class? For example, a class that loads a bitmap image (or other format) and stores the data some way, which can then interface with an API, such as d3d, to copy the data to a newly created texture. I guess what I'm looking for is a way to read data from an image file without using any of the interfaces directly associated with an API.

Share this post


Link to post
Share on other sites
Advertisement
A better [and more common] way I hear is to simply declare an interface class [pure virtual class in c++, others in others]. You'll still be using API loading features, but the program can simply use the interface class, and ignore how it's implimented.

For example, you would have a base class "texture_loader" or whatever, that defines the functions that "d3d_texture_loader" and "opengl_texture_loader" would need to impliment. The only time you need to know the implimentation is when you create the object [from what I hear, you don't even need to know then if you're clever], the game itself would always use the base class.

Share this post


Link to post
Share on other sites
Thanks.

That is one way, for sure. And that will probably be what I do in the short term while testing, but I also want to develop my own proprietary file format which holds data such as textures and models, sound, or whatever else (potentially all types in one file). That way I can save space by compressing data and other features later on (way later, heh).

What I was looking for was the FILE struct, found in stdio.h (I think that's where it is). I stumbled on to it earlier, I think I can use it to do what I intend. I'm also curious if using these STL features is a good idea (clearly it's more complicated than just using the d3dx load interfaces). I'm trying to design with flexibiltiy in mind, and to avoid being OS dependant, so I want to avoid using platform specific code in my base classes, as much as possible. I also dont want a bunch of bitmaps or jpg files laying around, it's fine for now, but having them in packages is much nicer, though that can come later. I'm hoping to progress from loading image files in my engine and passing the data to the 3D API to packing data in packages, and loading from those packages, and sending that data to the API.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!