OPENGL GLUT编译器找不到函数

时间:2013-02-11 22:13:56

标签: c++ opengl compiler-construction glut

我对opengl很新,并且我得到错误,说它无法找到函数:glColor3f,glVertex2f,还有pRect。我的包括

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef MAC
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

并且有问题的代码是:

void display()
{
    // Rotate objects
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //glMatrixMode(GL_MODELVIEW);
    //glLoadIdentity();

    glBegin(GL_QUADS);   //We want to draw a quad, i.e. shape with four sides
    glColor3F(1, 0, 0); //Set the colour to red
    glVertex2F(0, 0);            //Draw the four corners of the rectangle
    glVertex2F(0, pRect->h);
    glVertex2F(pRect->w, pRect->h);
    glVertex2F(pRect->w, 0);
    glEnd();
    glPopMatrix();

    //glFlush();
}

我想我包含了所有必要的文件,当我编译它时,我使用命令:

g++ main.cpp -lgut -IGL -IGLU 

但这似乎也不是问题。任何建议都会很精彩!万分感谢!

编辑: 改变了

 g++ main.cpp -lgut -IGL -IGLU 

g++ main.cpp -lgut -lGL -lGLU 

错误代码是:

 glColor3F : not declared in this scope
 glVertex2F : not declared in this scope
 pRect: not declared in this scope

0 个答案:

没有答案