Have 100 cubes flying around in a circle with refraction.
This commit is contained in:
parent
1107c86036
commit
a199d41890
7 changed files with 29 additions and 15 deletions
|
|
@ -84,11 +84,14 @@ void Scene::spawn(const std::string& name, components::Position& position, compo
|
|||
}
|
||||
}
|
||||
|
||||
void Scene::setup_instancing() {
|
||||
void Scene::time_warp() {
|
||||
float time = glfwGetTime();
|
||||
for(size_t i = 0; i < INSTANCE_COUNT; i++) {
|
||||
translations[i].x = (float)i;
|
||||
translations[i].z = (float)i;
|
||||
translations[i].y = 0.0f;
|
||||
auto& t = translations[i];
|
||||
float factor = (float)i / 3.0f;
|
||||
t.y = cos((time + i)) * factor;
|
||||
t.z = sin((time + i)) * factor;
|
||||
t.x = sin((time + i)) * factor;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &instanceVBO);
|
||||
|
|
@ -104,12 +107,16 @@ void Scene::setup_instancing() {
|
|||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glVertexAttribDivisor(3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// this works
|
||||
shader.use();
|
||||
void Scene::setup_instancing() {
|
||||
for(size_t i = 0; i < INSTANCE_COUNT; i++) {
|
||||
shader.setVec3(std::format("offsets[{}]", i), translations[i]);
|
||||
translations[i].x = (float)i;
|
||||
translations[i].z = (float)i;
|
||||
translations[i].y = (float)i;
|
||||
}
|
||||
|
||||
time_warp();
|
||||
}
|
||||
|
||||
void Scene::init_skybox() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue