[英]GLEW/SFML program not compiling in MinGW - “GLChar” not recognised
I am wondering why my code does not compile when I uncomment the line GLChar* test = "Test";
我想知道为什么在取消注释
GLChar* test = "Test";
时为什么我的代码无法编译GLChar* test = "Test";
Here is my full code: 这是我的完整代码:
#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;
}
It is very confusing to me that it does not seem to work when I uncomment GLChar* test = "Test"
, given that glClearColor
and glClear
work fine otherwise. 令我困惑的是,当我取消注释
GLChar* test = "Test"
时,它似乎不起作用,因为glClearColor
和glClear
可以正常工作。 It does not matter whether it is within main() or declared globally, the error is the same. 无论是在main()内还是全局声明都无所谓,错误是相同的。
The error is: 错误是:
E:\Downloads\SFML-Game\src\main.cpp:11:1: error: 'GLChar' does not name a type
GLChar* test = "Test";
My libraries are linked properly, I believe - here is my relevant CMakeLists.txt area: 我相信我的库已正确链接-这是我相关的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
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.