Skip to content

Instantly share code, notes, and snippets.

@floooh
Last active August 29, 2015 14:02
Show Gist options
  • Save floooh/4d618e73fbce5362cf53 to your computer and use it in GitHub Desktop.
Save floooh/4d618e73fbce5362cf53 to your computer and use it in GitHub Desktop.
How to use ORYOL_USE_GLGETATTRIBLOCATION

Set ORYOL_USE_GLGETATTRIBLOCATION cmake option to ON to activate alternative vertex attribute binding code-path using glGetAttribLocation instead of glBindAttribLocation. This is necessary on platforms where GL_MAX_VERTEX_ATTRIBS is smaller then Oryol's VertexAttr::NumVertexAttrs (16). Currently the only known platform where this is the case is the Raspberry Pi where GL_MAX_VERTEX_ATTRIBS is 8. Using this code path is mutually exclusive with vertex-array-objects, because of this ORYOL_USE_GLGETATTRIBLOCATION cannot be used on platforms which use the GL 3+ core profile (e.g. OSX).

How to configure the build process:

> oryol clean all
> oryol select [config]
> oryol config

This should start ccmake or cmake-gui.

Set the ORYOL_USE_GLGETATTRIBLOCATION option to ON, then config, generate and quit ccmake.

Build the project, when starting one of the Render samples, there should now be a console text message glStateWrapper: ORYOL_USE_GLGETATTRIBLOCATION is ON.

How it works:

glBindAttribLocation is not called: https://github.com/floooh/oryol/blob/master/code/Modules/Render/gl/glProgramBundleFactory.cc#L126

Instead after shader linkage glGetAttribLocation: https://github.com/floooh/oryol/blob/master/code/Modules/Render/gl/glProgramBundleFactory.cc#L189

Binding the mesh data for rendering is deferred until draw-time and needs the current shader program as second arg (redundancy checks happen within BindMesh): https://github.com/floooh/oryol/blob/master/code/Modules/Render/gl/glRenderMgr.cc#L295

BindMesh will use the actual attribute indices returned by glGetAttribLocation: https://github.com/floooh/oryol/blob/master/code/Modules/Render/gl/glStateWrapper.cc#L732

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment