Skip to main content
gamedev.net
🔒 Locked

Texture parameters

Started by rick_appleton Nov 30, 2004 at 8:13 AM 3 replies 1.4k views
Original Post
rick_appleton
rick_appleton
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.
Buzzy
Buzzy
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
_DarkWIng_
_DarkWIng_
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 ];
You should never let your fears become the boundaries of your dreams.
rick_appleton
rick_appleton
_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.
_DarkWIng_
_DarkWIng_
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.
You should never let your fears become the boundaries of your dreams.

Topic Locked

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

Sign in to reply to this topic.