openGL を使用してラベル (GameLabel) を表示するクラスを作成しましたが、解決できなかった 2 つの非常に奇妙なエラーが発生しました。
エラー C2079: 'displayPlayer' は未定義のクラス 'GameLabel' IntelliSense を使用しています: 不完全な型は許可されていません
これが私のコードです。
ラベル クラスを呼び出す Game.cpp の関数
void Game::draw(SDL_Window *window)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear window
// draw player
glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f (xpos, ypos, 0.0); // first corner
glVertex3f (xpos+xsize, ypos, 0.0); // second corner
glVertex3f (xpos+xsize, ypos+ysize, 0.0); // third corner
glVertex3f (xpos, ypos+ysize, 0.0); // fourth corner
glEnd();
GameLabel displayPlayer = new GameLabel(xpos+(xsize/2.0f), ypos+ysize, "Player");
//The ablove line is the one flagging the errors.
これが GameLabel.h です。
#include <SDL_ttf.h>
#include <GL/glew.h>
#include <string>
#include "Game.h"
class GameLabel
{
public:
GameLabel(float fx, float fy, char stri);
~GameLabel(void);
void textToTexture(const char * str, SDL_Surface* stringImage);
void draw(SDL_Surface* stringImage);
friend class Game;
protected:
SDL_Surface stringImage;
private:
GLuint texID;
GLuint height;
GLuint width;
GLfloat x;
GLfloat y;
char str;
};
そして最後に GameLabel.cpp コンストラクター
GameLabel::GameLabel(float fx, float fy, char stri)
{
x = fx;
y = fy;
str = stri;
}