-1

I used to write OpenGL programs using GLUT in particular for the windowing which I was able to compile on Linux and Mac. Recently I have upgraded the Mac OS to Mountain Lion and installed the latest version of XCode. Of course things have changed drastically and now I need to compile with Clang (gcc is replaced by Clang++). It doesn't seem (reading another stackoverflow question) possible to use GLUT anymore and apparently it can be replaced by FreeGLUT or GLW?

GLUT on OS X with OpenGL 3.2 Core Profile

My question is: if I want to use OpenGL and need to have an easy/quick way of creating a window, an openGL context, etc., as we did before with GLUT, what's the best way of doing this now with Clang/XCode 4.5.2? I found really strange that I couldn't find information on the web regarding compiling OpenGL programs with Clang, and more information on a substitute to GLUT? Ideally, I'd like to keep compiling this code under Linux? Is it still an option to use GLX and write the window side of things myself? Can I still do that on the Mac?

Community
  • 1
  • 1
user18490
  • 3,546
  • 4
  • 33
  • 52

1 Answers1

1

The choice of compiler doesn't really matter. GLUT (also the old versions) should still work with Clang as the ABI didn't change. Also Clang can be used in Linux as well (AFAIK you can even compile the kernel using Clang).

MacOS X doesn't use GLX, it uses a Cocoa NSOpenGLView class instance (or some fullscreen API bypassing Cocoa).

Just keep doing what you already did and replace all calls to the compiler with the Clang variant.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Thank you for your answer. I tried that but it didn't find the GLUT library after this new install and I don't remember installing GLUT in the past. That's why somehow I was thinking GLUT was not part of the standard install with Mountain Lion anymore. And regarding GLX I understand what you are saying but I used in the past on MAC and I was able to get the same code compiled on Linux. My question was more, can I still do that? – user18490 Nov 22 '12 at 00:05
  • @user18490: GLUT is no longer shipped with OS X, yes. Also OS X used to ship with a X11 server, which of course supports GLX. However the OpenGL support you get by that is not feature complete. GLUT is not a very good framework anyway. I recommend you use GLFW, available at http://www.glfw.org – datenwolf Nov 22 '12 at 00:16
  • Thank you very much. It's very clear and helpful. It's a bit off topic now then, but is GLX still the best way of using OpenGL on Linux, or is old technology that shouldn't be used anymore? What would would be more recent? – user18490 Nov 22 '12 at 15:25
  • @user18490: As long as X11 is the standard graphics and windowing system used in Linux, as long will be GLX the way to go. And frankly, I don't think Wayland will be, what so many people promise. What's most likely to happen is that somebody (me?) will take a large amount of Wayland code, merge it into a KDrive X server to make a X11 system that's independent of vendor drivers and uses OpenGL / OpenVG as a backend for X core and XRender operations, but also command passthrough to the graphics state tracker. I wrote my sentiments about Wayland down at http://datenwolf.net/bl20110930-0001/ – datenwolf Nov 22 '12 at 15:35
  • However you are, I will vote for you if you do this! I can't believe that these days, what's probably the most important to interact with a computer (windowing, keyboard and mouse events) is not yet somehow better supported through some sort of unified API across all platforms. I understand why, I just think it's sad. The best so far is Qt and there's very little alternative if you don't want to use it. Thanks again for your answer. It was very valuable. – user18490 Nov 22 '12 at 19:18
  • For future reference I was able to install GLFW successfully on the Mac. Download the zip archive then do sudo make cocoa-install. To compile a program form the command line (example given in the doc) do: clang -framework OpenGL -framework Cocoa -framework IOKit -lglfw -L/usr/local/lib -o programname programname.cpp – user18490 Nov 22 '12 at 20:15