我最近重新开始着手一个旧的个人项目(我上次最后一次工作是在2年前),这个项目使用GLSL着色器。该项目使用了许多像这样的着色器文件:
Original Answer翻译成"最初的回答"
#version 150
in vec3 color;
out vec4 out_Color;
void main(void){
out_Color = vec4(color,1.0);
}
使用该文件运行程序时,我遇到了以下错误:
"Original Answer" 翻译成 "最初的回答"
error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES
我假设在过去的两年里我更新了PC的某些驱动程序,GLSL版本1.5不再受支持。我已尝试使用以下标题中的任何其他版本,每个版本都会报告不同的错误,按照上述支持版本的顺序报告如下:
#version 110:
"最初的回答"
0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.10
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL 1.10
#version 120:
0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.20
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL 1.20
#version 130:
0:1(1): error: `in' qualifier in declaration of `position' only valid for function parameters in GLSL 1.10
0:2(1): error: `in' qualifier in declaration of `textureCoordinates' only valid for function parameters in GLSL 1.10
0:4(1): error: `out' qualifier in declaration of `passTextureCoordinates' only valid for function parameters in GLSL 1.10
#版本100:
最初的回答0:3(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL ES 1.00
0:3(1): error: No precision specified in this scope for type `vec3'
0:5(1): error: `out' qualifier in declaration of `out_Color' only valid for function parameters in GLSL ES 1.00
0:5(1): error: No precision specified in this scope for type `vec4'
#version 300 es:
0:3(1): error: No precision specified in this scope for type `vec3'
0:5(1): error: No precision specified in this scope for type `vec4'
最初的回答:假设不能或不是正确的解决方案只是回到1.5版本,那么现在我需要将我的着色器文件转换成以上某个版本并修复错误。所以这就是我的问题:这样做是正确的方法吗?我真的需要改变GLSL版本,如果是这样的话,哪个版本最好使用?我需要同时更改Java代码吗?或者改变GLSL的版本对我的Java LWJGL代码没有任何影响?
抱歉如果这是一个初学者的问题,而且我可能完全错了,正如我所提到的,我刚回到这个项目。以下是一些关于我当前安装的信息:
glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Ivybridge Mobile
OpenGL core profile version string: 3.3 (Core Profile) Mesa 13.0.6
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 13.0.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 13.0.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
I'm working on debian:
Distributor ID: Debian
Description: Debian GNU/Linux 9.13 (stretch)
Release: 9.13
Codename: stretch
我添加了下面的代码以查找项目使用的LWJGL和OpenGL版本:
我添加了下面的代码以查找项目使用的LWJGL和OpenGL版本:
System.out.println("[DEBUG]: OS name " + System.getProperty("os.name"));
System.out.println("[DEBUG]: OS version " + System.getProperty("os.version"));
System.out.println("[DEBUG]: LWJGL version " + org.lwjgl.Sys.getVersion());
System.out.println("[DEBUG]: OpenGL version " + glGetString(GL_VERSION));
最初的回答是:
它的输出为:
[DEBUG]: OS name Linux
[DEBUG]: OS version 4.9.0-4-amd64
[DEBUG]: LWJGL version 3.0.0a
[DEBUG]: OpenGL version 3.0 Mesa 13.0.6
glfwCreateWindow()
、glfwMakeContextCurrent(window);
、glfwShowWindow(window);
对于第一个函数,我在此省略了参数,以便阅读,但它只是像高度、宽度和标题之类的东西。在我看来,这个过程中没有任何与核心配置文件有关的内容。如果我提供的信息不正确,请谅解,因为我已经两年没看到这段代码了... 如果您愿意,您也可以在这里查看代码:https://github.com/BRHSM/LWJGL_Engine 它非常杂乱无章,我也想修复它... - BRHSMglCreateWindow
之前被调用。另外请注意,调试上下文仅适用于OpenGL 4.3及以上版本。我建议您请求主版本3,次版本3,并使用GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
。 - BDL