我有以下头文件:
#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()给我“在此范围内未声明”错误,即使我在头文件中包含了所有上述标题。我之前从未经历过这种情况,也不知道为什么我会收到这些错误。
感谢您的帮助!
答案 0 :(得分:4)
您正在寻找的电话是glColor3ub(255,0,0);不是glColor(255,0,0);