weixin_39595487 2020-11-30 03:02
浏览 0

[OGRE-290] Crash when giving an Ogre NSWindow* instead of NSView*

[reporter="RandomCitizen", created="Fri, 4 Oct 2013 23:10:22 +0200"]

I am creating a OpenGl Window using SDL 2

Take a lok at the following piece of code:

// The Sdl2 Window `sdlWindow` is created earlier

const bool USE_NSVIEW = true;

SDL_SysWMinfo windowInfo;
SDL_VERSION(&windowInfo.version);
SDL_GetWindowWMInfo(sdlWindow, &windowInfo);

if(windowInfo.subsystem != SDL_SYSWM_COCOA)
  throw Ogre::InvalidStateException(0,
    Ogre::String("Unexpeced SDL Window subsystem: ") + std::to_string(windowInfo.subsystem),
    "getOSSpecificWindowHandle",
    __FILE__,
    __LINE__);

NSWindow *window = windowInfo.info.cocoa.window;
size_t handle;

miscParameters["macAPI"] = "cocoa";

if(USE_NSVIEW)
{
  NSView *view = [window contentView];

  miscParameters["macAPICocoaUseNSView"] = "true";
  handle = reinterpret_cast(view);
}else
{
  miscParameters["macAPICocoaUseNSView"] = "false";
  handle = reinterpret_cast(window);
}

miscParameters["currentGLContext"] = "True";
miscParameters["externalGLContext"] = "True";
miscParameters["externalWindowHandle"] = Ogre::StringConverter::toString(handle, 0);

This code gives an NSView* pointer to Ogre and it just works fine. But when using the NSWindow* pointer itself by just setting the const bool USE_NSVIEW variable to false, ogre crashes.

该提问来源于开源项目:OGRECave/ogre

  • 写回答

5条回答 默认 最新

  • weixin_39595487 2020-11-30 03:02
    关注

    [author="masterfalcon", created="Mon, 14 Oct 2013 02:58:39 +0200"]

    The call stack would be quite helpful.

    However I have a feeling that it may crash on the mWindow = [mView window]; line in OgreOSXCocoaWindow.mm.

    评论

报告相同问题?