Added a update function to the level which rotates the bunny.

This commit is contained in:
Faerbit 2014-11-13 00:40:28 +01:00
parent f5a1864472
commit 16f4890458
4 changed files with 11 additions and 2 deletions

View File

@ -38,8 +38,11 @@ void deleteCustomResources()
// we have memory management via reference counting, so nothing to do here // 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: // clear the framebuffer:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

View File

@ -13,7 +13,7 @@ void initCustomResources();
void deleteCustomResources(); void deleteCustomResources();
// gets called ech frame, runTime is in seconds: // gets called ech frame, runTime is in seconds:
void draw( float runTime ); void draw(float runTime);
// gets called at window resize: // gets called at window resize:
void resizeCallback( GLFWwindow *, int newWidth, int newHeight ); void resizeCallback( GLFWwindow *, int newWidth, int newHeight );

View File

@ -41,6 +41,11 @@ void Level::render() {
this->terrain.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() { glm::vec3 Level::getAmbientLight() {
return ambientLight; return ambientLight;
} }

View File

@ -14,6 +14,7 @@ class Level {
Level(); Level();
~Level(); ~Level();
void load(ACGL::OpenGL::SharedShaderProgram shader); // Shader is necessary for correct texture assigning void load(ACGL::OpenGL::SharedShaderProgram shader); // Shader is necessary for correct texture assigning
void update(float runTime);
void render(); void render();
glm::vec3 getAmbientLight(); glm::vec3 getAmbientLight();
std::vector<Light> getLights(); std::vector<Light> getLights();