Why does glGetString(GL_VERSION) return null / zero instead of the OpenGL version?

glutInit() doesn’t create a GL context or make one current. You need a current GL context for glewInit() and glGetString() to work. Try this: #include <GL/glew.h> #include <GL/glut.h> #include <cstdio> int main(int argc, char **argv) { glutInit(&argc, argv); glutCreateWindow(“GLUT”); glewInit(); printf(“OpenGL version supported by this platform (%s): \n”, glGetString(GL_VERSION)); }

Cmake link library target link error

The syntax for target_link_libraries is: target_link_libraries(your_executable_name libraries_list) And you don’t have to add add_definition statements (target_link_libraries adds this options) There are also some useful variables provided by OpenGL and GLEW packages. Your CMakeLists.txt should be like: cmake_minimum_required (VERSION 2.6) project (test) find_package(OpenGL REQUIRED) find_package(GLEW REQUIRED) include_directories(${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) add_executable(test main.cpp ) target_link_libraries(test ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES}) One important … Read more

Initializing OpenGL without GLUT

As luke noted, the code to create and bind the context is specific to each windowing platform. Here are some functions to get you started in terms of initializing OpenGL on specific platforms: Windows (a tutorial is here) wglCreateContext(hDC) Mac OS X — OS X has essentially three options: Carbon, Cocoa, and the underlying Core … Read more

Glut deprecation in Mac OSX 10.9, IDE: QT Creator

You can still use it in 10.9. They’re sending you a pretty strong signal that they want you to stop, though… You can disable those warnings with the -Wno-deprecated-declarations compiler option. There’s also some difficulties including the right headers if you’re trying to use GL3 level features, because you need to include gl3.h for that, … Read more

GLUT on OS X with OpenGL 3.2 Core Profile

You need at least Mac OS X Lion (OS X 10.7 or higher) for the basic support of OpenGL 3.2. To use the OpenGL 3.2 Core Profile, just add glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | … | …); in your main-function. You can check it by std::printf(“%s\n%s\n”, glGetString(GL_RENDERER), // e.g. Intel HD Graphics 3000 OpenGL Engine glGetString(GL_VERSION) // e.g. … Read more

GLUT exit redefinition error

Cause: The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h. Solution: Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code. #include <stdlib.h> #include <GL/glut.h>

Using the mouse scrollwheel in GLUT

Freeglut’s glutMouseWheelFunc callback is version dependant and not reliable in X. Use standard mouse function and test for buttons 3 and 4. The OpenGlut notes on glutMouseWheelFunc state: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability … Read more