Hi!
I use a compute shader to draw triangles so I declare this structure in the c++ source code :
struct Triangle {
sf::Vector3f positions[3];
math::Vec3f colours[3];
sf::Vector2f texCoords[3];
sf::Vector3f normal;
unsigned int textureIndex;
unsigned int refractReflect;
float ratio;
odfaeg::math::Matrix4f transform;
odfaeg::math::Matrix4f textureMatrix;
};
I’ve an std::vector of triangles I fill when I load objects on my render.
Then, I pass every datas to an SSBO like this :
glCheck(glBindBuffer(GL_SHADER_STORAGE_BUFFER, trianglesSSBO));
glCheck(glBufferData(GL_SHADER_STORAGE_BUFFER, triangles.size() * 248, NULL, GL_DYNAMIC_DRAW));
GLvoid* p = nullptr;
glCheck(p = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY));
memcpy(p, &triangles[0], triangles.size() * 248);
glCheck(glUnmapBuffer(GL_SHADER_STORAGE_BUFFER));
248 is the size of the struct “Triangle”.
The problem is that every values are null in the compute shader, transform matrices, triangles positions, etc…
vec4 t = projMatrix * viewMatrix * triangles[i].transform * vec4(triangles[i].position[j], 1);
if (pixel_coords.x == 0 && pixel_coords.y == 0 && i == 0) {
drawNumber(ivec2(0, resolution.y-1), 1, vec4(1, 0, 0, 1), triangles[i].position[j].z);
}
Why opengl doesn’t fill my SSBO ?