XcodeGLUT tutorial problem :(

Post: #1
Can someone tell me what I did wrong with this code?
I got 33 errors:

#include <stdlib.h>

#include <GLUT/glut.h>

int lastFrameTime = 0;
float boxX = 0.0f;

void display(void)
    if lastFrameTime == 0
        lastFrameTime = glutGet(GLUT_ELAPSED_TIME);
        int now = glutGet(GLUT_ELAPSED_TIME);
    int elapsedMilliseconds = now - lastFrameTime;
    float elapsedTime = elapsedMilliseconds / 1000.0f;
    lastFrameTime = now;
    int windowWidth = glutGet(GLUT_WINDOW_WIDTH);
    boxX += 512.0f * elapsedTime;
    if (boxX > windowWidth)
        boxX -= windowWidth;
    glTranslatef(boxX, 0.0f, 0.0f);
    glVertex2f(   0.0f,  0.0f);
    glVertex2f( 128.0f,  0.0f);
    glVertex2f( 128.0f, 128.0f);
    glVertex2f(   0.0f,   128.0f);

void reshape(int width, int height)
    glViewport(0, 0, width, height);
    gluOrtho2D(0, width, 0, height);    

void idle(void)

int main(int argc, char** argv)
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
    glutInitWindowSize(640, 480);
    glutCreateWindow("GLUT Program");
    return EXIT_SUCCESS;
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
You didn't copy and paste it from the page, did ya.

putting parentheses around the top if statement fixes the problem. In future, post your errors -- just the code's not very helpful.
Quote this message in a reply
Post: #3
Shock I guess I overlooked that...

Thanks very much! Smile
Quote this message in a reply
Post Reply