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:
		@ -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;
 | 
			
		||||
	
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										18
									
								
								BarinkEngine/Include/Graphics/Texture.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								BarinkEngine/Include/Graphics/Texture.h
									
									
									
									
									
										Normal 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;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										8007
									
								
								BarinkEngine/Include/Graphics/stb_image.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8007
									
								
								BarinkEngine/Include/Graphics/stb_image.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user