I have a bit of a problem. I have a piece of code of a game seperated into two classes, one that handles textures and one that handles a game level (seperated into Texturehandler.cpp, Texturehandler.h and Gamelevel.cpp and Gamelevel.h) and the gamelevel handler needs to use some of the public functions of the texturehandler. The problem is the class prototype of the texturehandler uses some OpenGL specific types and a struct that also uses these types. Texturehandler.h contains:and Gamelevel.cpp contrains:Code:#ifndef _TEXHANDLER_H_ #define _TEXHANDLER_H_ enum E_texture_type { TEXTYPE_player, TEXTYPE_hud, TEXTYPE_level, TEXTYPE_monster, TEXTYPE_misc, }; struct S_texture_entry { GLuint texture_id; E_texture_type texture_type; int texture_inuse; char texture_name[80]; }; class TextureHandler { public: TextureHandler(); ~TextureHandler(); unsigned int GetTexture(const char* tex_file_name, E_texture_type tex_type = TEXTYPE_misc); void UseTexture(unsigned int entry_id); void MarkTypeAsUnused(E_texture_type unused_type); void ClearUnusedTextures(); private: unsigned int default_texture; S_texture_entry *entries; int entries_currentsize; GLuint LoadTGA(const char* tex_file_name); int CheckSize(int size); }; #endif // ifndef _TEXHANDLER_H_(well, it contains a lot more of course, but that is the important part)Code:#include "game_level.h" #include "texhandler.h"
This refuses to compile because Texhandler.h contains variables and functions of type GLuint, something that isn't defined in Gamelevel.cpp. I could fix this by including the OpenGL headers in Gamelevel.cpp, but obviously it doesn't make much sense that a game level class needs to know what sort of types the texturehandler class uses internally (the public interface of the texturehandler doesn't require any OGL specific stuff after all, and making the whole OGL interface invisible to parts of a program that don't need it is one of the good things about seperating code; it would make things tough on me as well if I later decide to add support for different renderers)
Would it be possible to make a seperate H file that contains only the interface of the class (an incomplete class prototype) and include that in the Gamelevel.CPP, and then include the complete class definition in Texturehandler.CPP?
Thanks in advance.
(my apologies if this had been asked before; I tried a few searches but didn't know what search terms to look for and the FAQ also didn't say anything about this; I also apologise for the long story, I couldn't really compress it any further)



LinkBack URL
About LinkBacks
) 



). I'll fix that inclusion guard tho', thanks for pointing that one out.