hi everyone,
i have read this tutorial: Bitbucket | Git solution for teams using Jira
plus the wiki page for the interface blocks: Interface Block (GLSL) - OpenGL Wiki
and still i’m asking myself if i have to use GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT anyhow to make my code working on other platforms
(it works on mine without bothering about that)
the fragment shader looks like that:
struct Material
{
vec3 Kd;
vec3 Ks;
};
#define MAX_MATERIALS 100
layout (std140, binding = 1) uniform Materials
{
Material materials[MAX_MATERIALS];
};
the c++ code looks like that:
struct Material
{
vec3 Kd;
float PADDING1;
vec3 Ks;
float PADDING2;
};
std::vector<Material> materials;
// fill that array with some materials ...
// allocate buffer memory
glGenBuffers(1, &m_materialbuffer);
glBindBuffer(GL_UNIFORM_BUFFER, m_materialbuffer);
glBufferData(GL_UNIFORM_BUFFER, sizeof(Material) * materials.size(), materials.data(), GL_STATIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
// bind materials to location 1:
glBindBufferBase(GL_UNIFORM_BUFFER, 1, m_materialbuffer);
so i’m allocating just enough space so put the vector<Material> into the buffer, that works fine
do i only have to bother about GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT when using glbindBufferRange(…) ?
(which by-the-way is 256 on my system)