不支持 GLSL 3.30;链接未编译的着色器;OpenGL
GLSL 3.30 is not supported;Linking with uncompiled shader;OpenGL
这段代码告诉 GLSL 3.30 is not supported
void GLSLShader::LoadFromString(GLenum 类型, const string& source) {
GLuint 着色器 = glCreateShader (类型);
const char * ptmp = source.c_str();
glShaderSource (shader, 1, &ptmp, NULL);
//check whether the shader loads fine
GLint status;
glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
GLint infoLogLength;
glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLogLength);
GLchar *infoLog= new GLchar[infoLogLength];
glGetShaderInfoLog (shader, infoLogLength, NULL, infoLog);
cerr<<"Compile log: "<<infoLog<<endl;
delete [] infoLog;
}
_shaders[_totalShaders++]=shader;
}
这是glxinfo | grep OpenGL
的结果
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Desktop
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
我正在使用 ubuntu 14.04、C++ 和 QtCreator
部分代码告诉 Linking with uncompiled shader
如何启用GLSL3.0或者我还应该做什么?
您可以在使用 Qt 创建 GL 小部件时设置 OpenGL 上下文,如下所示:
QGLFormat glFormat;
glFormat.setVersion( 3, 3 );
glFormat.setProfile( QGLFormat::CoreProfile );
glFormat.setSampleBuffers( true );
GLWidget w( glFormat );
这段代码告诉 GLSL 3.30 is not supported
void GLSLShader::LoadFromString(GLenum 类型, const string& source) {
GLuint 着色器 = glCreateShader (类型);
const char * ptmp = source.c_str();
glShaderSource (shader, 1, &ptmp, NULL);
//check whether the shader loads fine
GLint status;
glCompileShader (shader);
glGetShaderiv (shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE) {
GLint infoLogLength;
glGetShaderiv (shader, GL_INFO_LOG_LENGTH, &infoLogLength);
GLchar *infoLog= new GLchar[infoLogLength];
glGetShaderInfoLog (shader, infoLogLength, NULL, infoLog);
cerr<<"Compile log: "<<infoLog<<endl;
delete [] infoLog;
}
_shaders[_totalShaders++]=shader;
}
这是glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Desktop
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 10.5.0-devel (git-6ee5eff 2015-01-28 trusty-oibaf-ppa)
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
我正在使用 ubuntu 14.04、C++ 和 QtCreator
部分代码告诉 Linking with uncompiled shader
如何启用GLSL3.0或者我还应该做什么?
您可以在使用 Qt 创建 GL 小部件时设置 OpenGL 上下文,如下所示:
QGLFormat glFormat;
glFormat.setVersion( 3, 3 );
glFormat.setProfile( QGLFormat::CoreProfile );
glFormat.setSampleBuffers( true );
GLWidget w( glFormat );