Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the line number of GLSL compiler error

Tags:

c++

c

opengl

glsl

I would like to know if there is a common way of getting the line number of an GLSL compiler error. At first I thought I could parse glGetInfoLogARB but then i read that its output is not standardized.

like image 576
Axalo Avatar asked Dec 20 '25 21:12

Axalo


1 Answers

It is not standardized, but among individual vendors it more or less is.

For example, NVIDIA tends to output messages that reference lines this way:

<Shader String Index>:<Line Number>(<Character Number>): <warning|error|...>:

While not perfect, an approach you could take if you needed to parse the info log for line numbers is to pre-process the input based on the GL_VENDOR string. The info log is usually for human interpretation though, so I am not sure how much effort this is really worth.

Speaking of non-standard things, glGetInfoLogARB (...) is archaic (it only exists in GL_ARB_shader_objects).

When GLSL went core in GL 2.0, the function was split into glGetShaderInfoLog (...) and glGetProgramInfoLog (...) for compiler and linker information respectively. For portability sake, you should not be using the old ARB extension; target GL 2.0 as your minimum version and use core GLSL instead.

like image 140
Andon M. Coleman Avatar answered Dec 22 '25 11:12

Andon M. Coleman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!