Original Post
So I have these two classes, one is called OpenGLOperations and the other is called BSPManager. The first handles all the OpenGL things such as set-up, rendering of 2D and 3D data, it is what is actually called from the main program loop to render each frame. The BSPManager class loads in a .bsp file that stores all the 3D data from vertices to BSP trees to texture data, ect. The important thing about it here though is that it contains the logic for rendering all this data. The BSP tree traversal, the PVS decompression, and the texture orientations and such. Right now I have OpenGLOperations calling bspManager.renderLevel(); which calls a bunch of private functions and performs hidden surface removal and all. In these actual functions I directly reference OpenGL methods and the actual geometry rendering is done in these functions. It works well but the issue is, 1) I know this is poor software design, and 2) I want to break the BSPManager off into it’s own API independent project. So my only idea is to construct some sort of massive list of vertices & texture coords and such from the rendering logic (i.e. hidden surface removal) contained in the BSPManager and return a pointer to it to the OpenGLOperations class which would then render it. But this seems like a messy and potentially very slow method. Not to mention it hasn’t really been fully thought out and would no doubt have a large set of complexities keeping all that data associated with what it is suppose to be associated with. My other idea would be for your graphics API class to have to implement an interface specifying methods such as renderPolygon() which by storing a parent reference to the API class, the BSPManager would do all the render logic, then each time it found a polygon it wanted to render, would call this method just passing said polygon as a argument. Then it would be up to the API classes method to actually handle the presentation of the data. Roughly the same effect as the first solution just perhaps a bit more elegant? I don’t know…. How is this done normally? Any ideas?