Results 1 to 5 of 5

Thread: Problems With First Tutorial

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    8

    Problems With First Tutorial

    It's sad when you copy/paste code and can't get it to work . I tried to compile the first segment of code from "The Red Book", but it didn't work. It's gotta be something wrong with setting up the workspace. Unfortunetely, the book gives no information on how to set up the code in the compiler. Anyway, here is the error message and the code.

    Compiling...
    MessinAround.cpp
    c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
    c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
    c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.

    3DGL.exe - 3 error(s), 0 warning(s)

    Here is the code from the tutorial.

    #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
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    london ont canada
    Posts
    25

    Re: Problems With First Tutorial

    if memory serves correctly, the windows.h needs to be included (before the GL/ headers).

    other than that, make sure you have the proper libraries (opengl32.lib and glut32.lib) in your linker list -- it'll more than likely be your next error

    [This message has been edited by dallas (edited 01-14-2001).]

  3. #3

    Re: Problems With First Tutorial

    Yeah i tried the code in my compiler and i got the same problem. But adding

    #include <windows.h>

    should fix your problem.
    _-__--___---___--__-_
    Yes, I have no life..

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    8

    Re: Problems With First Tutorial

    Thanks, yeah, that fixed it.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    2

    Re: Problems With First Tutorial

    actually the whole point of glut is to be platform independant

    remove gl\gl.h and just include gl\glut.h

    glut automatically includes glu.h and gl.h

Similar Threads

  1. Replies: 3
    Last Post: 01-08-2014, 06:39 PM
  2. Replies: 4
    Last Post: 09-01-2013, 02:47 PM
  3. Problems with online tutorial
    By otz0815 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-09-2013, 04:27 PM
  4. NeHe tutorial on Bitmap Fonts (tutorial 13) error
    By Mariusz in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-03-2012, 09:16 AM
  5. Tutorial
    By JasonThornton in forum OpenCL
    Replies: 11
    Last Post: 08-12-2011, 05:30 AM

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