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

@ -32,4 +32,10 @@ void transformWindow(Transform& transform, std::string PanelName) {
ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]);
ImGui::End();
}
void materialWindow(Material& material, std::string PanelName) {
ImGui::Begin(PanelName.c_str());
ImGui::ColorPicker3("Color:", &material.Color[0]);
ImGui::End();
}

View File

@ -1,7 +1,8 @@
#pragma once
#include "imgui.h"
#include <BarinkEngine.h>
void CameraTool(Camera* camera);
void ScriptingTool(char* code);
void transformWindow(Transform& transform, std::string PanelName);
#pragma once
#include "imgui.h"
#include <BarinkEngine.h>
void CameraTool(Camera* camera);
void ScriptingTool(char* code);
void transformWindow(Transform& transform, std::string PanelName);
void materialWindow(Material& material, std::string PanelName);

View File

@ -7,11 +7,15 @@
* Define globals
*/
Camera* cam;
Renderable* Cube;
Renderable* Cube2;
Shader* shader;
Renderable* Cube;
Material* matCube;
Texture* textureCube;
Renderable* Cube2;
Material* matCube2;
char* code = new char[254];
@ -54,6 +58,8 @@ void Start() {
shader = new Shader(vertexShaderSource, fragmentShaderSource);
textureCube = new Texture("build/SandboxApplication/Debug/die.jpg");
matCube = new Material(*shader);
matCube->Color = glm::vec3(1.0, 0.0, 0.0);
@ -67,7 +73,17 @@ void Start() {
Cube2 = Renderable::Load();
Cube->addChild(*Cube2);
cam = new Camera(glm::vec3(0.0f, 1.5f, -10.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
Cube->shader = shader;
Cube2->shader = shader;
Cube->texture = textureCube;
Cube2->texture = textureCube;
Cube2->transform.Position = glm::vec3(-9.0f, 0.0f, 0.0f);
Cube->transform.Position = glm::vec3(-8.0f, 0.0f, -2.0f);
cam = new Camera(glm::vec3(0.0f, 1.5f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f);
memset(code, '\0', 254);
@ -98,6 +114,9 @@ void ImmediateGraphicsDraw() {
transformWindow(Cube2->transform, "Transform (Cube2)");
materialWindow(*matCube, "Material Cube");
materialWindow(*matCube2, "Material Cube2");
}