I just wanted to know what would cause this problem. Whenever I run my application, I get the following error in the command prompts
an internal OpenGL call failed in RenderTarget (61): GL_INVALID_OPERATION
The application can run and the window appears with the triangle, but the fragment shader is not working, as the triangle is white. It is suppose to be red. I wrote some debug code to detect whether or not an error has occurred but it does not run, so I'm guessing its not the shaders that is the problem.
During debug however, the error occurs after the command
Window.clear() // This is an SFML call.
Here is the some code
static const GLchar * vertex_shader_source[] =
{
"#version 400 core \n",
" \n",
"layout (location = 0) in vec3 position; \n",
" \n",
"layout (location = 1) in vec4 color; \n",
"out vec4 FS_color; \n",
" \n",
"void main(void) \n",
"{ \n",
" \n",
" gl_Position = vec4(position.x, position.y, position.z, 1.0f); \n",
" FS_color = color; \n",
" \n",
"} \n",
" \n"
};
static const GLchar * fragment_shader_source[] =
{
"#version 400 core \n",
" \n",
"in vec4 FS_color; \n",
"out vec4 color_output; \n",
" \n",
"void main(void) \n",
"{ \n",
" color_output = FS_color; \n",
" \n",
" \n",
"} \n"
};
MAIN FUNCTIONS:
const GLfloat vertices[] =
{
0.00f, 0.00f, 0.00f,
-0.50f, -0.50f, 0.00f,
0.50f, -0.50f, 0.00f
};
const GLfloat redColor[] =
{
1.0f, 0.0f, 0.0f, 1.0f
};
GLuint Program = compiler_shader();
GLuint VAO_1;
glGenVertexArrays(1, &VAO_1);
glBindVertexArray(VAO_1);
GLuint VBO_1;
glGenBuffers(1, &VBO_1);
glBindBuffer(GL_ARRAY_BUFFER, VBO_1);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(0);
GLuint VBO_2;
glGenBuffers(1, &VBO_2);
glBindBuffer(GL_ARRAY_BUFFER, VBO_2);
glBufferData(GL_ARRAY_BUFFER, sizeof(redColor), redColor, GL_STATIC_DRAW);
glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, nullptr);
glEnableVertexAttribArray(1);
glBindVertexArray(0);
Game LOOP:
glUseProgram(Program);
glBindVertexArray(VAO_1);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
Window.display();
Essentially, what I'm trying to do in this application is have one of the VBO objects hold a color, that is then sent to the vertex shader then to the fragment shader (Is there a way to send data directly to the fragment shader from application code?)
What could be causing this error? Thanks in advance