我有以下头文件:

#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() 也会给我“未在此范围内声明”错误。我以前从未经历过这种情况,也不知道为什么会出现错误。

感谢您的任何帮助!

最佳答案

您正在寻找的电话是 glColor3ub(255,0,0);不是 glColor(255,0,0);

关于c++ - glColor() 未在此范围内声明,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8638921/

10-11 15:38