我想知道为什么当我取消注释GLChar* test = "Test";行时我的代码无法编译

这是我的完整代码:

#include <iostream>

// GLEW
#define GLEW_STATIC
#include <GL/glew.h>

// SFML
#include <SFML/Window.hpp>

const int WIDTH = 800, HEIGHT = 600;
//GLChar* test = "Test";

int main() {
    sf::Window window(sf::VideoMode(WIDTH, HEIGHT),
              "OpenGL",
              sf::Style::Default,
              sf::ContextSettings(24, 0, 0, 3, 1));


    while (window.isOpen()) {
        sf::Event event;

        while (window.pollEvent(event)) {
            if (event.type == sf::Event::Closed) {
                window.close();
            } else if (event.type == sf::Event::Resized) {
                glViewport(0, 0, event.size.width, event.size.height);
            }
        }

        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);

        // clear the buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        window.display();
    }

    return 0;
}

令我感到困惑的是,当我取消注释GLChar* test = "Test"时,它似乎不起作用,因为glClearColorglClear可以正常工作。无论是在main()内还是全局声明都无所谓,错误是相同的。

错误是:
E:\Downloads\SFML-Game\src\main.cpp:11:1: error: 'GLChar' does not name a type
GLChar* test = "Test";

我相信我的库已正确链接-这是我相关的CMakeLists.txt区域:
target_link_libraries(game
libglew32.a
libopengl32.a
libsfml-main-d.a
libsfml-graphics-d.a
libsfml-audio-d.a
libsfml-system-d.a
libsfml-window-d.a
)

最佳答案

注意这种情况:正确的类型拼写是GLchar,而不是GLChar

09-04 15:31