Changing all occurences from texture to material.

This commit is contained in:
Faerbit 2014-11-08 01:17:23 +01:00
parent 31447458aa
commit 21b144a72b
7 changed files with 23 additions and 22 deletions

View File

@ -20,9 +20,9 @@ void Level::load(Shader shader) {
// load the geometry of the stanford bunny and build a VAO: // load the geometry of the stanford bunny and build a VAO:
Model model = Model("Bunny.obj"); Model model = Model("Bunny.obj");
// load a texture: // load a texture:
Texture texture = Texture("clownfishBunny.png"); Material material = Material("clownfishBunny.png");
//Create object //Create object
Object object = Object(model, texture, glm::vec3(0.0f, 0.0f, 0.0f), Object object = Object(model, material, glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 0.0f), shader); glm::vec3(0.0f, 0.0f, 0.0f), shader);
objects.push_back(object); objects.push_back(object);

View File

@ -6,6 +6,7 @@
#include "light.hh" #include "light.hh"
#include "entity.hh" #include "entity.hh"
#include "terrain.hh" #include "terrain.hh"
#include "material.hh"
#include "shader.hh" #include "shader.hh"
class Level { class Level {

View File

@ -1,15 +1,15 @@
#include "texture.hh" #include "material.hh"
Texture::Texture(std::string filePath) { Material::Material(std::string filePath) {
reference = ACGL::OpenGL::Texture2DFileManager::the()->get(ACGL::OpenGL::Texture2DCreator(filePath)); reference = ACGL::OpenGL::Texture2DFileManager::the()->get(ACGL::OpenGL::Texture2DCreator(filePath));
} }
Texture::Texture() { Material::Material() {
} }
Texture::~Texture() { Material::~Material() {
} }
ACGL::OpenGL::SharedTexture2D Texture::getReference() { ACGL::OpenGL::SharedTexture2D Material::getReference() {
return reference; return reference;
} }

View File

@ -1,17 +1,17 @@
#ifndef TEXTURE_HH_INCLUDED #ifndef MATERIAL_HH_INCLUDED
#define TEXTURE_HH_INCLUDED #define MATERIAL_HH_INCLUDED
#include <string> #include <string>
#include <ACGL/OpenGL/Creator/Texture2DCreator.hh> #include <ACGL/OpenGL/Creator/Texture2DCreator.hh>
#include <ACGL/OpenGL/Data/TextureLoadStore.hh> #include <ACGL/OpenGL/Data/TextureLoadStore.hh>
#include <ACGL/OpenGL/Managers.hh> #include <ACGL/OpenGL/Managers.hh>
class Texture{ class Material{
public: public:
Texture(std::string filePath); Material(std::string filePath);
Texture(); Material();
ACGL::OpenGL::SharedTexture2D getReference(); ACGL::OpenGL::SharedTexture2D getReference();
~Texture(); ~Material();
private: private:
ACGL::OpenGL::SharedTexture2D reference; ACGL::OpenGL::SharedTexture2D reference;
}; };

View File

@ -1,10 +1,10 @@
#include "object.hh" #include "object.hh"
Object::Object(Model model, Texture texture, glm::vec3 position, glm::vec3 rotation, Object::Object(Model model, Material material, glm::vec3 position, glm::vec3 rotation,
glm::vec3 velocity, glm::vec3 angularVelocity, Shader shader) : glm::vec3 velocity, glm::vec3 angularVelocity, Shader shader) :
Entity(position, rotation) { Entity(position, rotation) {
this->model = model.getReference(); this->model = model.getReference();
this->texture = texture.getReference(); this->material = material;
this->velocity = velocity; this->velocity = velocity;
this->angularVelocity = angularVelocity; this->angularVelocity = angularVelocity;
this->shader = shader.getReference(); this->shader = shader.getReference();
@ -17,6 +17,6 @@ Object::~Object() {
} }
void Object::render() { void Object::render() {
shader->setTexture("uTexture", texture, 0); shader->setTexture("uTexture", material.getReference(), 0);
model->render(); model->render();
} }

View File

@ -3,7 +3,7 @@
#include "entity.hh" #include "entity.hh"
#include "model.hh" #include "model.hh"
#include "texture.hh" #include "material.hh"
#include "shader.hh" #include "shader.hh"
#include <string> #include <string>
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
@ -12,14 +12,14 @@
class Object : public Entity { class Object : public Entity {
public: public:
Object(Model model, Texture texture, glm::vec3 position, glm::vec3 rotation, Object(Model model, Material material, glm::vec3 position, glm::vec3 rotation,
glm::vec3 velocity, glm::vec3 angularVelocity, Shader shader); glm::vec3 velocity, glm::vec3 angularVelocity, Shader shader);
Object(); Object();
~Object(); ~Object();
void render(); void render();
private: private:
ACGL::OpenGL::SharedVertexArrayObject model; ACGL::OpenGL::SharedVertexArrayObject model;
ACGL::OpenGL::SharedTexture2D texture; Material material;
glm::vec3 velocity; glm::vec3 velocity;
glm::vec3 angularVelocity; glm::vec3 angularVelocity;
ACGL::OpenGL::SharedShaderProgram shader; ACGL::OpenGL::SharedShaderProgram shader;

View File

@ -2,7 +2,7 @@
#define TERRAIN_HH_INCLUDED #define TERRAIN_HH_INCLUDED
#include <string> #include <string>
#include "texture.hh" #include "material.hh"
#include <fstream> #include <fstream>
#include <netinet/in.h> #include <netinet/in.h>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh> #include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
@ -10,12 +10,12 @@
class Terrain { class Terrain {
public: public:
Terrain(std::string filePath); Terrain(std::string filePath);
Terrain(); Terrain();
~Terrain(); ~Terrain();
void load(); void load();
void render(); void render();
private: private:
Texture texture; Material material;
std::string filePath; std::string filePath;
unsigned int heightmapWidth, heightmapHeight; unsigned int heightmapWidth, heightmapHeight;
float** heightmap; //can be accessed like 'float[][]' float** heightmap; //can be accessed like 'float[][]'