开发者

Would like to learn how to use OpenGL within Objective-C, but have no idea where to start. Help? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

开发者_开发问答

Closed 9 years ago.

Improve this question

I have zero experience with OpenGL and a small amount of experience with Objective-C, but I'm fairly decent with C++. What resources should I be looking at to start learning how to use OpenGL within Objective-C?

I read somewhere at some point that starting out with NSOpenGLView is a good start.


Honestly, you're probably not going to need to know much Objective-C for dealing with OpenGL, just C. OpenGL is C-based, so you don't need to learn anything new, language-wise, to deal with it. Objective-C knowledge is only really necessary when you plan on using Cocoa to build up your interface. Even then, the language is not hard to pick up if you're coming from a solid C / C++ background.

I highly recommend the book iPhone 3D Programming that Matt's first resource is based on. Even though you're asking about desktop OpenGL, and this book covers OpenGL ES, much is shared between the two APIs. The book does a great job of starting with simple concepts and fundamentals, and then building to more advanced topics like environment mapping and custom shaders. The author uses C++ as his base language for the book, so you should be familiar with even the most complex code he shows. OpenGL ES is effectively a subset of OpenGL, so almost everything translates across to the desktop.

Within a desktop Cocoa application, you have two ways of presenting OpenGL content: NSOpenGLView and CAOpenGLLayer. The former is an older NSView subclass that you can customize to place your rendering code within. The latter is a Core Animation CALayer that also acts as an OpenGL rendering target, but it give you a little more flexibility in how you can overlay other items on top of the OpenGL content. Getting the display set up for your OpenGL rendering will not take a lot of effort, with most of your time being spent on your OpenGL code.

You might want to pick apart some of Apple's sample applications, such as GLSL Showpiece, Cocoa OpenGL, GLEssentials, and CubePuzzle, among the other OpenGL examples they have in the developer center.


Given your affinity for C++, this will probably be the most appealing resource for you. It covers OpenGL ES 1.1 and 2.0, so you'll get all you need to know.

Personally, I really enjoy this set of tutorials, which avoid C++ and are quite well written. It only covers 1.1, but that may be an easier place to start anyway.


NeHe's tutorials include full Cocoa versions of all the early tutorials.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜