本文介绍了不支持GLSL 1.30的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用良好的显卡在ubuntu系统上成功运行了gl程序.但是,当我在带有图形移动4系列的老式英特尔计算机上运行它时,会出现以下错误:

I have run my gl program successfully on my ubuntu system with a good graphics card. However, when I run it in an old intel machine with graphics mobile 4-series, I get these errors:

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

我认为顶点和片段着色器文件中的某些关键字应更改为旧版本.有人可以建议我使用旧关键字吗?

I think some keywords in my vertex and fragment shader files should be changed to old version. Could any one suggest me the old keywords.

顶点着色器文件:

#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);
}

推荐答案

GLSL 1.30规范的第2页向后:

  • #version 130-> #version 120
  • in-> attribute
  • out-> varying
  • 删除fragColor声明,将fragColor用法替换为gl_FragColor
  • #version 130 -> #version 120
  • in -> attribute
  • out -> varying
  • Remove fragColor declaration, replace fragColor usage with gl_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);
}

这篇关于不支持GLSL 1.30的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 02:08