gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 21:05:55 25 4
gpt4 key购买 nike

我有以下头文件:

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com