Why can glBufferData buffer structs for UBO and SSBO when c++ does not specify struct layout
- 阅读更多 关于 Why can glBufferData buffer structs for UBO and SSBO when c++ does not specify struct layout
问题 I was browsing this page on how to use Uniform Buffer Objects in openGL and saw the following struct: struct shader_data_t { float camera_position[4]; float light_position[4]; float light_diffuse[4]; } shader_data; being buffered into an openGL Uniform Buffer Object using GLuint ubo = 0; glGenBuffers(1, &ubo); glBindBuffer(GL_UNIFORM_BUFFER, ubo); glBufferData(GL_UNIFORM_BUFFER, sizeof(shader_data), &shader_data, GL_DYNAMIC_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); and being used in the