1
votes

I'm running into trouble setting up GLUT (3.7.6 binaries obtained from Nate Robins) on Windows 8 64bit with VS2012. The glut32.dll is copied to the SysWOW64 dir, both include and lib path are set in my project files and the libraries are set in the Linker->Input settings ("...;glut32.lib;glu32.lib;opengl32.lib;...").

My code looks like this:

#include <GL/glut.h>

void display()
{
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutDisplayFunc(display);
    glutMainLoop();
}

The build process is successful but the application crashes with the following error message:

Unhandled exception at 0x1000BBAE (glut32.dll) in HelloOpenGL.exe: 0xC0000005: Access violation writing location 0x000000A8.

The setup seems fairly simple. Any ideas what I'm missing?

1
this might be the same question - nj-ath
@TheJoker Yes. The first lines of code in the main function are exactly the same. The answer explains why this fails. - Chemistpp
Thanks for pointing in the right direction! See my answers for details :) - Christoph

1 Answers

2
votes

The call to glutDisplayFunc() without opening a window caused the crash. This is the updated code that opens a new window before passing the display function:

#include <GL/glut.h>

void display()
{
}

int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    //Set Display Mode
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    //Set the window size
    glutInitWindowSize(250,250);
    //Set the window position
    glutInitWindowPosition(100,100);
    //Create the window
    glutCreateWindow("Hello OpenGL");
    //Set the display function
    glutDisplayFunc(display);
    //Enter the main loop
    glutMainLoop();
}