OpenGL shaders not properly rendering from buffers


#1

Hello,

This is my first time posting here. I am currently trying to develop on OpenGL (ft. GLFW) program in C. My intent with this program is to render a series of 2-dimensional squares in a window, that will all be different colors. I set the default background color to a neon blue color for error testing. Also, before I set-up the color-chaning code, I set all of the squares to a full-blue color to make sure it worked. However, rather than a full-blue screen, I saw a neon-blue screen. I believe that either my shaders are disfunctional or I have improperly set up my buffers for reading. I am relatively new to OpenGL, so I don’t know how to properly feed buffers into my shaders. What am I doing wrong?

Here is my source code: https://pastebin.com/Wsu3ZTSB


#2

Not sure here if there isn’t a default VAO but i didn’t see you generating one. Try adding one before buffer creation


GLuint VAO;
glCreateVertexArrays(1, &VAO);
glBindVertexArray(&VAO);


#3

The code uses the core profile:


glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

which doesn’t have a default VAO.

glVertexAttribPointer() and glEnableVertexAttrib() array should both generate GL_INVALID_OPERATION errors if called when no VAO is bound.