Closed Bug 565435 Opened 14 years ago Closed 14 years ago

OpenGL layer manager doesn't track vertex attribs correctly

Categories

(Core :: Graphics, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: vlad, Unassigned)

References

Details

Just noticed this.. in OpenGL, vertex attrib bindings are independent of the bound shader/program.  They're part of GL state, so that you can switch programs but maintain the same vertex attrib bindings.  So this code here in LayerManagerOGL::Initialize is unnecessary:

  mRGBLayerProgram->Activate();
  mGLContext->fVertexAttribPointer(VERTEX_ATTRIB_LOCATION,
                        2,
                        LOCAL_GL_FLOAT,
                        LOCAL_GL_FALSE,
                        0,
                        0);
  mYCbCrLayerProgram->Activate();
  mGLContext->fVertexAttribPointer(VERTEX_ATTRIB_LOCATION,
                        2,
                        LOCAL_GL_FLOAT,
                        LOCAL_GL_FALSE,
                        0,
                        0);

At least, it's unnecessary to do it twice -- activating the different programs in between has no effect.  However, this also means that all the current OpenGL layers aren't really correct -- all they're doing is calling program->Activate(), and aren't checking or ensuring that the vertex attribs are still set sanely.  Nothing is changing them, so it happens to accidentally work.

The right thing to do is to either track the state at a higher level (in GLContext) and pass in some sort of "I want the world to look like this" object for attribs, or for every usage to call EnableVertexAttrib, BindBuffer, and VertexAttribPointer.
This was fixed by bug 567626 and friends.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.