当前位置: 首页 > 工具软件 > OGRE > 使用案例 >

记录Ogre

子车灿
2023-12-01
// Do not add this to the application
RenderSystem *rs = mRoot->getRenderSystemByName("Direct3D9 Rendering Subsystem");
// or use "OpenGL Rendering Subsystem"
mRoot->setRenderSystem(rs);
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

You can use Root::getAvailableRenderers() to find out which RenderSystems are available for your application to use.
Once you have retrieved a RenderSystem, you can use the RenderSystem::getConfigOptions to see what options are available for the user.
By combining these two function calls, you can create your own config dialog for your application.

Creating a RenderWindow

Now that we have chosen the RenderSystem, we need a window to render Ogre in.
There are actually a lot of options for how to do this, but we will really only cover a couple.

If you want Ogre to create a render window for you, then this is very easy to do.
Add the following code to BasicTutorial6::go:

mWindow = mRoot->initialise(true, "BasicTutorial6 Render Window");

This call initialises the RenderSystem we set in the previous section.
The first parameter is whether or not Ogre should create a RenderWindow for you.

Alternatively, you can create a render window yourself using the win32 API, wxWidgets, or one of the many other Windows or Linux GUI systems.
A quick example of how to do this under Windows would look something like this:

// Do not add this to the application
mRoot->initialise(false);
HWND hWnd = 0;  // Get the hWnd of the application!
NameValuePairList misc;
misc["externalWindowHandle"] = StringConverter::toString((int)hWnd);
RenderWindow *win = mRoot->createRenderWindow("Main RenderWindow", 800, 600, false, &misc);

Note that you still have to call Root::initialise, but the first parameter is set to false.
Then, you must get the HWND of the window you want to render Ogre in.
How you get this will be determined entirely by the GUI toolkit you use to create the window (and under Linux I would imagine this would be a bit different as well).
After you have this, you use the NameValuePairList to assign the handle to "externalWindowHandle".
The Root::createRenderWindow function can then be used to create the RenderWindow class from the window you have already created.
Consult the API documentation on this function for more information.

 

 类似资料: