我想知道为什么在取消注释行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"
和glClearColor
工作正常,我取消注释glClear
时似乎无法正常工作,这让我很困惑。无论是在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
)
答案 0 :(得分:3)
观看案例:正确的拼写类型为GLchar
,而不是GLChar
。