Sign in to follow this  
rick_appleton

Texture parameters

Recommended Posts

I'm currently rethinking my texture object design, and I was wondering how you handle different texture parameters. Basically I was thinking of having something like this:
struct CTextureObject
{
  unsigned int  texID;
  unsigned short  tileX, tileY, magFilter, minFilter;

  static unsigned int     currentBoundTexID;
  static unsigned short   currentTileX, currentTileY, currentMagFilter, currentMinFilter  
}

And then whenever a texture is bound, check if the static values are the same as the local values for that texture and if not update them (and call the relevant API calls). However this seems redundant as most textures will have the same values. I could maybe store the texture objects depending on the texture parameters somehow, and handle it from there.

Share this post


Link to post
Share on other sites
I don't think that storing that information in every texture object is a very efficient way to do it. The other idea was better: ie. have a texture manager that kept a sorted list with all the relevant info, or a scene manager which sorted geometry to be rendered with the most efficient order of textures. Later if you wanted to expand with a shader system, you could build that on (or into) the same system (because they behave very similarly I do believe). Just a thought.

--Buzzy

Share this post


Link to post
Share on other sites
for openGL:
tileX, tileY, magFilter and minFilter have local effect (are asociated with current binded texture, not enviroment). They are not global opengl states so you don't have to store them as as static and test them later.

edit:
if you need multitexturing you will need:
static unsigned int currentBoundTexID[ MAX_MULTITEXTURING_UNITS ];

Share this post


Link to post
Share on other sites
_DarkWing_: so you're saying that if I bind texture A, set tiling to repeat, then bind texture B, set tiling to no-repeat. And then finally set texture A to be used for rendering, the tiling option will be ON? I did not know that, it certainly solves the problem, since the problem is entirely sidestepped.

Thanks for the help.

Share this post


Link to post
Share on other sites
Quote:
Original post by rick_appleton
so you're saying that if I bind texture A, set tiling to repeat, then bind texture B, set tiling to no-repeat. And then finally set texture A to be used for rendering, the tiling option will be ON?

Yes. At least in OpenGL. But I doubt DX works any different.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this