Okay, I've been working on this Texture class that's going to be compatible with both SDL and OpenGL with the capability to create an array of textures within one class as opposed to multiple classes and such.
Now I've run into a slight issue if I want to return the value of a texture. There's two different types of textures: SDL_Texture, and a standard GLuint Texture. The problem I have is that one or the other is used, not both which is depending on whether or not the person is using OpenGL.
So when the user wants to get the texture, I need the ability to return either an SDL_Texture, or GLuint depending on whether or not OpenGL is being used.
I tried this with a template class, but it didn't work, but I'll post the code so you can see what I'm trying to do.
1 2 3 4 5 6 7 8 9 10 11
|
template <class Tex> Tex Texture::GetTexture(int TextureNumber)
{
if (TextureNumber > NumTextures || TextureNumber < 0)
return;
if (!Loaded[TextureNumber])
return;
if (UsingGL)
return GLTextures[TextureNumber];
else
return SDLTextures[TextureNumber];
}
|
It basically just comes down to the last four lines of code. If the person is Using OpenGL return a GLuint, if the person is using SDL, return an SDL_Texture.
I would prefer to have the GetTexture function to be one function instead of two separate ones so I don't have to call a different function every time to check if I'm using SDL or OpenGL.
Any help on how this can be done is greatly appreciated.