tags:

views:

326

answers:

4

What's the bare skeleton to get a triangle drawn on an OpenGL window in C on OSX? I've gone through the tutorials at Nehe and tried to get it working, but the CreateGLWindow seems hopelessly tied to win32.

I want to stick to just opengl and glut, etc. I'll be eventually wrapping this in scheme, but I'd like to have a firmer understanding at the c-level beforehand.

Here's what I have thus far: http://gist.github.com/317241

Thanks!

A: 

Easiest way is to use Objective-C to get everything set up, then use C for drawing. (not the only way, GLUT is also an option.)

Sample code from Apple

cobbal
My main goal is eventually to wrap it up in scheme, but yes, I think understanding the Objective-C approach is important as well. I'll definitely read through the sample code from Apple - thank you!
Sean Grove
+2  A: 

NeHe has a tutorial for setting up an OpenGL window on Mac OS X with GLUT here. They also provide the code for all of the lessons for various different platforms. If you scroll to the bottom of lesson 2, you can download the lesson code ready to go for a number of platforms. You probably want either the GLUT sample or the Mac OS X/Cocoa sample.

Adam Rosenfield
Yeah, that may be the best way to go. I appreciate the heads up, I'll definitely read through them. I also found some pretty good resources for OpenGl development in C here http://www.opengl.org/resources/code/samples/simple/
Sean Grove
+6  A: 
Ned
+1  A: 

Hi Sean,

Here's the "hello.c" example from the OpenGL Red Book converted to R6RS Scheme:

http://gist.github.com/319363

That program runs in Ikarus Scheme and Ypsilon Scheme.

Notice that the 'import' form is referring to some 'agave' libraries. Those are available at:

http://github.com/dharmatech/agave

Agave is a project which provides a bunch of OpenGL demos and libraries for R6RS Scheme.

Ikarus and Ypsilon are both available for OS X.

Ed

dharmatech