Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glUseProgram(ProgramID);
- glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
- glBindBuffer(GL_ARRAY_BUFFER, instanceVBO);
- glBufferData(GL_ARRAY_BUFFER, sizeof(offsets), offsets, GL_DYNAMIC_DRAW);
- glEnableVertexAttribArray(1);
- glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, nullptr);
- glVertexAttribDivisor(1, 1);
- offsets[0].y += SPEED;
- glDrawArraysInstanced(GL_TRIANGLES, 0, 12 * 3, sizeof(offsets) / sizeof(offsets[0]));
- glfwSwapBuffers(window);
- glfwPollEvents();
- }
- /*
- #version 330 core
- layout(location = 0) in vec3 modelspace;
- layout(location = 1) in vec3 offsets;
- uniform mat4 MVP;
- void main()
- {
- gl_Position = MVP * vec4(modelspace.x + offsets.x, modelspace.y + offsets.y, modelspace.z + offsets.z, 1.0);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement