View Full Version : DSA requires binding?!

04-10-2015, 10:31 AM
Playing with Direct State Access functions right now. Just discovered smg unexpected creating a framebuffer: it seems like DSA functions generate GL_INVALID_OPERATION when I attempt to apply them to a newly generated FBO which was never bound. So here is the code that generates GL_INVALID_OPERATION error:

GLuint FBO = 0;
glNamedFramebufferTexture(FBO, GL_COLOR_ATTACHMENT0, TextureName, MipmapLevel);

And once I uncomment the FBO' binding line, error disappears - everything works fine.

In other words, generating name is not sufficient to create an object - it must be bound to context at least once before it could be used. Strange, I don't remember this to be stated anywhere... Am I wrong, am I missing smg from documentation or did I just found a bug in nVidia drivers?..

Alfonse Reinheart
04-10-2015, 10:46 AM
Strange, I don't remember this to be stated anywhere...

I do. It's right there in the specification (https://www.opengl.org/registry/specs/ARB/direct_state_access.txt); the beginning of it is in the "Additions to Chapter 2 of the OpenGL 4.4 (core) Specification (OpenGL Fundamentals)" section. And it's part of every DSA api function's error list that it yields GL_INVALID_OPERATION if the object has not been created.

This is why you should be using the glCreate* functions instead of glGen*; these create the name and the object. That way, you don't need to bind to edit things.

BTW, yes, this was a change from the EXT-form of DSA. It allows ARB_DSA to be a bit more efficient, since every API call doesn't have to potentially create an object.

04-10-2015, 01:17 PM
OMG, I am so ashamed...
Thank you, Alfonse, I happened to forget about those functions completely...:doh: