I’m not sure if I should have posted this in the forum for GLUT, but since this is probably a basic beginner question, I posted here instead.
I was using OpenGL and Freeglut with Visual Express C++ 2010 to program Pong. Several days ago, I made some minor edit (I can’t remember what this edit was, to be honest, since I only compiled the code the next morning). When I did, however, I received this runtime error on the line glutDisplayFunc:
Unhandled exception at 0x1000bbae in Pong.exe: 0xC0000005: Access violation writing location 0x000000a8.
I messed with my code and checked my pointers, but nothing was out of the ordinary. I decided to create a new project, and even in the new project, I had this same error. I removed all unnecessary code and found that something this simple (code posted below) caused the error I was experiencing. (I am aware that this code will probably not work due to the lack of many necessary parts, but at the moment, I am only interested in solving the particular issue, so I have eliminated as much as I can for simplicity’s sake.)
This leads me to believe that I may have installed Freeglut incorrectly, or something like that. I hope somebody can help me solve this frustrating issue. Thanks in advance!
Code:
#include <gl/freeglut.h>
using namespace std;
void mainDraw() {
}
int main(int argc, char** argv) {
//Initialize GLUT
//glutInit(&argc, argv);
//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
//glutInitWindowSize(windowwidth, windowheight);
//initSetup(); //Initialize rendering
glutDisplayFunc(mainDraw);
//glutKeyboardFunc(handleKeypress);
//glutKeyboardUpFunc(handleKeyup);
//glutSpecialFunc(handleSpecial);
//glutSpecialUpFunc(handleSpecialUp);
//glutReshapeFunc(handleResize);
//glutTimerFunc(25, update, 0);
//glutMainLoop();
return 0;
}
By the way, this error still appears when any of the glut event functions (glutDisplayFunc, glutKeyboardFunc, etc.) are uncommented, not just glutDisplayFunc.