OpenGL的范围问题
Scope troubles with OpenGL
今天尝试在CodeBlocks中编译这个简单的程序时遇到了困难:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW. Always include it before gl.h and glfw.h, since it's a bit magic.
#include <GL/glew.h>
// Include GLFW
#include <GL/glfw.h>
// Include GLM
#include <glm/glm.hpp>
using namespace glm;
int main(){
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFWn" );
return -1;
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // We want OpenGL 3.3
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
fprintf( stderr, "Failed to open GLFW windown" );
glfwTerminate();
return -1;
}
// Initialize GLEW
glewExperimental=true; // Needed in core profile
if (glewInit() != GLEW_OK) {
fprintf(stderr, "Failed to initialize GLEWn");
return -1;
}
glfwSetWindowTitle( "Tutorial 01" );
// Ensure we can capture the escape key being pressed below
glfwEnable( GLFW_STICKY_KEYS );
do{
// Draw nothing, see you in tutorial 2 !
// Swap buffers
glfwSwapBuffers();
} // Check if the ESC key was pressed or the window was closed
while( glfwGetKey( GLFW_KEY_ESC ) != GLFW_PRESS &&
glfwGetWindowParam( GLFW_OPENED ) );
}
此代码来自教程 http://www.opengl-tutorial.org/beginners-tutorials/tutorial-1-opening-a-window/
我认为问题可能是由于我无法让 CMake 正常工作而引起的,所以我只是将依赖项复制到 CodeBlocks 目录中。
这些错误都涉及 glfw 的范围...
In function 'int main()':
|23|error: 'GLFW_FSAA_SAMPLES' was not declared in this scope
|24|error: 'GLFW_OPENGL_VERSION_MAJOR' was not declared in this scope
|25|error: 'GLFW_OPENGL_VERSION_MINOR' was not declared in this scope
|26|error: 'GLFW_OPENGL_PROFILE' was not declared in this scope
|26|error: 'GLFW_OPENGL_CORE_PROFILE' was not declared in this scope
您正在阅读的教程使用 Glfw 2,您可能下载了 GLFW 3.0降级 glfw 或按照本指南进行版本迁移:http://www.glfw.org/docs/3.0/moving.html
相关文章:
- 在 C++ 中使用正则表达式错误时出现问题 括号表达式中的范围无效
- 我在范围内未声明的错误类有问题
- 如何在cpp中使用地图显示给定日期范围内(在下面的问题中)的费率?
- 使用基于范围的循环迭代矢量时出现问题
- 示例代码中使用分隔符将 std::string 拆分为 std::vector 的范围问题
- C++ 字符串订阅超出范围的问题
- 命名空间范围问题
- 无法取消引用超出范围的向量迭代器 - 有什么问题?
- 断言失败错误,C++中的矢量下标超出范围问题
- 给定数组范围的选择排序问题
- 指针范围问题和返回类中封装的指针向量内的指针引用
- C++范围?将数组传递给函数时出现问题
- C++奇怪的问题.数据成员超出范围
- PlatformIO 的范围问题(?)
- C++. 面试. 关于返回 int* 值问题的范围
- 编程:原理与实践 使用C++ 第 4 章演练步骤 6:关于数字范围的一般问题
- 为什么BKDFHash不关心超出范围的问题?
- 访问函数中的使用声明:与范围相关的问题
- 函数返回本地变量,尽管变量不超出范围,没有编译器问题,并且代码执行
- 无法编译 - 范围问题