Hi I am trying to get proper UIView and UIViewController from SDL Window
and pass it to Ogre but the program crashes with [SDL_uikitopenglview
setMWindowName:]: unrecognized selector sent to instance 0xa213940. I am
not sure if I am doing it properly. My code is below.
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("Could not initialize SDL\n");
return 1;
}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_EGL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_DisplayMode displayMode;
SDL_GetDesktopDisplayMode(0, &displayMode);
SDL_Window* window = SDL_CreateWindow(NULL, 0, 0, displayMode.w,
displayMode.h, SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN |
SDL_WINDOW_RESIZABLE);
SDL_GLContext glContext = SDL_GL_CreateContext(window);
SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
SDL_GetWindowWMInfo(window,&wmInfo);
//Objective-C
UIWindow * appWindow = wmInfo.info.uikit.window;
UIViewController * rootViewController = appWindow.rootViewController;
UIView * myView = [appWindow.subviews objectAtIndex:0];
//Passing the handles to Ogre
Ogre::NameValuePairList params;
params["externalWindowHandle"] =
Ogre::StringConverter::toString((unsigned long)appWindow);
params[“externalViewHandle”] =
Ogre::StringConverter::toString((unsigned long)myView);
params[“externalViewControllerHandle”] =
Ogre::StringConverter::toString((unsigned long)rootViewController);