trying to use the code from an online book to learn OpenGL. i'm using Dev-C++, because i can't find a good way to get GLUT into VS 2008 PRO without muckin about in C:\windows\system32 which i try to stay away from. (any suggestions appreciated)

so this is the code:

#include <GL/glut.h>
// Initial square position and size
GLfloat x1 = 0.0f;
GLfloat y1 = 0.0f;
GLfloat rsize = 25;

// Step size in x and y directions
// (number of pixels to move each time)
GLfloat xstep = 1.0f;
GLfloat ystep = 1.0f;

// Keep track of windows changing width and height
GLfloat windowWidth;
GLfloat windowHeight;

///////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT);

       // Set current drawing color to red
    //           R     G       B
    glColor3f(1.0f, 0.0f, 0.0f);

    // Draw a filled rectangle with current color
    glRectf(x1, y1, x1 + rsize, y1 - rsize);

    // Flush drawing commands and swap
    glutSwapBuffers();
    }

///////////////////////////////////////////////////////////
// Called by GLUT library when idle (window not being
// resized or moved)
void TimerFunction(int value)
    {
    // Reverse direction when you reach left or right edge
    if(x1 > windowWidth-rsize || x1 < -windowWidth)
        xstep = -xstep;

    // Reverse direction when you reach top or bottom edge
    if(y1 > windowHeight || y1 < -windowHeight + rsize)
        ystep = -ystep;

    // Actually move the square
    x1 += xstep;
    y1 += ystep;


    // Check bounds. This is in case the window is made
    // smaller while the rectangle is bouncing and the
    // rectangle suddenly finds itself outside the new
    // clipping volume
    if(x1 > (windowWidth-rsize + xstep))
        x1 = windowWidth-rsize-1;
    else if(x1 < -(windowWidth + xstep))
        x1 = - windowWidth -1;

    if(y1 > (windowHeight + ystep))
        y1 = windowHeight-1;
    else if( y1 < -((windowHeight)–rsize+ystep) )
    y1 = -windowHeight + rsize -1;


     // Redraw the scene with new coordinates
    glutPostRedisplay();
    glutTimerFunc(33,TimerFunction, 1);
    }


///////////////////////////////////////////////////////////
// Setup the rendering state
void SetupRC(void)
    {
    // Set clear color to blue
    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
    }


///////////////////////////////////////////////////////////
// Called by GLUT library when the window has changed size
void ChangeSize(GLsizei w, GLsizei h)
    {
    GLfloat aspectRatio;

    // Prevent a divide by zero
    if(h == 0)
        h = 1;

    // Set Viewport to window dimensions
    glViewport(0, 0, w, h);

    // Reset coordinate system
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    // Establish clipping volume (left, right, bottom, top, near, far)
    aspectRatio = (GLfloat)w / (GLfloat)h;
    if (w <= h)
        {
        windowWidth = 100;
        windowHeight = 100 / aspectRatio;
        glOrtho (-100.0, 100.0, -windowHeight, windowHeight, 1.0, -1.0);
        }
    else
        {
        windowWidth = 100 * aspectRatio;
        windowHeight = 100;
        glOrtho (-windowWidth, windowWidth, -100.0, 100.0, 1.0, -1.0);
        }

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

///////////////////////////////////////////////////////////
// Main program entry point
int main(void)
    {
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutCreateWindow("Bounce");
    glutDisplayFunc(RenderScene);
    glutReshapeFunc(ChangeSize);
    glutTimerFunc(33, TimerFunction, 1);

    SetupRC();

    glutMainLoop();
    }

and i get a few errors
64 stray '\150' in program
64 expected ')' before "rsize"
expected ')' before ';' token

i don't see any mismatched parenthesis, and i don't know what \150 means, so i could use some help.

thanks

(my first post in a while, has to have been a month or a few since my last real question)

Wow, that was a problem I never encoutered before, but I solved it :)

This piece of code

else if( y1 < -((windowHeight)–rsize+ystep) )
    y1 = -windowHeight + rsize -1;

should be replaced with this:

else if( y1 < -((windowHeight)-rsize+ystep) )
    y1 = -windowHeight + rsize -1;

Yes, I know it looks the same, but the minus (-) in the first snippet is not really a minus (ascii-45/2d). So replace the minus with a minus and the code should compile :)
Small problem, but a bit hard to find ;)

commented: Good catch. +17
commented: big help thanks! +1
commented: Good catch on a really odd problem! +6

Thats a very weird error. Thanks

Wow thanks a lot, a miracle I found this thread! :)

thanks, this is the weirdest problem i have ever seen by the way

Thank you very much, I will never think of this solution.

commented: C'mon -1

I shall never think of it either.

And let us never speak of it again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.