2014-01-21 94 views
2

我已經在我的ubuntu系統上成功運行我的gl程序,並帶有一個好的圖形卡。然而,當我在一箇舊的英特爾機顯卡運行移動4系列,我得到這些錯誤:GLSL 1.30不支持

QGLShader::compile(Vertex): 0:1(10): error: GLSL 1.30 is not supported. Supported version are: 1.10, 1.20 and 1.00 ES 
QGLShader::compile(Fragment): 0:1(10): error: GLSL 1.30 is not supported. Supported version are: 1.10, 1.20 and 1.00 ES 

我覺得有些關鍵字在我的頂點和片段着色器的文件應改爲舊版本。任何人都可以向我推薦舊的關鍵字。

的Vertex Shader文件:

#version 130 

uniform mat4 mvpMatrix; 

in vec4 vertex; 
in vec2 textureCoordinate; 

out vec2 varyingTextureCoordinate; 

void main(void) 
{ 
    varyingTextureCoordinate = textureCoordinate; 
    gl_Position = mvpMatrix * vertex; 
} 

片段着色器文件:

#version 130 

uniform sampler2D texture; 

in vec2 varyingTextureCoordinate; 

out vec4 fragColor; 

void main(void) 
{ 
    fragColor = texture2D(texture, varyingTextureCoordinate); 
} 
+1

請給[當某人回答](http://stackoverflow.com/help/someone-answers)閱讀和/或訪問[about]中的所有主題(也會給你一個徽章) – rene

回答

7

page 2 of the GLSL 1.30 spec運行功能棄用列表向後:

  • #version 130 - >#version 120
  • in - >attribute
  • out - >varying
  • 刪除fragColor聲明,與gl_FragColor

頂點着色器替換fragColor用法:

#version 120 
uniform mat4 mvpMatrix; 
attribute vec4 vertex; 
attribute vec2 textureCoordinate; 
varying vec2 varyingTextureCoordinate; 
void main(void) 
{ 
    varyingTextureCoordinate = textureCoordinate; 
    gl_Position = mvpMatrix * vertex; 
} 

片段着色器:

#version 120 
uniform sampler2D texture; 
varying vec2 varyingTextureCoordinate; 
void main(void) 
{ 
    gl_FragColor = texture2D(texture, varyingTextureCoordinate); 
}