0

I have reinstalled devcpp 4.9.9.2 on windows xp virtualbox and installed glut and glew.

My original program just used glut, and shows some spheres bouncing around a room. My problem is that once I add in the line

glGenFramebuffers(1, &myBuffer);

my program fails to run. It compiles just fine. But when I run it says "Ass1.exe has encountered a problem and needs to close. We are sorry for the inconvenience.".

If I comment out this line then it works just fine, with balls bouncing around. The glGenFramebuffers is at the bottom of my setup method.

Here is a link to my code. https://dl.dropboxusercontent.com/u/13330596/Exercise1.cpp


This is the code just before I now call glewInit();

// Initialize GLUT.
glutInit(&argc, argv);

// Set display mode with an RGB colour buffer, double buffering and a depth buffer..
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); 

// Set OpenGL window size
glutInitWindowSize(1000, 1000);

// Set position of OpenGL window upper-left corner
glutInitWindowPosition(100, 100); 

// Create OpenGL window with title
glutCreateWindow("Dissertation");


glewInit();

1 Answers1

3

You must call glewInit(); before you can use extended functionality. Probably you didn't so the functions pointers are still null pointer. glewInit must be called after a context has been created and bound. In the case of using GLUT this is right after glutCreateWindow(…);

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I have added glewInit(); just after glutCreateWindow(); and rather than the program crashing straight away, something flashes up and then it crashes. Seems like slight progress – Adam Kenworthy Apr 28 '13 at 12:19
  • @AdamKenworthy: Well, now you have to debug the problem. Print status a log to stderr `fprintf(stderr, …)` of each and every action. Also if you don't know already, learn how to use a debugger. Getting stack backtrace of the moment of the crash is extremely usefull. – datenwolf Apr 28 '13 at 12:24
  • It crashes so early on that debug doesn't actually show anything at all. I see a flash of a window and that's it. If I comment out glGenFramebuffers(1, &myBuffer); it runs like normal, but otherwise it crashes. – Adam Kenworthy Apr 28 '13 at 12:36
  • you should set glInit to be experimental .It is stupid old thing glut never fixed.Anyway I would suggest you to use GLFW instead... – Michael IV Apr 28 '13 at 12:40
  • @MichaelIV I have added "glewExperimental = GL_TRUE;" but now I do not get the flash of a window before crashing. – Adam Kenworthy Apr 28 '13 at 12:47
  • @AdamKenworthy: If you start the program in a debugger the logging output should persist and the debugger should interrupt the program at time of the crash, so that you can inspect it. – datenwolf Apr 28 '13 at 12:56
  • What OpenGL version your card support?Have you checked for framebuffer extension ,that it is supported? – Michael IV Apr 28 '13 at 12:57
  • I have moved glew32.dll into windows/system and windows/system32. This means that the exe now runs!! – Adam Kenworthy Apr 28 '13 at 12:58