I’ve been using OpenGL for quite a while now but I always get confused by it’s state management system. In particular the issue I struggle with is understanding exactly which object or target a particular state is stored against.
Eg 1: assigning a texture parameter. Are those parameters stored with the texture itself, or the texture unit? Will binding a texture with a different texture unit move those parameter settings?
Eg 2: glVertexAttribPointer – what exactly is that associated with – is the it the active shader program, the the bound data buffer, the ES context itself? If I bind a different vertex buffer object, do I need to call glVertexAttribPointer again?
So I’m not asking for answers to the above questions – I’m asking if those answers are written down somewhere so I don’t need to do the whole trial and error thing everytime I use something new.
Those answers are written in the OpenGL ES 2.0 specification (PDF link). Every function states what state it affects, and there’s a big series of tables at the end that specify which state is part of which objects, or just part of the global context.