From 606533b74ba3354bb5f43f5d1513600dea6ef14d Mon Sep 17 00:00:00 2001 From: Faerbit Date: Thu, 23 Oct 2014 00:13:09 +0200 Subject: [PATCH] Implemented object.cc --- object.cc | 22 ++++++++++++++++++++++ object.hh | 15 +++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 object.cc diff --git a/object.cc b/object.cc new file mode 100644 index 0000000..abd5cfd --- /dev/null +++ b/object.cc @@ -0,0 +1,22 @@ +#include "object.hh" + +Object::Object(Model model, Texture texture, glm::vec3 position, glm::vec3 rotation, + glm::vec3 velocity, glm::vec3 angularVelocity) : Entity(position, rotation) { + this->model = model.getReference(); + this->texture = texture.getReference(); + this->velocity = velocity; + this->angularVelocity = angularVelocity; + + //TODO ensure this is only done once per loading(static encapsulation) + + shader = ACGL::OpenGL::ShaderProgramCreator("HelloWorld").attributeLocations( + model.getReference()->getAttributeLocations()).create(); + shader->use(); +} + +Object::~Object() { +} + +void Object::render() { + shader->setTexture("uTexture", texture, 0); +} diff --git a/object.hh b/object.hh index 8a95240..95f003c 100644 --- a/object.hh +++ b/object.hh @@ -3,18 +3,25 @@ #include "entity.hh" #include "model.hh" -#include "texture.hh" +#include "texture.hh" +#include #include +#include +#include +#include class Object : Entity { public: - Object(Model model, Texture texture, glm::vec3 position, glm::vec3 rotation, glm::vec3 velocity, glm::vec3 angularVelocity); + Object(Model model, Texture texture, glm::vec3 position, glm::vec3 rotation, + glm::vec3 velocity, glm::vec3 angularVelocity); ~Object(); + void render(); private: - Model model; - Texture texture; + ACGL::OpenGL::SharedVertexArrayObject model; + ACGL::OpenGL::SharedTexture2D texture; glm::vec3 velocity; glm::vec3 angularVelocity; + ACGL::OpenGL::SharedShaderProgram shader; }; #endif