У меня есть следующий шейдер Vertex:
#version 330
layout (location = 0) in ivec4 inOHLC;
layout (location = 1) in int inVolume;
layout (location = 2) in int inTimestamp;
out ivec4 outOHLC;
out int outVolume;
out int outTimestamp;
void main()
{
outOHLC = inOHLC;
outVolume= inVolume;
outTimestamp = inTimestamp;
}
И я хочу получить outOHLC
, outVolume
и outTimestamp
в шейдере Geometry. Я кодирую это:
#version 330
in ivec4 inOHLC;
in int inVolume;
in int inTimestamp;
layout (line_strip, max_vertices = 2) out;
void main() {
float x = (float)inTimestamp / 100.0;
float y1 = (float)inOHLC[1] / 100.0;
float y2 = (float)inOHLC[1] / 100.0;
gl_Position = vec4(x, y1, 0.0, 0.0);
EmitVertex();
gl_Position = vec4(x, y2, 0.0, 0.0);
EmitVertex();
EndPrimitive();
}
Но я получаю следующую ошибку:
run:
. . . vertex compilation success.
. . . geometry compilation failed.
Shader Info Log:
ERROR: 7:1: 'inOHLC' : geometry shader input varying variable must be declared as an array
ERROR: 8:1: 'inVolume' : geometry shader input varying variable must be declared as an array
ERROR: 9:1: 'inTimestamp' : geometry shader input varying variable must be declared as an array
ERROR: 15:1: ')' : syntax error syntax error
После комментария @ Rabbid76 я изменил код следующим образом:
#version 330
in ivec4 ohlc[];
in int volume[];
in int timestamp[];
layout (line_strip, max_vertices = 2) out;
void main()
{
float x = (float)timestamp / 100.0;
float y1 = (float)ohlc[1] / 100.0;
float y2 = (float)ohlc[2] / 100.0;
gl_Position = vec4(x, y1, 0.0, 0.0);
EmitVertex();
gl_Position = vec4(x, y2, 0.0, 0.0);
EmitVertex();
EndPrimitive();
}
И теперь я получаю только одну ошибку:
run:
. . . vertex compilation success.
. . . geometry compilation failed.
Shader Info Log:
ERROR: 40:1: ')' : syntax error syntax error
Я предполагаю, что это связано либо с приведением (float)
(оно существует даже в GLSL?), Либо с определениями переменных с плавающей точкой.