c++ - glColor() 未在此范围内声明

标签 c++ opengl

我有以下头文件:

#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/

相关文章:

opengl - 在opengl中围绕兴趣点旋转相机

c++ - C++ 上的 SendInput 不考虑 Ctrl 和 Shift

c++ - OpenGL 分层渲染

c++ - 在 C++ 中使用您自己的 Matrix 类进行 OpenGL 对象旋转

c++ - while (数组末尾) - 如何识别

无法在OpenGL上绘制三角形

c++ - 如何在这种情况下适本地使用 RAII/减少内存泄漏

c++ - 如何在 Linux (GCC) 中打印输出(不是标准输出)?

c++ - 参数评估与链式方法之间是否存在有保证的“先发生”关系?

c++ - 从长位加倍