Advertisement

OpenGL and something else

Started by March 25, 2002 05:55 PM
2 comments, last by yanivchik22 22 years, 11 months ago
I need to sweetch between OpenGL and DirectX(revolution3D.net) how can I do this? I have tried to do this right now and it''s work but when I want to back to OpenGL, it not initalize again please, help me...
Sorry, forgot to write, I do this in VB
Advertisement
Sorry, forgot to write, I do this in VB
I don't know anything about VB, but this it what I would do in C++

You have 1 base class let's name him CEngine, you derive 2 classes from him
CEngineDX for DirectX and CEngineOGL for openGL, these classes have
the same member functions (CreateWindow(),Init(),DrawScene(),Shutdown() for example)
which do the same, the only difference between them is they do it for
DX or OGL. In your main function you have a pointer to a CEngine object.
The main would look like this :


int main() //should be WinMain
{
CEngine* engine;
engine = new CEngineOGL; // or CEngineDX
engine->CreateWindow();
engine->Init();
while (!done)
{
engine->DrawScene();
}
engine->ShutDown();
}



To switch between OGL and DX you just call the ShutDown function,
deallocate memmory for the engine class, reallocate memmory for the
engine but for a different API, call CreateWindow and Init again and
finally let your main loop continue. In short delete the old window
and create a new one which supports whatever API you wan't.

I know this is not VB but I think you can aply the same principles
in VB (I'm assuming you can do OO in VB).

[edited by - George2 on March 26, 2002 3:18:30 AM]

[edited by - George2 on March 26, 2002 3:19:18 AM]
"THE INFORMATION CONTAINED IN THIS REPORT IS CLASSIFIED; DO NOT GO TO FOX NEWS TO READ OR OBTAIN A COPY." , the pentagon

This topic is closed to new replies.

Advertisement