记录Ogre

// 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.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值