Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

openGL: 'gluOrtho2D' was not declared in this scope


  • Please log in to reply

#1
andreuboada

andreuboada

    New Member

  • Member
  • Pip
  • 1 posts
Hi!

Im Andreu and Im getting started with OpenGL. My operating system is Mac OS 10.6 and Im using Netbeans to write my C++ code.

I found this code in a Computer Graphics textbook. However, I have many compilation errors and Ive been surfing literally a myriad of forums and I dont know what to do.

#include <iostream>
#include <stdio.h>
#include <OpenGL/gl.h>

void myinit(){
    glClearColor(1.0,1.0,1.0,1.0);
    glColor3f(1.0,0.0,0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0,50.0,0.0,50.0);
    glMatrixMode(GL_MODELVIEW);
}

void display(){
    GLfloat vertices[3][2]={{0.0,0.0},{25.0,50.0},{50.0,0.0}};
    int i, j, k;
    int rand();
    GLfloat p[2]={7.5,5.0};
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_POINTS);

    for(k=0; k<5000; k++){
        j=rand()*3;
        p[0]=(p[0]+vertices[j][0])/2.0;
        p[1]=(p[1]+vertices[j][1])/2.0;
        glVertex2fv(p);
    }

    glEnd();
    glFlush();
}


int main(int argc, char** argv) {
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0);
    glutCreateWindow("Sierpinski Gasket");
    glutDisplayFunc(display);
    myinit();
    glutMainLoop();
}

My compilation errors are:

main.cpp: In function 'void myinit()':
main.cpp:13: error: 'gluOrtho2D' was not declared in this scope
main.cpp: In function 'int main(int, char**)':
main.cpp:38: error: 'glutInit' was not declared in this scope
main.cpp:39: error: 'GLUT_SINGLE' was not declared in this scope
main.cpp:39: error: 'GLUT_RGB' was not declared in this scope
main.cpp:39: error: 'glutInitDisplayMode' was not declared in this scope
main.cpp:40: error: 'glutInitWindowSize' was not declared in this scope
main.cpp:41: error: 'glutInitWindowPosition' was not declared in this scope
main.cpp:42: error: 'glutCreateWindow' was not declared in this scope
main.cpp:43: error: 'glutDisplayFunc' was not declared in this scope
main.cpp:45: error: 'glutMainLoop' was not declared in this scope
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

Id appreciate your help very much. I will attach my code in case it is necessary.

Thank you.
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP