I have specified the following Shader Storage Buffer in the Vertex Shader:
layout(std430, binding = 1) buffer MVP
{
mat4 u_proj;
mat4 u_view;
mat4 u_model;
} mvp_data;
I have initialized the model, view and projection matrix:
model = glm.mat4(1)
view = glm.lookAt(glm.vec3(0,-3,0), glm.vec3(0,0,0), glm.vec3(0,0,1))
proj = glm.perspective(glm.radians(90), self.__vp_size[0]/self.__vp_size[1], 0.1, 100)
How can the buffer object's data store be created and initialized using glBufferData (or glNamedBufferData)
ssbo = glGenBuffers( 1 )
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo )
glBufferData(GL_SHADER_STORAGE_BUFFER, 3*16*4, ???, GL_STATIC_DRAW )
respectively initialized by glBufferSubData (or glNamedBufferSubData)
ssbo = glGenBuffers( 1 )
glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo )
glBufferData(GL_SHADER_STORAGE_BUFFER, 3*16*4, None, GL_STATIC_DRAW )
glBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, ???, ???);
Since the SSBO contains 3 (tightly packed) mat4, the size of the buffer is 3 * 16 * 4 (3 4x4-matrices with element data type float).
So the initialization of the buffer can be done by a NumPy array.
But how the PyGLM matrices can be effectively assigned to the NumPy array?
buffer_data = numpy.zeros(3*16, dtype=numpy.float32)
??? buffer_data = model, view, proj
glBufferData(GL_SHADER_STORAGE_BUFFER, buffer_data.nbytes, buffer_data, GL_STATIC_DRAW)
Or is there an even more efficient solution, without an copying the data to a NumPy array?