Linking GLEW with CMake

Typical CMake scripts like FindGLEW will define variables that specify the paths and files that your project needs. If the script can’t automatically identify the correct paths (usually because of nonstandard install location, which is fine), then it leaves these variables up to you to fill in. With command line CMake, you use the -D … Read more

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

Using GLEW to use OpenGL extensions under Windows

Yes, the OpenGL Extension Wrangler Library (GLEW) is a painless way to use OpenGL extensions on Windows. Here’s how to get started on it: Identify the OpenGL extension and the extension APIs you wish to use. OpenGL extensions are listed in the OpenGL Extension Registry. Check if your graphic card supports the extensions you wish … Read more

Building glew on windows with mingw

To build it with MinGW, you should do (copied from the make log, with slight modifications and additional explanations): mkdir lib/ mkdir bin/ gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c gcc -shared -Wl,-soname,libglew32.dll -Wl,–out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 # Create library file: lib/libglew32.dll.a ar cr lib/libglew32.a … Read more