1

I am following a openGL tutorial which includes this function called "glutCreateWindow", my compiler (XCode 5 gcc, OSX) says it is deprecated.

What else option would be proper to replace these "glut*" related functions?

glutCreateWindow glutDisplayFunc glutMainLoop

?

fkkcloud
  • 167
  • 4
  • 11
  • @Claudiordgz: Those functions do not exist. GLUT is not part of OpenGL, it's a 3rd party library. And on MacOS you should not use GLX, since the X11 server there is not as well integrated as native OpenGL. – datenwolf Mar 15 '14 at 01:12
  • @datenwolf oh sorry, you are right on the gl, I just checked my code. I didn't know about the glx part though, thanks – Claudiordgz Mar 15 '14 at 01:21
  • So, what should I use to replace those kind of code? – fkkcloud Mar 16 '14 at 01:36

1 Answers1

1

As mentioned, those methods are deprecated. The best way to proceed is to create a proper Cocoa app. There are a few ways to create a Cocoa app that works via OpenGL. The simplest is probably to just create an app from the Application template in Xcode, and add a window that contains an NSOpenGLView.

user1118321
  • 25,567
  • 4
  • 55
  • 86
  • NSOpenGLView seems like an objective-c language. I hope to just know what would be the functions that I can use instead of those if I do the examples in c++ on OSX. – fkkcloud Mar 16 '14 at 05:15
  • `NSOpenGLView` just sets up an OpenGL context within a window for you to draw into. It is Objective-C-based, but that doesn't preclude you from writing all your rendering code in C++. – user1118321 Mar 16 '14 at 06:00
  • I am sorry but I still don't get it. So I include "NSOpenGLView.h" but it does not seem to import correctly. Should I set new frameworks "APPKit"? Could you give me a little instruction how to setup that NSOpenGLView lib and work with my c++ code (example for opengl tutorial) please? – fkkcloud Mar 16 '14 at 16:04
  • If you look at the part of the documentation I linked above titled "Drawing to an NSOpenGLView Class: A Tutorial", it describes step-by-step how to create a Cocoa app with an `NSOpenGLView` and how to draw to it. In your case, you can replace the `-drawRect:` method with calls to your C++ code to do the drawing. (Note that they say to name the file "MyOpenGLView.m", but if you name it "MyOpenGLView.mm" then you'll have an Objective-C++ file, which can call C++ code.) – user1118321 Mar 16 '14 at 16:18