Thread: Compiling OpenGL (GLUT) on Linux

  1. #1
    Unregistered
    Guest

    Unhappy Compiling OpenGL (GLUT) on Linux

    I've just bought "OpenGL Programming Guide" 3rd ed.
    I'm trying to compile the very first program (see below) but can't figure out how to compile and build it. Which libraries must i include and how do I do it?
    I'm running RedHat 7.2 and I'm using the Anjuta IDE with gcc.

    Here's the complete source:
    Code:
    #include <GL/gl.h>
    #include <GL/glut.h>
    
    void display(void)
    {
    /*  clear all pixels  */
        glClear (GL_COLOR_BUFFER_BIT);
    
    /*  draw white polygon (rectangle) with corners at
     *  (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)  
     */
        glColor3f (1.0, 1.0, 1.0);
        glBegin(GL_POLYGON);
            glVertex3f (0.25, 0.25, 0.0);
            glVertex3f (0.75, 0.25, 0.0);
            glVertex3f (0.75, 0.75, 0.0);
            glVertex3f (0.25, 0.75, 0.0);
        glEnd();
    
    /*  don't wait!  
     *  start processing buffered OpenGL routines 
     */
        glFlush ();
    }
    
    void init (void) 
    {
    /*  select clearing (background) color       */
        glClearColor (0.0, 0.0, 0.0, 0.0);
    
    /*  initialize viewing values  */
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    }
    
    /* 
     *  Declare initial window size, position, and display mode
     *  (single buffer and RGBA).  Open window with "hello"
     *  in its title bar.  Call initialization routines.
     *  Register callback function to display graphics.
     *  Enter main loop and process events.
     */
    int main(int argc, char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
        glutInitWindowSize (250, 250); 
        glutInitWindowPosition (100, 100);
        glutCreateWindow ("hello");
        init ();
        glutDisplayFunc(display); 
        glutMainLoop();
        return 0;   /* ISO C requires main to return int. */
    }

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    well since as far as i know there is no official release for linux you will probably be using MesaGL, i've never used it(im unfortunatly stuck on windows) heres a link to their site you may find the info you need here

    http://www.mesa3d.org/

    ::edit::

    the guys on this message board will have better info than i can give im sure try here.

    http://www.opengl.org
    Last edited by no-one; 04-02-2002 at 01:42 PM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling a C program in Linux
    By hern in forum C Programming
    Replies: 14
    Last Post: 06-28-2004, 08:33 PM
  2. Code not compiling in Linux
    By CompiledMonkey in forum C++ Programming
    Replies: 5
    Last Post: 06-22-2004, 09:06 AM
  3. GLUT on Linux
    By bludstayne in forum Game Programming
    Replies: 4
    Last Post: 05-18-2004, 02:55 PM
  4. opengl Nehe tutorial errors when compiling
    By gell10 in forum Game Programming
    Replies: 4
    Last Post: 07-14-2003, 08:09 PM
  5. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM