• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: design question: OpenGL and cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: design question: OpenGL and cocoa


  • Subject: Re: design question: OpenGL and cocoa
  • From: "Kenneth C. Dyke" <email@hidden>
  • Date: Fri, 11 Apr 2003 00:05:50 -0700

On Thursday, April 10, 2003, at 10:37 PM, email@hidden wrote:

I'm new to this whole object-oriented approach with OpenGL and was hoping get
some advice.

I have a view defined as:

@interface MyView : NSOpenGLView

This view is responsible for drawing an image on the screen. The image is
composed of multiple objects of different shapes. However instead of having the
view know about how to draw these shapes, I thought I would "ojectify" (is that
even a word?) them.

That's generally a good idea. ;)

So I have created the following model:
[code snipped]

and each of these objects overides the -(void)draw method and uses openGL to
draw the appropriate shape.

Thus the idea is that MyView's drawRect method will iterate over all the MyShape
objects it needs to draw and simply call the object's -(void)draw method.

Something to me doesn't feel right, and I am not sure what that is. I think it
might have to do with the MyShape objects not knowing about the context into
which it must draw to?

Actually, this is the ideal situation. If you can isolate the rendering code from needing to know about the context in which they are being drawn (except for such things as selection, maybe whether they are drawing bounding boxes or not, etc.), you'll be much better off if you ever want to provide multiple views of the same objects at the same time.

Each view might be responsible for showing your objects from a different camera position. So, you can have the view set up the appropriate modelview/projects transformation for the camera, and then have your objects draw themselves at the orientation/placement that they know about.

-Ken

Kenneth Dyke, email@hidden (personal), email@hidden (work)
Sr. Mad Scientist, MacOS X OpenGL Group, Apple Computer, Inc.
C++ is to C as Lung Cancer is to Lung
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Binary Differencer/Patcher for OS X?
  • Next by Date: toolbar item validation extremely inefficient
  • Previous by thread: design question: OpenGL and cocoa
  • Next by thread: Re: design question: OpenGL and cocoa
  • Index(es):
    • Date
    • Thread