如何将 SDL 与 OGRE 结合使用?
当我使用 OGRE 和 SDL (如 本文),我似乎在主渲染窗口后面出现第二个窗口时遇到问题。基本上,我使用的代码是这样的:
SDL_init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
Ogre::Root *root = new Ogre::Root();
root->restoreConfig();
root->initialise(false);
Ogre::NameValuePairList windowSettings;
windowSettings["currentGLContext"] = Ogre::String("True");
Ogre::RenderWindow *window = root->createRenderWindow("MainRenderWindow", 640, 480, false, &windowSettings);
window->setVisible(true);
问题是,如何摆脱多余的窗口?
为了方便后代,我使用的是 OGRE 1.6.4、Mac OS X 10.6.2 和 SDL 1.2.14。
When I go to use OGRE with SDL (as described in this article), I seem to be having trouble with a second window that appears behind my main render window. Basically, the code I'm using is this:
SDL_init(SDL_INIT_VIDEO);
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
Ogre::Root *root = new Ogre::Root();
root->restoreConfig();
root->initialise(false);
Ogre::NameValuePairList windowSettings;
windowSettings["currentGLContext"] = Ogre::String("True");
Ogre::RenderWindow *window = root->createRenderWindow("MainRenderWindow", 640, 480, false, &windowSettings);
window->setVisible(true);
The question is, how do I get rid of the extra window?
Just for posterity, I'm using OGRE 1.6.4, Mac OS X 10.6.2, and SDL 1.2.14.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终自己解决了这个问题。问题最终是 OGRE 的 Mac GL 后端不支持 currentGLContext 选项,因此最好的解决方案是更改为 SDL 1.3(直接来自 Subversion,截至撰写本文时)并使用
currentGLContext >SDL_CreateWindowFrom
调用以开始从 OGRE 创建的窗口获取事件。还应该注意的是,OGRE 窗口需要将 macAPI 设置为 cocoa,否则 SDL 将无法识别窗口句柄。I ended up figuring this out on my own. The problem ends up being that OGRE's Mac GL backend does not honor the
currentGLContext
option, so the best solution is to change to SDL 1.3 (directly from Subversion, as of time of writing) and use theSDL_CreateWindowFrom
call to start getting events from a window created by OGRE. It should also be noted that the OGRE window needs to have themacAPI
set tococoa
, or else SDL won't recognize the window handle.我看到您已经解决了您的问题,但并非所有用户都会满足于将 SDL 降级到 1.3。您可以使用 SDL2 和通过 OGRE SDL_CreateWindow 创建的 SDL2 窗口。代码看起来像这样:
I see that you already solved your problem, but not all users will be content with downgrading SDL to 1.3. You can use SDL2 and an SDL2 window created via SDL_CreateWindow with OGRE. The code would look something like this: