glfwOpenWindowHint 未在此范围内声明 GLFW3 & GLEW
glfwOpenWindowHint not declared in this scope GLFW3 & GLEW
根据OpenGL针对OpenGL 3+的一些教程,我一开始就遇到了一些差异,这是我设法获得的代码,但一开始,我就遇到了大量错误,没有一个说它找不到包含的头,只是头没有定义核心函数。
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GL/glfw3.h>
#include <glm/glm.hpp>
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);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //I don't want the
//old OpenGL
// 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
// 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 ) );
问题是MinGW不太喜欢这个,并且已经生产了大量"未声明"错误,所有这些都是OpenGL窗口存在所必需的。除了SDL2之外,我从未使用过任何图形库,所以你可能需要带我了解一下。。。非常感谢。
SigmaGLPPmain.cpp:23:20: error: 'GLFW_FSAA_SAMPLES' was not declared in this scope
SigmaGLPPmain.cpp:23:40: error: 'glfwOpenWindowHint' was not declared in this scope
SigmaGLPPmain.cpp:24:20: error: 'GLFW_OPENGL_VERSION_MAJOR' was not declared in this
scope
SigmaGLPPmain.cpp:25:20: error: 'GLFW_OPENGL_VERSION_MINOR' was not declared in this
scope
SigmaGLPPmain.cpp:29:48: error: 'GLFW_WINDOW' was not declared in this scope
SigmaGLPPmain.cpp:29:60: error: 'glfwOpenWindow' was not declared in this scope
SigmaGLPPmain.cpp:43:35: error: cannot convert 'const char*' to 'GLFWwindow*' for
argument '1' to 'void glfwSetWindowTitle(GLFWwindow*, const char*)'
SigmaGLPPmain.cpp:46:30: error: 'glfwEnable' was not declared in this scope
SigmaGLPPmain.cpp:52:21: error: too few arguments to function 'void
glfwSwapBuffers(GLFWwindow*)'
SigmaGLPPmain.cpp:55:20: error: 'GLFW_KEY_ESC' was not declared in this scope
SigmaGLPPmain.cpp:56:21: error: 'GLFW_OPENED' was not declared in this scope
SigmaGLPPmain.cpp:56:33: error: 'glfwGetWindowParam' was not declared in this scope
SigmaGLPPmain.cpp:56:36: error: expected '}' at end of input
您使用GLFW3
标头,但您编写的代码是为GLFW2
编写的。
在GLFW3
中,函数glfwOpenWindowHint()
被重命名为glfwWindowHint()
有关升级说明,请查看此页面:http://www.glfw.org/docs/3.0/moving.html自GLFW2
以来,发生了很多变化。
相关文章:
- GLEW/GLUT:调用init并创建一个窗口后,取消初始化并重新初始化?
- 为什么需要检查 GLAD 或 GLEW 是否正确初始化?
- 现代OpenGL和GLEW Libraray的编译错误
- 使用 CMake 和 Visual Studio 2019 编译 GLEW?
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 无法链接 GLEW 库
- 将源中的 GLEW 与 cmake 静态链接
- OpenGL/Glew C++纹理不适用
- GLEW 未在 MSYS2 上定位 OpenGL 函数
- 在macOS上编译GLEW和GLUT?
- LNK 1104 无法打开文件 'glfw3.lib
- 致命错误 C1083:无法打开包含文件:"GL/glew.h":没有此类文件或目录
- 使用 glew 和 mingw 时未定义的引用?
- 在Visual Studio Community中使用glfw3 glew和opengl获取访问冲突异常
- 带有CMAKE和GLEW GLFW3和GLM库的OpenGL
- 无法使用GLFW3初始化GLew
- glfwOpenWindowHint 未在此范围内声明 GLFW3 & GLEW
- 包括使用g++mac的GLEW、glfw3和glm
- GLFW3 和 GLEW 分段故障
- 如何构建 OpenGL + GLEW + GLFW 程序,以便在带有 exe 的文件夹中不需要 glfw3.dll?