[Return]

Report a post

Preview
i keep getting errors when compiling a shader, i have no idea why ( ´,_ゝ`)
this is all from a tutorial in https://learnopengl.com/Getting-started/Hello-Triangle
i just tried to clean it up a little by creating a function to compile shaders instead of putting them all in main()



bool getCompileResult(unsigned int *shader, const char *src) {
glShaderSource(*shader, 1, &src, nullptr);
//the error is in glShaderSource! (error is GL_INVALID_VALUE)
//etc....
}

const char *vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n"
"}\0";

int main() {
//some stuff
unsigned int vertexShader = glCreateShader(GL_VERTEX_SHADER);
if(!getCompileResult(&vertexShader, vertexShaderSource))
return -1;

}


i feel like i'm maybe making mistakes with pointers but i checked what *src in getCompileResult points to and it's exactly the source i declared
the opengl documentation says:

>GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL.
>GL_INVALID_VALUE is generated if maxLength is less than 0.

it cant be the second because i passed nullptr to glShaderSource which means it knows the string is null terminated, but idk what "shader is not a value generated by OpenGL" means
any help?
Post number No.143927
Board Off-Topic@Heyuri
Optional. Describe what's wrong with it.