LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Matthias on May 20, 2006, 12:47:24

Title: Optimisation for org.lwjgl.opengl.StateTracker
Post by: Matthias on May 20, 2006, 12:47:24
The pushAttrib() and popAttrib() does a many calls to getCapabilities() to get the current StateTracker instance - this is unneccessary;

static void popAttrib() {
StateTracker tracker = getStateTracker();
if ((tracker.attrib_stack.popState() & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) {
tracker.vbo_array_stack.popState();
tracker.vbo_element_stack.popState();
tracker.pbo_pack_stack.popState();
tracker.pbo_unpack_stack.popState();
tracker.references_stack.popState();
}
}

static void pushAttrib(int mask) {
StateTracker tracker = getStateTracker();
tracker.attrib_stack.pushState();
tracker.attrib_stack.setState(mask);
if ((mask & GL11.GL_CLIENT_VERTEX_ARRAY_BIT) != 0) {
tracker.vbo_array_stack.pushState();
tracker.vbo_element_stack.pushState();
tracker.pbo_pack_stack.pushState();
tracker.pbo_unpack_stack.pushState();
tracker.references_stack.pushState();
}
}

static StateTracker getStateTracker() {
return GLContext.getCapabilities().tracker;
}


This saves a lot work for code that is working with VBOs or VertexArrays.
Title: Optimisation for org.lwjgl.opengl.StateTracker
Post by: elias on May 29, 2006, 12:26:08
That's not the most up to date source code (are you using 0.99 source code or the CVS source?), but I've applied the gist of it to the subversion tree.

- elias