I am practicing some opengl code, how ever when i want to force the opengl context to use a certain version of opengl through glutInitContextVersion() it fails compilation process and gives this message:-
use of undeclared identifier 'glutInitContextVersion'
i want to fix this issue so i kept my code as simple as possible
code
#include "File.h"
#include <GLUT/GLUT.h>
#include <OpenGL/OpenGL.h>
using namespace std;
int main ()
{
glutInitContextVersion(3,2);
return 1;
}
However i was able to use other glut functions without any error or warning messages
I am running Xcode 4.4.1 on Macbook air with OS X 10.9.1
You can create a 3.2+ core profile context with the GLUT that comes with the Xcode version for OS X 10.9. You just have to use a different interface. Instead of calling glutInitContextVersion()
, you need to add the GLUT_3_2_CORE_PROFILE
flag to the glutInitDisplayMode()
call:
glutInitDisplayMode(... | GLUT_3_2_CORE_PROFILE);
You will also need to include <OpenGL/gl3.h>
before <GLUT/glut.h>
to use GL3 and later features.
The whole thing will generate a bunch of compiler warnings since GLUT is marked as deprecated in OS X 10.9. My answer to a related questions contains instructions on how to disable those warnings: Glut deprecation in Mac OSX 10.9, IDE: QT Creator.