[英]Compiling Simple static OpenGL 4.0 program using MinGW, freeglut and glew
[英]GLEW/SFML program not compiling in MinGW - “GLChar” not recognised
我想知道為什么在取消注釋GLChar* test = "Test";
時為什么我的代碼無法編譯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
)
注意這種情況:正確的類型拼寫是GLchar
,而不是GLChar
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.