2017-07-10 40 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

謝謝我會試着找到定義! –

相關問題