2015-05-03 99 views
0

我試圖運行使用LWJGL和GLSL 3.3構建的OpenGL軟件,但在Linux Mint 17.1和Intel Ivy Bridge(HD4000)+ Mesa 10.6的3.0 devel的。在Ubuntu 14.04(Linux Mint 17.1)上的OpenGL 3.3 +英特爾圖形+ LWJGL

從我讀的Mesa 10.1+應該支持OpenGL和GLSL 3.3的Sandry Bridge和更新的Intel CPU。

glxinfo | grep的OpenGL的返回:

OpenGL vendor string: Intel Open Source Technology Center 
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile x86/MMX/SSE2 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 10.6.0-devel (git-4348046 2015-05-02 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.6.0-devel (git-4348046 2015-05-02 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.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa) 
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00 
OpenGL ES profile extensions: 

(我猜我需要OpenGL着色語言版本字符串:3.30,而不僅僅是核心標準3.3)

當調用Display.create()(LWJGL)不帶參數,我得到以下錯誤:

> 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 
> 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES 

glGetString(GL_VERSION)回報:

> 3.0 Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa) 

如果我嘗試調用Display.create()與核心配置文件真實,就像這樣:

Display.create(new PixelFormat(), new ContextAttribs(3,3).withProfileCore(true)); 

我收到以下錯誤:

0:11(6): error: operands of `==' must have the same type 

和GL_VERSION是:

3.3 (Core Profile) Mesa 10.6.0-devel (git-4348046 2015-05-02 trusty-oibaf-ppa) 

我不確定這是什麼意思,或者我應該怎麼做才能夠o在Intel集成顯卡上運行OpenGL 3.3。我很滿意這個代碼在nVidia(4.4+支持)上的作用。

任何有關此事的幫助將不勝感激,謝謝!

編輯:這是導致問題的着色器:

#version 330 

in vec2 texCoord0; 

uniform vec3 color; 
uniform sampler2D sampler; 

void main() { 
    vec4 textureColor = texture2D(sampler, texCoord0.xy); 

    if (textureColor == 0) 
     gl_FragColor = vec4(color, 1); 
    else 
     gl_FragColor = textureColor * vec4(color, 1); 
} 

比較textureColor== vec4(0,0,0,0)沒有工作,對不起。

我現在可以運行它。但我沒有看到任何紋理。我會試着找到問題,有沒有什麼明顯的可能會導致我的着色器?

+1

Mesa僅在覈心配置文件中支持GL> 3.0。你實際上設法在你以後的嘗試中獲得核心配置文件,而GLSL編譯器現在接受'#version 330'指令。然而,你的着色器在第11行有一些語法錯誤,因爲'0:11(6):錯誤:'=='的操作數必須具有相同的類型'試圖告訴你。您應該發佈着色器源代碼。事實上着色器在Nvidia上的工作並沒有什麼證明。特別是nvidia編譯器非常草率,並且允許大量超出GLSL規範的構造。 – derhass

+0

謝謝,我將把着色器添加到原始問題中。我認爲他們沒有問題,因爲我可以在另一臺機器上運行此代碼。 – Thums

回答

0

這一點很明顯,不是嗎?

vec4 textureColor = ... 
[...] 
if (textureColor == 0) 

您無法將vec4與標量進行比較。你可以使用類似if (textureColor == vec4(0))的東西。

但是,在大多數情況下,比較浮點值是否相等是一個壞主意。我真的會建議你使用不同的方法,如測試length(textureColor) < 0.5/256.0

+0

是的,我已經改變了你的答案,無論如何,謝謝! – Thums

相關問題