Results 1 to 2 of 2

Thread: glMainLoop() crashes

  1. #1
    Guest

    glMainLoop() crashes

    I am working on OpenGL on Linux with ATI Xpert 2000 and ATI 9550. I have downloaded Mesa-6.2.1. I am running a simple sample as follow:

    #include <stdio.h>
    #include <math.h>
    #include <strings.h>
    #include <unistd.h>

    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GL/glut.h>

    // Called to draw scene
    void RenderScene(void)
    {
    // Clear the buffer
    glClear(GL_COLOR_BUFFER_BIT);

    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glBegin(GL_POLYGON);
    glVertex2f(0.4, 0.4);
    glVertex2f(0.4, 0.9);
    glVertex2f(0.9, 0.9);
    glVertex2f(0.9, 0.4);
    glEnd();

    // execute drawing commands
    glFlush();
    }

    void SetupRC(void)
    {
    glClearColor(1, 0, 0, 0);
    }

    // Map the above rectangle coords to window system by glViewport
    // and glOrtho
    void ChangeSize(GLint w, GLint h)
    {
    glOrtho(0, 1, 0, 1, 0, 1);
    }

    int main(int argc, char *argv[])
    {
    glutInitDisplayMode(GLUT_SINGLE);
    /* A single-buffered window means that all drawing commands
    are performed on the window displayed. A double-buffered
    window means that the drawing commands are actually executed
    to create a scence offscreen and then quilckly swapped into
    view on the window.
    */

    // create a window
    glutInitWindowSize(800, 600);
    glutInitWindowPosition(2, 20);
    glutCreateWindow("GLRect");

    // initialize OpenGL states before rendering
    SetupRC();

    glutReshapeFunc(ChangeSize);
    printf("finish Reshape\n");

    // Diaplay or refresh window
    glutDisplayFunc(RenderScene);
    printf("finish RenderScene\n");

    // Processing all OS specific messages, keystrokes and so on.
    glutMainLoop();
    printf("finish Mainloop\n");
    exit (0);
    }

    I can build it, but crashes on glutMainLoop() when I run it. If I change glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) to glPolygonMode(GL_FRONT_AND_BACK, GL_LINE), It is OK.

    Can anybody know the reason? Thanks a lot.

    Kevin

  2. #2
    Guest

    Re: glMainLoop() crashes

    You need to call:
    Code :
    glutInit(&amp;argc, argv);
    before you call glutInitDisplayMode();

Similar Threads

  1. glGetUniformiv crashes on ATI?
    By imported_pjcozzi in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 12-16-2009, 12:25 PM
  2. Glu Tesselator Crashes!
    By glfreak in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-30-2008, 08:05 AM
  3. pc crashes
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 03-14-2002, 03:32 AM
  4. Crashes on GF3
    By Humus in forum OpenGL: Advanced Coding
    Replies: 31
    Last Post: 02-25-2002, 11:33 AM
  5. Quake III - Crashes
    By in forum OpenGL: User Software
    Replies: 4
    Last Post: 12-24-2000, 05:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean