Skip to content

Instantly share code, notes, and snippets.

@yorung
Last active August 29, 2015 14:20
Show Gist options
  • Save yorung/d2efea8c35c4d75aa277 to your computer and use it in GitHub Desktop.
Save yorung/d2efea8c35c4d75aa277 to your computer and use it in GitHub Desktop.
make mat4 from vec4
uniform vec4 uniformBuffer[9];
void main() {
mat4 matV = mat4(uniformBuffer[0], uniformBuffer[1], uniformBuffer[2], uniformBuffer[3]);
mat4 matP = mat4(uniformBuffer[4], uniformBuffer[5], uniformBuffer[6], uniformBuffer[7]);
float etc1 = uniformBuffer[8].x;
float etc2 = uniformBuffer[8].y;
float etc3 = uniformBuffer[8].z;
}
struct UniformBuffer
{
Mat matP, matV;
float etc1, etc2, etc3, padding;
};
static UniformBuffer buf;
void Write()
{
glUniform4fv(glGetUniformLocation(shaderId, "uniformBuffer"), sizeof(buf) / (sizeof(GLfloat) * 4), (GLfloat*)&buf);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment