Why SDL_TextureID? (Potential performance loss on looking up SDL_Texture ptr all over again)


Seems SDL_TextureID type is pretty unique for SDL 1.3, most of SDL functions expect pointers to structures, but texture functions expect SDL_TextureID which is just an unsigned integer.

I wonder what was the reason having SDL_TextureID instead SDL_Texture*?? Anyway it seems all texture related functions try to lookup SDL_Texture ptr from SDL_TextureID passed as parameter prior doing any processing. This makes me wonder why we loose precious CPU cycles all over again looking up those IDs. I know there’s nice hash table here, but still maybe we don’t need that at all?

First I thought SDL_TextureID is suppose to map directly to OpenGL/DX texture ID, but it’s now, maybe this was original intention of this data type when 1.3 was to be born… but now?

Wouldn’t it be better to drop this lookup table and pass/return SDL_Texture ptr there? And maybe have:
typedef SDL_Texture * SDL_TextureID; for sake of compatibility.

Then we could replace all those function returning width/height of textures with simple inlines.

Best regards,–