2009-12-30 4 views
5

OGRESDL (this article에 설명 된대로)로 사용하면 주 렌더링 창 뒤에 나타나는 두 번째 창에 문제가있는 것 같습니다. 기본적으로 내가 사용하는 코드는 다음과 같습니다.SDL을 OGRE와 함께 사용하는 방법?

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를 사용하고 있습니다.

답변

7

나는 이것을 스스로 알아 냈습니다. 문제는 OGRE의 Mac GL 백엔드가 currentGLContext 옵션을 따르지 않기 때문에 가장 좋은 해결책은 (서면 작성 시점에 Subversion에서 직접) SDL 1.3으로 변경하고 SDL_CreateWindowFrom 호출을 사용하여 창에서 이벤트를 받기 시작하는 것입니다 OGRE가 만들었습니다. OGRE 창은 macAPIcocoa으로 설정해야하며 그렇지 않으면 SDL이 창 핸들을 인식하지 못합니다.

2

이미 문제가 해결되었지만 모든 사용자가 SDL을 1.3으로 낮추는 것에 만족하지는 않습니다. OGRE를 사용하여 SDL_CreateWindow를 통해 생성 된 SDL2 및 SDL2 창을 사용할 수 있습니다. 코드는 다음과 같습니다.

if (SDL_Init(SDL_INIT_VIDEO) != 0) { 
    OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "Cannot initialize SDL2!", 
     "BaseApplication::setup"); 
} 

Ogre::Root *root = new Ogre::Root(); 
root->restoreConfig(); 
root->initialise(false); 

Ogre::NameValuePairList params; // ogre window/render system params 
SDL_Window *sdlWindow = SDL_CreateWindow("myWindow", posX, posY, width, height, vflags); 
// see SDL_CreateWindow docs/examples for how to populate posX, posY, width, height, and vflags according to your needs 

SDL_SysWMinfo wmInfo; 
SDL_VERSION(&wmInfo.version); 
if (SDL_GetWindowWMInfo(sdlWindow, &wmInfo) == SDL_FALSE) { 
    OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, 
     "Couldn't get WM Info! (SDL2)", 
     "BaseApplication::setup"); 
} 

params.insert(std::make_pair("macAPI", "cocoa")); 
params.insert(std::make_pair("macAPICocoaUseNSView", "true")); 

// grab a string representing the NSWindow pointer 
Ogre::String winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.cocoa.window); 

// assign the NSWindow pointer to the parentWindowHandle parameter 
params.insert(std::make_pair("parentWindowHandle", winHandle)); 

Ogre::RenderWindow *ogreWindow = root->createRenderWindow("myWindowTitle", width, height, isFullscreen, &params); 
// see OGRE documentation on how to populate width, height, and isFullscreen to suit your needs 

// create OGRE scene manager, camera, viewports, etc