How to have OpenGL as part of a window in OSX

Started by
4 comments, last by MARS_999 16 years, 2 months ago
I have been following NeHe's tutorials and they have been great. I am not interested in full screen mode and all of the tutorials have the GL context take up the entire window. I have tried unsuccessfully to make the gl context view smaller. Can anyone offer help on how to have the Open GL view take up only part of the window so I can have text, tables and other items in the window sa well? Thanks! WonderMellon
Advertisement
The GUI library Cocoa has an OpenGL object. You could also do it using wxwidgets or QT in which case you can target more than one platform.

Image Hosted by ImageShack.us<br/>
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
SpeciesUnknown,
Thanks for the reply. I am actually doing what you mentioned and have subclassed the NSOpenGLView. What I am having trouble with is the following snippet of code (I think)

glView = [ [ Lesson02View alloc ] initWithFrame:[ glWindow frame ]
colorBits:16 depthBits:16 fullscreen:FALSE ];
if( glView != nil )
{
[ glWindow setContentView:glView ];
[ glWindow makeKeyAndOrderFront:self ];
[ self setupRenderTimer ];
}
else
[ self createFailed ];

This creates the OpenGL view but makes it the size of the entire window and not just the size of the view in IB.
Its been awhile since I have coded on the Mac, but in IB you can make the OpenGL window whatever size you want and change the properties of the sub window if you may. IIRC you don't need to to do this with code, it all can be done in IB.
Thanks Mars_999. You are correct and I have, indeed, defined the size in IB. My problem is that the code to alloc the NSOpenGLView sets the view to the size of the entire window. I have not found a way to limit it to just the size of the view defined in IB.
I can tell you I have done this back when I was on Mac. You can try going to opengl.org in the OSX section and ask Onesadcookie he will know how to help you.

This topic is closed to new replies.

Advertisement