Compare commits
4 Commits
82e0f473fb
...
Feature/In
Author | SHA1 | Date | |
---|---|---|---|
3c30bf7fb7 | |||
85f9c78adf | |||
4df6cfba90 | |||
7b9685c381 |
@ -1,29 +1,49 @@
|
|||||||
#include "BarinkEngine.h"
|
#include "BarinkEngine.h"
|
||||||
#include <phonon.h>
|
|
||||||
|
|
||||||
EngineStatistics* ES;
|
EngineStatistics* ES;
|
||||||
|
BarinkEngine::InputManager InputSystem;
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
// Setup performance sampler
|
// Setup performance sampler
|
||||||
PerfomanceSamplerInit();
|
PerfomanceSamplerInit();
|
||||||
|
|
||||||
|
|
||||||
// Startup services
|
// Create the window
|
||||||
BarinkWindow MainWindow = BarinkWindow(800, 600);
|
BarinkWindow MainWindow = BarinkWindow(800, 600);
|
||||||
|
|
||||||
|
// =================================================
|
||||||
|
// Startup services
|
||||||
|
// =================================================
|
||||||
|
|
||||||
|
// Startup Renderer
|
||||||
BarinkEngine::Renderer renderer = BarinkEngine::Renderer();
|
BarinkEngine::Renderer renderer = BarinkEngine::Renderer();
|
||||||
BarinkEngine::InputManager InputSystem = BarinkEngine::InputManager();
|
|
||||||
|
|
||||||
|
// Startup InputManager
|
||||||
|
InputSystem = BarinkEngine::InputManager();
|
||||||
|
|
||||||
InputSystem.attach(&MainWindow);
|
InputSystem.attach(&MainWindow);
|
||||||
|
InputSystem.setupGLFWInput(MainWindow.windowptr());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Startup GUI System
|
||||||
GUIManager GUISystem = GUIManager(&MainWindow);
|
GUIManager GUISystem = GUIManager(&MainWindow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Enable depth testing
|
||||||
|
// NOTE: TODO Move this into the renderer
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// First call to setup game
|
// First call to setup game
|
||||||
Start();
|
Start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Runtime loop
|
// Runtime loop
|
||||||
while (!MainWindow.WindowShouldClose()) {
|
while (!MainWindow.WindowShouldClose()) {
|
||||||
|
|
||||||
@ -53,6 +73,9 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
// Shutdown Services
|
// Shutdown Services
|
||||||
delete ES;
|
delete ES;
|
||||||
|
InputSystem.detach(&MainWindow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
25
BarinkEngine/EventSystem/EventEmitter.cpp
Normal file
25
BarinkEngine/EventSystem/EventEmitter.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "../Include/EventSystem/EventEmitter.h"
|
||||||
|
|
||||||
|
|
||||||
|
void EventEmitter::Subscribe(EventListener& subscriber)
|
||||||
|
{
|
||||||
|
subscribers.push_back(&subscriber);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventEmitter::Unsubscribe(EventListener& subscriber)
|
||||||
|
{
|
||||||
|
subscribers.remove(&subscriber);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventEmitter::EmitEvent(Event& incident)
|
||||||
|
{
|
||||||
|
// Notify all subscribers an event has taken place
|
||||||
|
for (auto it = subscribers.begin(); it != subscribers.end(); ++it)
|
||||||
|
{
|
||||||
|
(*it)->ReceiveEvent(incident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EventEmitter::EventEmitter() {
|
||||||
|
subscribers = std::list<EventListener*>{};
|
||||||
|
}
|
@ -11,16 +11,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class ModelImporter {
|
class ModelImporter {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::vector<BarinkEngine::Mesh> Import(std::string path);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ImportFBX(std::string path);
|
|
||||||
void ImportBlend(std::string path);
|
|
||||||
void ImportGLTF(std::string path);
|
|
||||||
void ImportOBJ(std::string path);
|
|
||||||
static BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene);
|
static BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene);
|
||||||
static std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene);
|
static std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene);
|
||||||
|
|
||||||
public:
|
|
||||||
void Import(std::string path);
|
|
||||||
|
|
||||||
static std::vector<BarinkEngine::Mesh> Test();
|
|
||||||
};
|
};
|
@ -13,6 +13,8 @@
|
|||||||
#include "Graphics/Renderer.h"
|
#include "Graphics/Renderer.h"
|
||||||
#include "Graphics/GUI/GUIManager.h"
|
#include "Graphics/GUI/GUIManager.h"
|
||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
|
|
||||||
|
|
||||||
#include "PerfCounter.h"
|
#include "PerfCounter.h"
|
||||||
|
|
||||||
|
|
||||||
@ -20,3 +22,5 @@ extern void Start();
|
|||||||
extern void Update();
|
extern void Update();
|
||||||
extern void ImmediateGraphicsDraw();
|
extern void ImmediateGraphicsDraw();
|
||||||
extern void Stop();
|
extern void Stop();
|
||||||
|
|
||||||
|
extern BarinkEngine::InputManager InputSystem;
|
9
BarinkEngine/Include/EventSystem/Event.h
Normal file
9
BarinkEngine/Include/EventSystem/Event.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
};
|
18
BarinkEngine/Include/EventSystem/EventEmitter.h
Normal file
18
BarinkEngine/Include/EventSystem/EventEmitter.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Event.h"
|
||||||
|
#include "EventListener.h"
|
||||||
|
|
||||||
|
class EventEmitter {
|
||||||
|
public:
|
||||||
|
void Subscribe (EventListener& subscriber);
|
||||||
|
void Unsubscribe(EventListener& subscriber);
|
||||||
|
void EmitEvent(Event& incident);
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::list<EventListener*> subscribers;
|
||||||
|
|
||||||
|
|
||||||
|
EventEmitter();
|
||||||
|
|
||||||
|
};
|
5
BarinkEngine/Include/EventSystem/EventListener.cpp
Normal file
5
BarinkEngine/Include/EventSystem/EventListener.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "EventListener.h"
|
||||||
|
|
||||||
|
void EventListener::ReceiveEvent(Event& incident)
|
||||||
|
{
|
||||||
|
}
|
8
BarinkEngine/Include/EventSystem/EventListener.h
Normal file
8
BarinkEngine/Include/EventSystem/EventListener.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Event.h"
|
||||||
|
#include <list>
|
||||||
|
class EventListener{
|
||||||
|
public:
|
||||||
|
virtual void ReceiveEvent(Event& incident);
|
||||||
|
|
||||||
|
};
|
18
BarinkEngine/Include/EventSystem/InputSystemEvents.h
Normal file
18
BarinkEngine/Include/EventSystem/InputSystemEvents.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct KEY_DOWN_EVENT : public Event {
|
||||||
|
public:
|
||||||
|
int scancode;
|
||||||
|
int keycode;
|
||||||
|
int mods;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KEY_UP_EVENT : public Event {
|
||||||
|
public:
|
||||||
|
int scancode;
|
||||||
|
int keycode;
|
||||||
|
int mods;
|
||||||
|
|
||||||
|
};
|
@ -28,10 +28,10 @@ public:
|
|||||||
|
|
||||||
~Renderable();
|
~Renderable();
|
||||||
|
|
||||||
static Renderable* Load();
|
static Renderable* Load(std::string& path);
|
||||||
void Draw();
|
void Draw();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<BarinkEngine::Mesh> meshes;
|
std::vector<BarinkEngine::Mesh> meshes;
|
||||||
Renderable();
|
Renderable(std::string& path);
|
||||||
};
|
};
|
@ -3,12 +3,13 @@
|
|||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include "../Include/EventSystem/EventListener.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BarinkWindow{
|
class BarinkWindow : EventListener {
|
||||||
private:
|
private:
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
bool FullScreen;
|
bool FullScreen;
|
||||||
@ -18,12 +19,15 @@ class BarinkWindow{
|
|||||||
static bool InitGLFW();
|
static bool InitGLFW();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BarinkWindow(const int width, const int height);
|
BarinkWindow(const int width, const int height);
|
||||||
~BarinkWindow();
|
~BarinkWindow();
|
||||||
|
|
||||||
GLFWwindow* windowptr();
|
GLFWwindow* windowptr();
|
||||||
|
|
||||||
|
void ReceiveEvent(Event& incident) override;
|
||||||
bool WindowShouldClose();
|
bool WindowShouldClose();
|
||||||
|
|
||||||
void Poll();
|
void Poll();
|
||||||
|
14
BarinkEngine/Include/Input/GLFWInput.h
Normal file
14
BarinkEngine/Include/Input/GLFWInput.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "GLFW/glfw3.h"
|
||||||
|
|
||||||
|
namespace BarinkEngine {
|
||||||
|
namespace Input {
|
||||||
|
|
||||||
|
void BE_GLFW_KEYS(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||||
|
void BE_GLFW_CURSOR_POSITION(GLFWwindow* window, double x, double y);
|
||||||
|
void BE_GLFW_CURSOR_ENTER(GLFWwindow* window, int entered);
|
||||||
|
void BE_GLFW_MOUSE_BUTTON(GLFWwindow* window, int button, int action, int mods);
|
||||||
|
void BE_GLFW_SCROLL(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,29 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <list>
|
||||||
|
|
||||||
#include "Graphics/Window.h"
|
#include "Graphics/Window.h"
|
||||||
|
#include "EventSystem/EventEmitter.h"
|
||||||
|
#include "../Include/Input/GLFWInput.h"
|
||||||
|
#include "BarinkEngine.h"
|
||||||
|
|
||||||
namespace BarinkEngine {
|
namespace BarinkEngine {
|
||||||
|
|
||||||
class InputManager {
|
class InputManager : public EventEmitter {
|
||||||
public:
|
public:
|
||||||
InputManager();
|
InputManager();
|
||||||
|
|
||||||
void PollEvents();
|
void PollEvents();
|
||||||
|
|
||||||
void attach(BarinkWindow* window);
|
void attach(BarinkWindow* window);
|
||||||
|
void detach(BarinkWindow* window);
|
||||||
|
|
||||||
|
|
||||||
|
void setupGLFWInput(GLFWwindow* window);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<BarinkWindow*> windows;
|
std::list<BarinkWindow*> windows;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
104
BarinkEngine/Input/GLFWInput.cpp
Normal file
104
BarinkEngine/Input/GLFWInput.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#include "BarinkEngine.h"
|
||||||
|
#include "../Include/Input/GLFWInput.h"
|
||||||
|
#include "../Include/EventSystem/InputSystemEvents.h"
|
||||||
|
#include "../Include/Input/InputManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace BarinkEngine {
|
||||||
|
namespace Input {
|
||||||
|
|
||||||
|
|
||||||
|
void BE_GLFW_KEYS(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GLFW_KEY_DOWN: {
|
||||||
|
KEY_DOWN_EVENT keydown{};
|
||||||
|
keydown.name = "KEY::DOWN";
|
||||||
|
keydown.mods = mods;
|
||||||
|
keydown.scancode = scancode;
|
||||||
|
keydown.keycode = key;
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(keydown);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
case GLFW_KEY_UP: {
|
||||||
|
KEY_UP_EVENT keyup{};
|
||||||
|
keyup.name = "KEY::DOWN";
|
||||||
|
keyup.mods = mods;
|
||||||
|
keyup.scancode = scancode;
|
||||||
|
keyup.keycode = key;
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(keyup);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
Event KeyEvent{};
|
||||||
|
KeyEvent.name = "KEY";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(KeyEvent);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BE_GLFW_CURSOR_POSITION(GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
Event CursorPosUpdate{};
|
||||||
|
CursorPosUpdate.name = "UPDATE::CURSOR:POSITION";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(CursorPosUpdate);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BE_GLFW_CURSOR_ENTER(GLFWwindow* window, int entered)
|
||||||
|
{
|
||||||
|
if (entered) {
|
||||||
|
Event mouseEntered{};
|
||||||
|
mouseEntered.name = "Mouse Entered Window's confines!";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(mouseEntered);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Event mouseLeft{};
|
||||||
|
mouseLeft.name = "Mouse Left Window's confines!";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(mouseLeft);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BE_GLFW_MOUSE_BUTTON(GLFWwindow* window, int button, int action, int mods)
|
||||||
|
{
|
||||||
|
Event MouseButtonEvent{};
|
||||||
|
MouseButtonEvent.name = "MOUSEBUTTON";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(MouseButtonEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BE_GLFW_SCROLL(GLFWwindow* window, double xoffset, double yoffset)
|
||||||
|
{
|
||||||
|
Event ScrollEvent{};
|
||||||
|
ScrollEvent.name = "SCROLL";
|
||||||
|
|
||||||
|
InputSystem.EmitEvent(ScrollEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,44 @@
|
|||||||
#include "Input/InputManager.h"
|
#include "Input/InputManager.h"
|
||||||
|
|
||||||
void BarinkEngine::InputManager::PollEvents()
|
namespace BarinkEngine {
|
||||||
|
|
||||||
|
void InputManager::PollEvents()
|
||||||
{
|
{
|
||||||
for (std::vector<BarinkWindow*>::iterator it = windows.begin(); it != windows.end(); ++it) {
|
for (auto it = windows.begin(); it != windows.end(); ++it) {
|
||||||
(*it)->Poll();
|
(*it)->Poll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BarinkEngine::InputManager::attach(BarinkWindow* window)
|
|
||||||
{
|
void InputManager::setupGLFWInput(GLFWwindow* window) {
|
||||||
windows.push_back(window);
|
// Attach callbacks
|
||||||
|
glfwSetKeyCallback(window, BarinkEngine::Input::BE_GLFW_KEYS);
|
||||||
|
glfwSetCursorPosCallback(window, BarinkEngine::Input::BE_GLFW_CURSOR_POSITION);
|
||||||
|
glfwSetCursorEnterCallback(window, BarinkEngine::Input::BE_GLFW_CURSOR_ENTER);
|
||||||
|
glfwSetMouseButtonCallback(window, BarinkEngine::Input::BE_GLFW_MOUSE_BUTTON);
|
||||||
|
glfwSetScrollCallback(window, BarinkEngine::Input::BE_GLFW_SCROLL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BarinkEngine::InputManager::InputManager()
|
|
||||||
|
void InputManager::attach(BarinkWindow* window)
|
||||||
{
|
{
|
||||||
windows = std::vector<BarinkWindow*>();
|
windows.push_back(window);
|
||||||
|
this->Subscribe((EventListener&)(*window));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputManager::detach(BarinkWindow* window)
|
||||||
|
{
|
||||||
|
windows.remove(window);
|
||||||
|
this->Unsubscribe((EventListener&)*window);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InputManager::InputManager() : EventEmitter()
|
||||||
|
{
|
||||||
|
windows = std::list<BarinkWindow*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,66 +1,13 @@
|
|||||||
#include "AssetManager/ModelImporter.h"
|
#include "AssetManager/ModelImporter.h"
|
||||||
|
|
||||||
|
|
||||||
void ModelImporter::ImportFBX(std::string path)
|
std::vector<BarinkEngine::Mesh> ModelImporter::Import(std::string path)
|
||||||
{
|
{
|
||||||
//spdlog::warn("ImportFBX not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelImporter::ImportBlend(std::string path)
|
|
||||||
{
|
|
||||||
//spdlog::warn("ImportBlend not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelImporter::ImportGLTF(std::string path)
|
|
||||||
{
|
|
||||||
//spdlog::warn("ImportGLTF not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelImporter::ImportOBJ(std::string path)
|
|
||||||
{
|
|
||||||
//spdlog::warn("ImportOBJ not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModelImporter::Import(std::string path)
|
|
||||||
{
|
|
||||||
//spdlog::warn("Import not implemented!");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<BarinkEngine::Mesh> ModelImporter::Test() {
|
|
||||||
|
|
||||||
/*
|
|
||||||
spdlog::info("====== Tiny GLTF ======");
|
|
||||||
tinygltf::Model loadedModel;
|
|
||||||
tinygltf::TinyGLTF loader;
|
|
||||||
std::string error;
|
|
||||||
std::string warn;
|
|
||||||
bool ret = loader.LoadASCIIFromFile(&loadedModel, &error, &warn, "./Build/SandboxApplication/Debug/sponza.gltf");
|
|
||||||
|
|
||||||
if (!warn.empty())
|
|
||||||
spdlog::warn("TinyGLTF Warning: {}", warn);
|
|
||||||
if (!error.empty())
|
|
||||||
spdlog::error("TinyGLTF Error: {}", error);
|
|
||||||
if (!ret) {
|
|
||||||
spdlog::error("TinyGLTF Error: Failed to parse glTF");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
spdlog::info("Meshes in model: {}", loadedModel.meshes.size());
|
|
||||||
spdlog::info("Primitives in mesh: {}", loadedModel.meshes[0].primitives.size());
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//spdlog::info("======= Assimp ======");
|
|
||||||
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile("build/SandboxApplication/Debug/Cube.obj", aiProcess_Triangulate | aiProcess_FlipUVs);
|
const aiScene* scene = importer.ReadFile(path.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs);
|
||||||
|
|
||||||
aiNode* currentNode = scene->mRootNode;
|
aiNode* currentNode = scene->mRootNode;
|
||||||
|
|
||||||
return processNode(currentNode, scene);
|
return processNode(currentNode, scene);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene) {
|
std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene) {
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
#include "PerfCounter.h"
|
#include "PerfCounter.h"
|
||||||
|
|
||||||
|
|
||||||
Renderable* Renderable::Load()
|
Renderable* Renderable::Load(std::string& path)
|
||||||
{
|
{
|
||||||
return new Renderable();
|
return new Renderable(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderable::Renderable()
|
Renderable::Renderable(std::string& path)
|
||||||
{
|
{
|
||||||
meshes = ModelImporter::Test();
|
meshes = ModelImporter::Import(path);
|
||||||
|
|
||||||
transform.Scale = glm::vec3(1.0f);
|
transform.Scale = glm::vec3(1.0f);
|
||||||
transform.Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
|
transform.Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "Graphics/Shader.h"
|
#include "Graphics/Shader.h"
|
||||||
|
#include "spdlog/spdlog.h"
|
||||||
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
|
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
|
||||||
{
|
{
|
||||||
char infoLog[512];
|
char infoLog[512];
|
||||||
@ -15,7 +15,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
|||||||
glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes);
|
glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes);
|
||||||
if(!succes){
|
if(!succes){
|
||||||
glGetShaderInfoLog(vertId, 512, NULL, infoLog);
|
glGetShaderInfoLog(vertId, 512, NULL, infoLog);
|
||||||
//spdlog::error( "Vertex shader has compile error {}", infoLog);
|
spdlog::error( "Vertex shader has compile error {}", infoLog);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
|||||||
glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes);
|
glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes);
|
||||||
if(!succes){
|
if(!succes){
|
||||||
glGetShaderInfoLog(fragId, 512, NULL, infoLog);
|
glGetShaderInfoLog(fragId, 512, NULL, infoLog);
|
||||||
//spdlog::error("Fragment shader has compile error {}", infoLog);
|
spdlog::error("Fragment shader has compile error {}", infoLog);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ char* Shader::readFile (const char* filePath){
|
|||||||
file.open(filePath);
|
file.open(filePath);
|
||||||
|
|
||||||
if(file.is_open() == false){
|
if(file.is_open() == false){
|
||||||
//spdlog::info("File not found.");
|
spdlog::info("File not found.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
#version 440 core
|
#version 440 core
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
uniform vec3 Color;
|
uniform vec3 Color;
|
||||||
|
|
||||||
in vec2 TexCoord;
|
in vec2 TexCoord;
|
||||||
|
|
||||||
uniform sampler2D Texture;
|
uniform sampler2D Texture;
|
||||||
|
|
||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
FragColor = mix ( texture(Texture, TexCoord), vec4(Color, 1.0f));
|
FragColor = mix ( texture(Texture, TexCoord), vec4(Color, 1.0f), 0.5f);
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
#include "Graphics/Window.h"
|
#include "Graphics/Window.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
#include "../Include/EventSystem/Event.h"
|
||||||
|
|
||||||
bool BarinkWindow::InitGLFW(){
|
bool BarinkWindow::InitGLFW(){
|
||||||
if(!glfwInit())
|
if(!glfwInit())
|
||||||
@ -74,3 +75,13 @@ void BarinkWindow::SwapBuffers()
|
|||||||
{
|
{
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BarinkWindow::ReceiveEvent(Event& incident)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "EVENT RECEIVED: " << incident.name << std::endl;
|
||||||
|
|
||||||
|
}
|
@ -13,29 +13,43 @@ project "BarinkEngine"
|
|||||||
|
|
||||||
"../libs/physx/physx/include",
|
"../libs/physx/physx/include",
|
||||||
"../libs/steam-audio/include",
|
"../libs/steam-audio/include",
|
||||||
|
|
||||||
"../libs/assimp/include",
|
"../libs/assimp/include",
|
||||||
|
|
||||||
|
|
||||||
"../libs/glad/include",
|
"../libs/glad/include",
|
||||||
|
|
||||||
"../libs/glfw/include",
|
"../libs/glfw/include",
|
||||||
-- "../libs/tinygltf",
|
|
||||||
"../libs/glew/include",
|
"../libs/glew/include",
|
||||||
"../libs/glm",
|
"../libs/glm",
|
||||||
|
|
||||||
"../libs/ImGui",
|
"../libs/ImGui",
|
||||||
|
}
|
||||||
|
|
||||||
|
links {
|
||||||
|
-- This needs to fall under the filter as the names can differ on different platforms
|
||||||
|
"phonon",
|
||||||
|
"lua54",
|
||||||
|
"spdlog",
|
||||||
|
"assimp-vc143-mtd",
|
||||||
|
"glfw3",
|
||||||
|
|
||||||
|
"ImGUI_Opengl3",
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
libdirs {
|
libdirs {
|
||||||
"../libs/steam-audio/lib/windows-x64",
|
"../libs/steam-audio/lib/windows-x64",
|
||||||
"../libs/lua",
|
"../libs/lua",
|
||||||
"../libs/spdlog/build/Release",
|
"../libs/spdlog/build/Release",
|
||||||
"../libs/assimp/lib/Debug",
|
"../libs/assimp/lib/Debug",
|
||||||
"../libs/glfw/build/src/Debug",
|
"../libs/glfw/build/src/Debug",
|
||||||
"../libs/ImGui"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
files {
|
files {
|
||||||
"../libs/ImGui/*.cpp",
|
|
||||||
"../libs/ImGui/backends/imgui_impl_glfw.cpp",
|
|
||||||
"../libs/ImGui/backends/imgui_impl_Opengl3.cpp",
|
|
||||||
"../libs/glad/src/glad.c",
|
"../libs/glad/src/glad.c",
|
||||||
|
|
||||||
"./*.cpp",
|
"./*.cpp",
|
||||||
@ -45,6 +59,7 @@ project "BarinkEngine"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filter { "system:windows"}
|
filter { "system:windows"}
|
||||||
prebuildcommands {
|
prebuildcommands {
|
||||||
-- Copy shaders
|
-- Copy shaders
|
||||||
@ -54,14 +69,7 @@ project "BarinkEngine"
|
|||||||
"copy graphics\\shaders\\RenderSurfaceVert.shader ..\\build\\SandboxApplication\\Debug\\RenderSurface.vs"
|
"copy graphics\\shaders\\RenderSurfaceVert.shader ..\\build\\SandboxApplication\\Debug\\RenderSurface.vs"
|
||||||
}
|
}
|
||||||
|
|
||||||
links {
|
|
||||||
-- This needs to fall under the filter as the names can differ on different platforms
|
|
||||||
"phonon",
|
|
||||||
"lua54",
|
|
||||||
"spdlog",
|
|
||||||
"assimp-vc143-mtd",
|
|
||||||
"glfw3"
|
|
||||||
}
|
|
||||||
|
|
||||||
filter { "system:linux" }
|
filter { "system:linux" }
|
||||||
prebuildcommands {
|
prebuildcommands {
|
||||||
@ -71,3 +79,5 @@ project "BarinkEngine"
|
|||||||
"cp graphics/shaders/RenderSurfaceFrag.shader ../build/SandboxApplication/Debug/RenderSurface.fs",
|
"cp graphics/shaders/RenderSurfaceFrag.shader ../build/SandboxApplication/Debug/RenderSurface.fs",
|
||||||
"cp graphics/shaders/RenderSurfaceVert.shader ../build/SandboxApplication/Debug/RenderSurface.vs"
|
"cp graphics/shaders/RenderSurfaceVert.shader ../build/SandboxApplication/Debug/RenderSurface.vs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include('../ImGui')
|
||||||
|
18
ImGui/premake5.lua
Normal file
18
ImGui/premake5.lua
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
project "ImGUI_Opengl3"
|
||||||
|
kind "StaticLib"
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
"../libs/glfw/include",
|
||||||
|
"../libs/ImGui"
|
||||||
|
}
|
||||||
|
|
||||||
|
files {
|
||||||
|
"../libs/ImGui/*.cpp",
|
||||||
|
"../libs/ImGui/backends/imgui_impl_glfw.cpp",
|
||||||
|
"../libs/ImGui/backends/imgui_impl_Opengl3.cpp",
|
||||||
|
}
|
||||||
|
|
||||||
|
libdirs{
|
||||||
|
"../libs/ImGui",
|
||||||
|
"../libs/glad"
|
||||||
|
}
|
BIN
Manuals/GLSL.std.450.pdf
Normal file
BIN
Manuals/GLSL.std.450.pdf
Normal file
Binary file not shown.
BIN
Manuals/SPIRV.pdf
Normal file
BIN
Manuals/SPIRV.pdf
Normal file
Binary file not shown.
@ -58,7 +58,7 @@ void Start() {
|
|||||||
|
|
||||||
shader = new Shader(vertexShaderSource, fragmentShaderSource);
|
shader = new Shader(vertexShaderSource, fragmentShaderSource);
|
||||||
|
|
||||||
textureCube = new Texture("build/SandboxApplication/Debug/die.jpg");
|
textureCube = new Texture("build/SandboxApplication/Debug/Textures/wall.jpg");
|
||||||
|
|
||||||
matCube = new Material(*shader);
|
matCube = new Material(*shader);
|
||||||
matCube->Color = glm::vec3(1.0, 0.0, 0.0);
|
matCube->Color = glm::vec3(1.0, 0.0, 0.0);
|
||||||
@ -66,11 +66,13 @@ void Start() {
|
|||||||
matCube2 = new Material(*shader);
|
matCube2 = new Material(*shader);
|
||||||
matCube2->Color = glm::vec3(0.0, 1.0f, 0.0);
|
matCube2->Color = glm::vec3(0.0, 1.0f, 0.0);
|
||||||
|
|
||||||
|
std::string cubePath = "build/SandboxApplication/Debug/Models/Cube.obj";
|
||||||
|
std::string lanternPath = "build/SandboxApplication/Debug/Models/Latern.gltf";
|
||||||
/*
|
/*
|
||||||
* load meshes
|
* load meshes
|
||||||
*/
|
*/
|
||||||
Cube = Renderable::Load();
|
Cube = Renderable::Load(lanternPath);
|
||||||
Cube2 = Renderable::Load();
|
Cube2 = Renderable::Load(cubePath);
|
||||||
Cube->addChild(*Cube2);
|
Cube->addChild(*Cube2);
|
||||||
|
|
||||||
Cube->shader = shader;
|
Cube->shader = shader;
|
||||||
|
Reference in New Issue
Block a user