Original Post
Hello everyone, I'll do a quick outline of what I'm using first. Microsoft Visual C++ Express Edition 2005. Mainly programming for Win32, though I plan to eventually port to Linux. I'm using OpenGL for graphics. I'd like a few suggestions on my engine design. It's not strictly a game engine, more like a graphics engine (That can be used for games, obviously). The whole engine is based on a hierarchal design (see example below). This makes it easy to program new parts to the Engine, as well as update the old. However, it also means there's very large include-trees (I think #including one .h file causes 10 other custom ones to be included at one point, which in turn includes even more standard .h files). I'll provide my texture management system as an example (though other parts are based on the same design, ie: geometry, sound, physics, network, etc). I have two low-level classes. One class is the 'buffer', which manages holding image data in system memory, as well as loading files from the hard drive. The other class is the 'Texture' class, which manages the OpenGL texture ID, and copying the data from system memory to the GPU. On the next level I have a class called 'hTexture', which requires both the 'Texture' and the 'Buffer' class to operate. It manages swapping the texture from the GPU/RAM/HD as needed. On the same level is the hGLSL class which manages GLSL shaders. Then, on the next higher level I have the 'Material' class, which, as it sounds, handles opengl materials. It combines multiple 'hTexture' classes for multitexturing, handles properties (glEnable), and requires the hTexture and hGLSL classes. I've spent 1.5 years programming the Engine, so redesign is not an option, however, I'd like any tips and comments about the above design. Is it good? Is there anything I should watch out for? Any interfaces I should provide to the end-user to make it easier to access? In theory, the end-user should only have to access the 'Material' class to make it all work. On a completely different note, my engine requires a WindowContext to be created to display the window, and create an OpenGL context. Some variables in it need to be shared with other classes, however, there may not be any opportunity to pass the WindowContext to the class as a pointer. Currently, my solution to this is to create a global pointer with the current active WindowContext class. However, to have multiple contexts requires switching between each context on a single thread. A more efficient solution would be to have multiple threads, each with its own WindowContext class. However, this makes a single global pointer to the current class unreasonable (as there could be multiple current classes at the same time). I've been reading about TLS (Thread local storage, via __declspec(thread) ). Is this a plausible method? Is there a better way than having a thread-specific global pointer? Thanks for reading my essay
I'll appreciate any feedback you may have, ~Zix