I am writing a custom mac window on which i draw stuff using Ogre gaming engine…I would like this window to be a child window of a juce component…
I looked at the juce OpenGL Component code and decided i would need a component somewhat similar…I find that in the OpenGL component “createOpenGLContext” there is no window being created for Mac…Any particular reason why this is done?
What I tried is creating a new Mac window(on which i draw using Ogre later) using HIViewComponentPeer and setting this as a child of my top level component
Here’s the code snippet of what Im doing…
void* juce_createOgreContext (MyOgreComponent* component)
jassert (component != 0);
HIViewComponentPeer* const parentPeer = dynamic_cast <HIViewComponentPeer*> (component->getTopLevelComponent()->getPeer()); if (parentPeer == 0) return 0; OgreContextInfo* const oc = new OgreContextInfo(); HIViewComponentPeer* const peer = new HIViewComponentPeer (component, parentPeer->getStyleFlags(),parentPeer->viewRef); int i = 0; AGLPixelFormat pixelFormat; GLint attribs[ 20 ]; attribs[ i++ ] = AGL_NO_RECOVERY; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_ACCELERATED; attribs[ i++ ] = GL_TRUE; attribs[ i++ ] = AGL_RGBA; attribs[ i++ ] = AGL_DOUBLEBUFFER; attribs[ i++ ] = AGL_ALPHA_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_STENCIL_SIZE; attribs[ i++ ] = 8; attribs[ i++ ] = AGL_DEPTH_SIZE; attribs[ i++ ] = 32; attribs[ i++ ] = AGL_NONE; pixelFormat = aglChoosePixelFormat (0, 0, attribs); oc->_pixelFormat = pixelFormat; oc->_renderContext = aglCreateContext (pixelFormat, 0); aglSetDrawable ((AGLContext)oc->_renderContext, GetWindowPort (peer->windowRef)); oc->_nativeMacWindow = peer; oc->_windowHandle = peer->windowRef; oc->_nativeMacCarbonHandle = peer->viewRef; return oc;
I see that this new window is independent and not a child of the top level component…Am I doing something wrong?