Original Post
Hey everybody, I'm creating a tiny framework that will support rendering for OpenGL as well as for Direct3D9. Now I've created a GraphicsDevice class, an OpenGLGraphicsDevice (which is derived from GraphicsDevice) and a Direct3D9GraphicsDevice class (which also is derived from GraphicsDevice). This isn't really hard to accomplish but I want to make use of swap chains in Direct3D. This is because I need to render to multiple windows. In OpenGL this can be done by using multiple rendering contexts. Now I've come up with some example code that does the job (it does have some memory leaks though). This is the concept: The bind function will loop through a std::map and check if the handle already exists. If not, it will be registered and a swap chain will be created. In the OpenGL version, a new rendering context will be created and registered. Full sourcecode can be found here: http://waltertamboer.nl/Test.zip My question is; Are there people that have created such a framework before or are willing to take a look at my code to give me some tips to improve it. Or maybe anyone knows a better way to do this? [Edited by - WalterTamboer on July 5, 2007 1:50:31 AM]
while (Rendering)
{
Device->Bind(FirstHandle);
Device->Clear();
Device->BeginScene();
...
Device->EndScene();
Device->Present();
Device->Bind(SecondHandle);
Device->Clear();
Device->BeginScene();
...
Device->EndScene();
Device->Present();
}