From 16f4890458e882c911fbcaa63e1b509627751b37 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Thu, 13 Nov 2014 00:40:28 +0100 Subject: [PATCH] Added a update function to the level which rotates the bunny. --- graphics.cc | 5 ++++- graphics.hh | 2 +- level.cc | 5 +++++ level.hh | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/graphics.cc b/graphics.cc index 2d7e4ab..95df54c 100644 --- a/graphics.cc +++ b/graphics.cc @@ -38,8 +38,11 @@ void deleteCustomResources() // we have memory management via reference counting, so nothing to do here } -void draw( float runTime ) +void draw(float runTime) { + // update Level first TODO: move this with the rest of the stuff that doesn't belong here to main + level.update(runTime); + // clear the framebuffer: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/graphics.hh b/graphics.hh index 267c423..c3c6e5d 100644 --- a/graphics.hh +++ b/graphics.hh @@ -13,7 +13,7 @@ void initCustomResources(); void deleteCustomResources(); // gets called ech frame, runTime is in seconds: -void draw( float runTime ); +void draw(float runTime); // gets called at window resize: void resizeCallback( GLFWwindow *, int newWidth, int newHeight ); diff --git a/level.cc b/level.cc index 96b7185..4367595 100644 --- a/level.cc +++ b/level.cc @@ -41,6 +41,11 @@ void Level::render() { this->terrain.render(); } +void Level::update(float runTime) { + // rotate bunny + objects[0].setRotation(glm::vec3(0.0f, 1.0472f * runTime, 0.0f)); +} + glm::vec3 Level::getAmbientLight() { return ambientLight; } diff --git a/level.hh b/level.hh index a2da274..924605f 100644 --- a/level.hh +++ b/level.hh @@ -14,6 +14,7 @@ class Level { Level(); ~Level(); void load(ACGL::OpenGL::SharedShaderProgram shader); // Shader is necessary for correct texture assigning + void update(float runTime); void render(); glm::vec3 getAmbientLight(); std::vector getLights();