glColor()在此范围内未声明。

3

我有以下头文件:

#ifndef CLASSES_H
#define CLASSES_H

class Mouse // Handles clicking of the mouse

{

private:



public:

Mouse()
{

    // Constructor

}

void handle_input(int x, int y) // Takes arguments of xloc and yloc of the mouse          pointer
{



}

};

class Game_Grid

{

private:



public:



};

class Red_Jewel // Is a circle shape

{

private:

int offset;

public:

Red_Jewel(int offset)
{

    this -> offset = offset;

}

void draw()
{

    glColor(256,0,0); // Red


}

};

class Green_Jewel // Is a triangle shape

{

private:

int offset;

public:

Green_Jewel(int offset)
{

    this -> offset = offset;

}

void draw()
{

    glColor(0,256,0); // Green

}

};

class Blue_Jewel // Is a square shape

{

private:

int offset;

public:

Blue_Jewel(int offset)
{

    this -> offset = offset;

}

void draw()
{

    glColor(0,0,256); // Blue

}

};

// Define objects here; circle jewel, triangle jewel, square jewel, the game grid

#endif // CLASSES_H

这是一个被包含在.cpp主文件中的内容,该主文件包含以下内容:

#include <SDL/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "classes.h" // objects within the game
#include <iostream>

在头文件中使用glColor()时,即使我在头文件中包含了所有上述的头文件,仍然会出现“未在此范围内声明”的错误。我以前从未遇到过这种情况,也不知道为什么会出现这些错误。
感谢您提供的任何帮助!
1个回答

4

你需要调用的函数是glColor3ub(255,0,0),而不是glColor(255,0,0)。


这解决了我的问题。尽管在Windows上编译时我能够像这样使用glColor()。 - user969416

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接