Hi everyone, I was making a shader class header which loads the shader from files, compiles and links them into the final shader object. It's based on this: https://learnopengl.com/code_viewer_gh.php?code=includes/learnopengl/shader_s.h

I remade it using the C way of reading files to read the files and it works perfectly fine when reading the file into the pointer. However, once I try to create a fragment shader like this:
GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);, it doesn't allow me and says
Thread 1: EXC_BAD_ACCESS (code = 1, address = 0x1298) I tried to use glGet Error to see if I could get the error code but the program crashes once it gets to the line with glCreateShader, so I can't get the error code.

If I try to run the program, it results in a glitchy screen when you press q and then if the q button is pressed a second time, I get the screen filled with a green colour. I think this is happening because the shader isn't working, although even when I did it without the shader class and just wrote out the shader as a pointer and compiled/linked it without wrapping it in a class*, it still gave me glitchy output.
*The shader did compile and link that time, so I don't understand why it's glitching.

// note that this is allowed, the call to glVertexAttribPointer registered VBO as the vertex attribute's bound vertex buffer object so afterwards we can safely unbind
glBindBuffer(GL_ARRAY_BUFFER, 0);

// remember: do NOT unbind the EBO while a VAO is active as the bound element buffer object IS stored in the VAO; keep the EBO bound.
//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

// You can unbind the VAO afterwards so other VAO calls won't accidentally modify this VAO, but this rarely happens. Modifying other
// VAOs requires a call to glBindVertexArray anyways so we generally don't unbind VAOs (nor VBOs) when it's not directly necessary.
glBindVertexArray(0);