the following shader is said to be one string and a null-terminated string.
A shader:
const GLchar* VertexShader =
{
"#version 330\n"\
"layout(location=0) in vec4 in_Position;\n"\
"layout(location=1) in vec4 in_Color;\n"\
"out vec4 ex_Color;\n"\
"void main(void)\n"\
"{\n"\
" gl_Position = in_Position;\n"\
" ex_Color = in_Color;\n"\
"}\n"
};
My questions are:
- What are the slashes mean at the end of each line? Moreover, why the last line doesn’t has a slash?
- There are several strings in the shader, why the shader is said to have only one string?
- Why it is said to be a null-terminated string? (Since there is no ‘\0’)
It is a line continuation, it means the current line continues in the next one.
Sequential string literals are collapsed into a single one. So
"ab" "c"becomes"abc".String literals are null-terminated. So
"ab"is actually{'a', 'b', '\0'}. Note that when string literals are collapsed, all but the last implicit null-termination characters are removed.