Adding textures capabilities

* Added Texures to the two sample cubes
* Modified mesh structure
	- mesh now contains indices and vertices
	- Vertices contain vertices and uv's (later on they will also
	contain normals)

Solution definitely not perfect and needs improvement.
This commit is contained in:
2022-06-05 01:44:54 +02:00
parent d019155d10
commit 16b61986a1
17 changed files with 8412 additions and 272 deletions

View File

@ -1,13 +1,20 @@
#pragma once
#include <vector>
#include <glm/glm.hpp>
namespace BarinkEngine{
class Mesh {
public:
std::vector<glm::vec3> vertices;
std::vector<unsigned int > elements;
std::vector<glm::vec2> uv;
};
#pragma once
#include <vector>
#include <glm/glm.hpp>
namespace BarinkEngine{
struct Vertex {
glm::vec3 vertices;
glm::vec2 uv;
};
class Mesh {
public:
std::vector<Vertex> vertices;
std::vector<unsigned int > elements;
};
}

View File

@ -3,6 +3,7 @@
#include "Mesh.h"
#include "Buffer.h"
#include "Material.h"
#include "Texture.h"
#include "VertexArray.h"
#include "Scene.h"
@ -14,10 +15,13 @@ public:
*/
Buffer vertexBuffer;
Buffer elementBuffer;
//Buffer uv;
VertexArray VAO;
GLuint UV_id;
Material* material;
Texture* texture;
Shader* shader;

View File

@ -10,7 +10,7 @@
class Shader {
private:
int id;
char* readFile (const char* filePath);
public:
Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
@ -22,5 +22,6 @@ class Shader {
void setUniformFloat(std::string uniformName, float value)const;
void setUniformInt(std::string uniformName, int value) const ;
int id;
};

View File

@ -0,0 +1,18 @@
#pragma once
#include <spdlog/spdlog.h>
#include <string>
class Texture {
public:
Texture(const std::string texturePath);
void Bind();
void Unbind();
private:
unsigned int Id;
};

File diff suppressed because it is too large Load Diff