diff options
author | Michael Rodin <mrodin@de.adit-jv.com> | 2018-11-15 10:12:59 +0100 |
---|---|---|
committer | Michael Rodin <mrodin@de.adit-jv.com> | 2018-11-27 16:51:39 +0100 |
commit | 14cc000dfe21fc1a73e98d1a05143eb0e12df694 (patch) | |
tree | c9d7d702b702239121f9a208b45fbd8d5b0cbe73 | |
parent | 5319180771f36052645a2d9fce5b96ed70bbd298 (diff) | |
download | wayland-ivi-extension-14cc000dfe21fc1a73e98d1a05143eb0e12df694.tar.gz |
EGLWLMockNavigation: class Car: add new constructor
Add a new constructor and member variables to
support using textures. Also modify the initializer
list of the old constructor to initialize new member
variables appropriately.
Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
-rw-r--r-- | ivi-layermanagement-examples/EGLWLMockNavigation/include/Car.h | 7 | ||||
-rw-r--r-- | ivi-layermanagement-examples/EGLWLMockNavigation/src/Car.cpp | 40 |
2 files changed, 47 insertions, 0 deletions
diff --git a/ivi-layermanagement-examples/EGLWLMockNavigation/include/Car.h b/ivi-layermanagement-examples/EGLWLMockNavigation/include/Car.h index 0ef5787..6a889a9 100644 --- a/ivi-layermanagement-examples/EGLWLMockNavigation/include/Car.h +++ b/ivi-layermanagement-examples/EGLWLMockNavigation/include/Car.h @@ -22,6 +22,8 @@ #include "IRenderable.h" #include "vec.h" +#include "ShaderTexture.h" +#include "TextureLoader.h" class ShaderBase; @@ -29,6 +31,7 @@ class Car : public IRenderable { public: Car(vec3f position, vec3f size, vec4f color, ShaderBase* shader); + Car(vec3f position, vec3f size, vec4f color, ShaderTexture* shader, TextureLoader* texture); virtual ~Car() {} virtual void render(); @@ -40,8 +43,12 @@ private: vec4u m_index; vec3f m_vertex[4]; + vec2f m_texCoords[4]; ShaderBase* m_pShader; + + TextureLoader* texture; + bool withTexture = false; }; #endif /* _CAR_H */ diff --git a/ivi-layermanagement-examples/EGLWLMockNavigation/src/Car.cpp b/ivi-layermanagement-examples/EGLWLMockNavigation/src/Car.cpp index 51205ee..c77cdb3 100644 --- a/ivi-layermanagement-examples/EGLWLMockNavigation/src/Car.cpp +++ b/ivi-layermanagement-examples/EGLWLMockNavigation/src/Car.cpp @@ -34,6 +34,8 @@ Car::Car(vec3f position, vec3f size, vec4f color, ShaderBase* shader) , m_color(color) , m_index(0, 1, 2, 3) , m_pShader(shader) +, texture(nullptr) +, withTexture(false) { m_vertex[0].x = 0.0; m_vertex[0].y = 0.0; @@ -52,6 +54,44 @@ Car::Car(vec3f position, vec3f size, vec4f color, ShaderBase* shader) m_vertex[3].z = 0.0; } +Car::Car(vec3f position, vec3f size, vec4f color, ShaderTexture* shader, TextureLoader* texture) +: m_position(position) +, m_size(size) +, m_color(color) +, m_index(0, 1, 2, 3) +, m_pShader(shader) +, texture(texture) +, withTexture(true) +{ + m_vertex[0].x = 0.0; + m_vertex[0].y = 0.0; + m_vertex[0].z = 0.0; + + m_vertex[1].x = 0.0; + m_vertex[1].y = 0.0; + m_vertex[1].z = -m_size.z; + + m_vertex[2].x = m_size.x; + m_vertex[2].y = 0.0; + m_vertex[2].z = -m_size.z; + + m_vertex[3].x = m_size.x; + m_vertex[3].y = 0.0; + m_vertex[3].z = 0.0; + + m_texCoords[0].x = 0.0; + m_texCoords[0].y = 0.0; + + m_texCoords[1].x = 0.0; + m_texCoords[1].y = 1.0; + + m_texCoords[2].x = 1.0; + m_texCoords[2].y = 1.0; + + m_texCoords[3].x = 1.0; + m_texCoords[3].y = 0.0; +} + void Car::render() { m_pShader->use(&m_position, &m_color); |