I found out that I can use uniform buffers to store multiple variables like this
#version 330 core
layout (location = 0) in vec3 aPos;
layout (std140) uniform Matrices
{
mat4 projection;
mat4 view;
};
uniform mat4 model;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
}
and treat this data like any other buffer
unsigned int uboMatrices
glGenBuffers(1, &uboMatrices);
glBindBuffer(GL_UNIFORM_BUFFER, uboMatrices);
glBufferData(GL_UNIFORM_BUFFER, 2 * sizeof(glm::mat4), NULL, GL_STATIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
glBindBufferRange(GL_UNIFORM_BUFFER, 0, uboMatrices, 0, 2 * sizeof(glm::mat4));
However, I can't seem to find any examples that would allow me to treat such a buffer like an array. Essentially I would like to achieve a global random-access buffer like this
#version 330 core
layout (location = 0) in vec3 aPos;
layout (what here?) uniform float[] globalBuffer;
uniform mat4 model;
void main()
{
...
}
The long term plan is to later produce this array with OpenCL