Just started with OpenGL

This is a discussion on Just started with OpenGL within the Game Programming forums, part of the General Programming Boards category; This is the tutorial I am looking at for Open GL. http://fly.srk.fer.hr/~unreal/theredbook/chapter01.html Here is the program I'm trying to get ...

  1. #1
    The Maverick Programmer
    Join Date
    Jan 2005
    Posts
    10

    Just started with OpenGL

    This is the tutorial I am looking at for Open GL.
    http://fly.srk.fer.hr/~unreal/theredbook/chapter01.html

    Here is the program I'm trying to get to work

    Code:
    #include <iostream>
    #include <gl.h>
    
    using namespace std;
    
    int main()  {
    
       glClearColor(0.0, 0.0, 0.0, 0.0);
       glClear(GL_COLOR_BUFFER_BIT);
       glColor3f(1.0, 1.0, 1.0);
       glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); 
       glBegin(GL_POLYGON);
          glVertex2f(-0.5, -0.5);
          glVertex2f(-0.5, 0.5);
          glVertex2f(0.5, 0.5);
          glVertex2f(0.5, -0.5);
       glEnd();
       glFlush();
    
       cin.get();
    }
    But I get a list of errors that stem, seemingly, from the same source. One such example is the following.

    " undefined reference to 'glClearColor@16' "

    I just started to look into OpenGL recently, and some help is greatly appreciated. And if anyone knows a better tutorial, other than cprogramming.com, then please do tell.
    Conformity in the Code is a Calculated error in Compilation.

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    56
    You'll have to compile your program with the OpenGL library.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Yeah it looks like you havent linked to the library

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    1,197
    I suggest you go over to http://nehe.gamedev.net
    That code you have there will never work.

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    the original code from your link looks like this.
    Code:
    #include <whateverYouNeed.h>
    
    main() {
    
       OpenAWindowPlease();
    
       glClearColor(0.0, 0.0, 0.0, 0.0);
       glClear(GL_COLOR_BUFFER_BIT);
       glColor3f(1.0, 1.0, 1.0);
       glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); 
       glBegin(GL_POLYGON);
          glVertex2f(-0.5, -0.5);
          glVertex2f(-0.5, 0.5);
          glVertex2f(0.5, 0.5);
          glVertex2f(0.5, -0.5);
       glEnd();
       glFlush();
    
       KeepTheWindowOnTheScreenForAWhile();
    }

    you cant just strip out the windowing parts
    also, you should #include <GL/gl.h>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 06:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21