i want to draw in two NSOpenGLViews in a Cocoa App using XCode, different things in each view. i think i have to use NSOpenGLContext, and the method SetView. but i have not found how to use this exactly. where i have to use this calls? which is the right way to do it?
Asked
Active
Viewed 286 times
1
-
What have you tried? What does your code look like? You haven't given us enough information to answer your question. Usually, you don't need to do anything in particular. You just create 2 `NSOpenGLView` sub-classes and then put one of each in your window. – user1118321 Aug 28 '12 at 03:03
-
I have created two sub-classes of NSOpenGLView, MyOpenGLView1 and MyOpenGLView2. In MyOpenGLView1 i draw a falling object (no problem), in MyOpenGLView2 i have to draw the velocity/time graphic of the falling object. so in MyOpenGLView2 i need to have access to the values of some of my variables defined in MyOpenGLView1 (this is my problem), such as Time and Velocity to be able to draw the velocity/time graphic. – user1621592 Aug 28 '12 at 23:39
-
i tried to import MyOpenGLView1 into MyOpenGLView2 using #import, and making an object to have access to the variables: MyOpenGLView1 *Variables, but i couldnt do it. Which is the right way to be able to use this variables in both classes? i am just a beginner, i will appreciate your help. – user1621592 Aug 28 '12 at 23:40
1 Answers
-1
It sounds like what you need to use is a Model/View/Controller pattern. You should put your data (the variables in MyOpenGLView1
) into a model object. Both the OpenGL views should then access that model object. This is a common way to separate out the functionality of your application from the presentation.

user1118321
- 25,567
- 4
- 55
- 86