2017-07-10 28 views
0

我想复制教程(精灵渲染),使用OpenGL版本> = 3.3。如何使用不同的OpenGL配置文件?

例如几何着色器3.2中引入的,我得到这个错误:

error: ‘GL_GEOMETRY_SHADER’ was not declared in this scope 

我更新了我的台面驱动程序到最新;我不太了解,但在C++编译/链接时如何选择更新版本的OpenGL:

➜glxinfo | grep -i“版本”

server glx version string: 1.4 
client glx version string: 1.4 
GLX version: 1.4 
    Version: 17.1.4 
    Max core profile version: 4.5 
    Max compat profile version: 3.0 
    Max GLES1 profile version: 1.1 
    Max GLES[23] profile version: 3.1 
OpenGL core profile version string: 4.5 (Core Profile) Mesa 17.1.4 
OpenGL core profile shading language version string: 4.50 
OpenGL version string: 3.0 Mesa 17.1.4 
OpenGL shading language version string: 1.30 
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 17.1.4 
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10 

我不能真正理解这一点,但它说有某种核心配置文件使用4.5版。我如何利用这个配置文件?

我初始化GL上下文在我的代码是这样的:

if(!glfwInit()) e_glfw_init(); 
m_window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE.c_str(), nullptr, nullptr); 
if(m_window == nullptr) e_window_context(); 
glfwMakeContextCurrent(m_window); 
glewExperimental = true; 
if(glewInit() != GLEW_OK) e_glew_init(); 
+4

你如何初始化你的上下文? – BDL

+3

你使用的是什么OpenGL头文件/加载库? –

+0

@NicolBolas我包括这些标题: 'GL/glew.h' 'GLFW/glfw3.h' 'GLM/glm.hpp' 'GL/glu.h' 'GLM/GTC/type_ptr .hpp' –

回答

0

按照glfw documentation,您可以通过使用glfwWindowHint功能指定的OpenGL版本和配置文件:

if(!glfwInit()) e_glfw_init(); 

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); 
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); 
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); 

m_window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE.c_str(), 
          nullptr, nullptr); 
+0

嗯,我不想改变窗口的OpenGL版本,我想在编译我的代码时获得更新的OpenGL的特性。 (基本上包括一个较新的头文件,并链接一个较新的预编译的库/共享对象) –

+3

没有“新”库或头文件这样的事情。所有的方法和扩展都是从这个库中加载的(这就是'glewInit'所做的)。应在当前的'glew.h'头文件中定义'GL_GEOMETRY_SHADER'。 – BDL

+0

谢谢我会试着找到定义! –

相关问题