OpenGL error 1280 using glad

I have some code to generate a framebuffer and bind it. It doesn’t and I get the error code 1280. Line of code that gives the error:

GLCall(glBindFramebuffer(GL_FRAMEBUFFER, fbo));

My code:

#include "OpenGLFBO.h"

void OpenGL_FBO::CreateFBO(bool drawDefault)

	glGenFramebuffers(1, &fbo_id);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo_id);


	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, OpenGL_FBO::texture);

	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, OpenGL_FBO::width, OpenGL_FBO::height, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);


	glBindTexture(GL_TEXTURE_2D, 0);

	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);


	//GLenum DrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
	//glDrawBuffers(1, DrawBuffers);

	glBindFramebuffer(GL_FRAMEBUFFER, 0);

	if (drawDefault) {
		glBindFramebuffer(GL_FRAMEBUFFER, OpenGL_FBO::fbo_id);

		GLuint VAO;
		glGenVertexArrays(1, &VAO);

		float vertices[] = {
			0.0f, -2.0f,
			2.0f, -2.0f,
			1.0f, 0.0f

		GLuint VBO;

		glGenBuffers(1, &VBO);
		glBindBuffer(GL_ARRAY_BUFFER, VBO);
		glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_DYNAMIC_DRAW);


		glViewport(0, 0, OpenGL_FBO::width, OpenGL_FBO::height);
		glScissor(0, 0, OpenGL_FBO::width, OpenGL_FBO::height);
		glClearColor(1.0f, 0.1f, 0.1f, 1.0f);

		//glBindBuffer(GL_ARRAY_BUFFER, 0);

		//glBindFramebuffer(GL_FRAMEBUFFER, 0);

		//glBindTexture(GL_TEXTURE_2D, OpenGL_FBO::texture);

		glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);

		glDrawArrays(GL_TRIANGLES, 0, 3);

		glVertex2f(0.0f, -2.0f);
		glVertex2f(2.0f, -2.0f);
		glVertex2f(1.0f, 0.0f);

		glBindFramebuffer(GL_FRAMEBUFFER, 0);

		//glBindBuffer(GL_ARRAY_BUFFER, 0);
	//glBindTexture(GL_TEXTURE_2D, 0);

void OpenGL_FBO::Bind()
	GLCall(glBindFramebuffer(GL_FRAMEBUFFER, fbo_id));

void OpenGL_FBO::Unbind()
	GLCall(glBindFramebuffer(GL_FRAMEBUFFER, 0));

OpenGL_FBO::~OpenGL_FBO() {
	GLCall(glDeleteFramebuffers(1, &fbo_id));

the fbo is in a header file.
I also run the create function first, then the bind.

I have fixed my code! Very sorry!

1280 = 0x500 = GL_INVALID_ENUM.

As GL_FRAMEBUFFER is a valid enum for the first argument to glBindFramebuffer, I’m going to assume that the GLCall macro is reporting an error from a previous call. A non-zero result from glGetError immediately after a call to a GL function doesn’t mean that function generated the error, only that it was generated by some function called since the last time a glGetError call returned zero. If you want to narrow the error down to a specific GL function, you have to call glGetError before the function, check that it returns zero (GL_SUCCESS), call the GL function, then call glGetError again. Note that a function can generate more than one error; if you want to clear the error state, you have to call glGetError repeatedly until it returns zero.

Or you can use debug output if the implementation supports it (OpenGL 4.3 or the KHR_debug extension).

1 Like

If I do not use GLCall() it just throws an assertion somewhere in my code. I don’t see why I should remove GLCall. Also, the GLCall() function actually does check until it is GL_SUCCESS.

Edit: I tried adding glGetError before and it gave the error 1280. Sorry!

What could be the problem then?

Do you mean that glGetError returned 1280 before the glBindFramebuffer call? If so, you’ll need to identify the call which generated that error.

If glGetError returned zero immediately prior to the glBindFramebuffer call and 1280 afterwards, that would have to be an implementation bug. GL_FRAMEBUFFER is one of the three valid enums for glBindFramebuffer (the other two being GL_READ_FRAMEBUFFER and GL_DRAW_FRAMEBUFFER).

I wrote glGetError() before and it gave the 1280 error. I cannot find what caused the error although. I know it is in that piece of code though.

Use debug output if your system supports it. Otherwise add glGetError calls until you narrow it down to a specific call.

The only thing that stands out is if you’re using a core profile context then


will generate GL_INVALID_ENUM.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.