Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: glutinit crashing, not initializing with minimalist code

  1. #1
    Intern Contributor
    Join Date
    May 2017
    Posts
    63

    glutinit crashing, not initializing with minimalist code

    In the following code my goal is to initialize without an error. I am using the simplest, most minimal code possible (as far as I know):
    Code :
    #include<GL/glut.h>
     
    int main(int argc, char *argv[])
    {
    	glutInit(&argc, argv);
    	return 1;
    }

    glut32.dll in same folder as .exe

    compiles fine, error:
    Lighthouse3d_initialize.exe stopped working

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,716
    Is your program 32-bit or 64-bit? What character set are you using? Unicode?

  3. #3
    Intern Contributor
    Join Date
    May 2017
    Posts
    63
    Quote Originally Posted by mhagain View Post
    Is your program 32-bit or 64-bit? What character set are you using? Unicode?
    I've never been asked the Unicode question: it has never been an issue. I've done a plethora of successful GL demos without that being an issue. How do I get you this information?
    I am pretty sure my program is 32 bit. How do I check this?

    .exe is x86
    glut32.dll is x86, as well
    Last edited by technologist; 10-22-2017 at 10:32 AM.

  4. #4
    Intern Contributor
    Join Date
    May 2017
    Posts
    63

    here it is:

    Amazingly, the addition of the following parameter completely resolved the problem and resulted in a running program:

    Code :
    #define GLUT_DISABLE_ATEXIT_HACK

    to

    Code :
    #include <iostream>
    #define GLUT_DISABLE_ATEXIT_HACK
    #include <GL/glut.h>
     
    int main(int argc, char *argv[])
    {
    	std::cout<<"Hello GL World"<<std::endl;
    	glutInit(&argc, argv);
    	return 0;
    }

    MUST put a copy of glut32.dll in the same folder as project .exe or the runtime error will continue but for a different reason.

    Here is the dummy argument version as above. But you have to add the #define GLUT_DISABLE_ATEXIT_HACK BEFORE #include <GL/glut.h>:

    Code :
    #include <iostream>
    #define GLUT_DISABLE_ATEXIT_HACK
    <GL/glut.h>
     
    int main()
    {
      int argc = 1;
      char *argv[1] = {(char*)"Something"};
      glutInit(&argc, argv);
    ...
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •