NSOpenGLView in Cocoa

Started by
-1 comments, last by Samith 12 years, 4 months ago
Hey guys, for my own entertainment I've been attempting to develop some simple OpenGL apps on my Macbook.

I've been following tutorials (this tutorial specifically) and I can't seem to get anything to work. In the "Drawing to an NSOpenGLView class" section, they tell you to drag an NSOpenGLView object onto your window in the IB and set it's class to your MyOpenGLView class. The MyOpenGLView class is a subclass of NSOpenGLView with only the -drawRect function overridden to clear the screen and draw a single triangle. My overridden -drawRect function gets called, but the view remains white, when it should be displaying a triangle on a black background.

If, instead of dragging an NSOpenGLView object onto my window, I drag a "Custom View" object and set its class to MyOpenGLView class (I do not change any code at all), everything works fine.

I'm pretty hesitant to jump on a solution without understanding why, exactly, my solution actually solves anything. Can anyone tell me why it is that the NSOpenGLView object does not work whereas the custom view object does (even without changing any code at all!)? I haven't been able to find any satisfactory answers by googling, though maybe I just don't know what to google.

As always, any help is appreciated!

This topic is closed to new replies.

Advertisement