Search code examples
c++windowsopenglcmakeglut

Setting up OpenGL library on windows


I'm totally new to OpenGL, so I'm trying to compile my application at home. At my university I have everything settle by my professor in the lab and there I use Linux. At home I'm using windows 8 with visual studio 2013.

I'm trying to build a sphere in my app which contain the includes below:

#include <GL/glut.h>
#include <math.h>
#include <iostream>

So, since it contains Glut.h I went to http://www.opengl.org/resources/libraries/glut/glut_downloads.php#2 to download the library and make it rock, but I had some problems.

I thought the windows version would come compiled and it didn't. The dlls are not inside the package as I expected to link them in my project properties so I tryed to use CMake to compile the glut but it didn't work. CMake returns to me the following log:

CMake Error: Cannot open file for write: C:/Program Files/Glut 3.7 Build/CMakeCache.txt.tmp
CMake Error: The source directory "C:/Program Files/Glut 3.7/glut-3.7" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Error: : System Error: No such file or directory
CMake Error: Unable to open cache file for save. C:/Program Files/Glut 3.7 Build/CMakeCache.txt
CMake Error: : System Error: No such file or directory

It says that the folder doesn't contain the CMake file.

My download link to glut (supposed to be windows, not sure cos of the error) is this http://www.opengl.org/resources/libraries/glut/glut37.zip

Normally I programm java, which I dont have so many headaches to setup the IDE..so take it easy please and now I ask:

What am I missing to make my OpenGL code run?


Solution

  • Your teacher should help you at the first place.

    I would like to inform you that GLUT library was abandoned since 1998. Last version is [3.7].But you are lucky!

    "freeglut" is alternative to the OpenGL Utility Toolkit (GLUT) library. Everything you need is here, I recommend reading it all.

    And to help you out, here you can find Windows binaries, look for link called: "Download freeglut 2.8.1-1 for MSVC".

    After download, you must link the library folder, include folder and copy freeglut.dll to you project folder (inside Debug or Release folder). You can find dll files inside a bin folder. And after that, you can call #include "GL/glut.h" with no problems.

    Good luck!