OGRECave / ogre

scene-oriented, flexible 3D engine (C++, Python, C#, Java)
https://ogrecave.github.io/ogre/
MIT License
3.91k stars 966 forks source link

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

Closed paroj closed 8 years ago

paroj commented 8 years ago

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

paroj commented 8 years ago

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

paroj commented 8 years ago

[author="randomcitizen", created="Fri, 18 Oct 2013 19:06:17 +0200"]

I will give you a callstack as soon as I am able to get my hands on a mac again. (I think this will be in one or two weeks - sorry for the delay )

paroj commented 8 years ago

[author="masterfalcon", created="Fri, 20 Dec 2013 08:41:30 +0100"]

Any chance of getting a callstack soon?

paroj commented 8 years ago

[author="randomcitizen", created="Sat, 21 Dec 2013 08:51:39 +0100"]

I will be able to get my hand on a mac again in the first week in January. sorry

paroj commented 8 years ago

in the !macAPICocoaUseNSView case the API expects a GL3PlusWindow instead of a NSWindow.