0

我对 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
4

0 回答 0