Compare commits
	
		
			1 Commits
		
	
	
		
			3fa5455b43
			...
			Feature/In
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3c30bf7fb7 | 
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1 @@
 | 
				
			|||||||
*.png filter=lfs diff=lfs merge=lfs -text
 | 
					*.png filter=lfs diff=lfs merge=lfs -text
 | 
				
			||||||
*.webp filter=lfs diff=lfs merge=lfs -text
 | 
					 | 
				
			||||||
*.xcf filter=lfs diff=lfs merge=lfs -text
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,11 +1,12 @@
 | 
				
			|||||||
**/build/
 | 
					build/
 | 
				
			||||||
**/intermediates/
 | 
					intermediates/
 | 
				
			||||||
tools/
 | 
					tools/
 | 
				
			||||||
*.make
 | 
					*.make
 | 
				
			||||||
Makefile
 | 
					Makefile
 | 
				
			||||||
.vscode/
 | 
					.vscode/
 | 
				
			||||||
libs/lua
 | 
					libs/lua
 | 
				
			||||||
libs/glad
 | 
					libs/glad
 | 
				
			||||||
 | 
					Debug/
 | 
				
			||||||
*.sln
 | 
					*.sln
 | 
				
			||||||
*.vcxproj
 | 
					*.vcxproj
 | 
				
			||||||
*.vcxproj.filters
 | 
					*.vcxproj.filters
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										17
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@ -4,10 +4,12 @@
 | 
				
			|||||||
[submodule "glm"]
 | 
					[submodule "glm"]
 | 
				
			||||||
	path = libs/glm
 | 
						path = libs/glm
 | 
				
			||||||
	url = https://github.com/nigelbarink/glm.git
 | 
						url = https://github.com/nigelbarink/glm.git
 | 
				
			||||||
	ignore = untracked
 | 
					 | 
				
			||||||
[submodule "spdlog"]
 | 
					[submodule "spdlog"]
 | 
				
			||||||
	path = libs/spdlog
 | 
						path = libs/spdlog
 | 
				
			||||||
	url = https://github.com/nigelbarink/spdlog.git
 | 
						url = https://github.com/nigelbarink/spdlog.git
 | 
				
			||||||
 | 
					[submodule "tinygltf"]
 | 
				
			||||||
 | 
						path = libs/tinygltf
 | 
				
			||||||
 | 
						url = https://github.com/syoyo/tinygltf.git
 | 
				
			||||||
[submodule "GorrillaAudio"]
 | 
					[submodule "GorrillaAudio"]
 | 
				
			||||||
	path = libs/GorillaAudio
 | 
						path = libs/GorillaAudio
 | 
				
			||||||
	url = https://github.com/mewspring/gorilla-audio.git
 | 
						url = https://github.com/mewspring/gorilla-audio.git
 | 
				
			||||||
@ -20,19 +22,6 @@
 | 
				
			|||||||
[submodule "libs/steam-audio"]
 | 
					[submodule "libs/steam-audio"]
 | 
				
			||||||
	path = libs/steam-audio
 | 
						path = libs/steam-audio
 | 
				
			||||||
	url = https://github.com/ValveSoftware/steam-audio.git
 | 
						url = https://github.com/ValveSoftware/steam-audio.git
 | 
				
			||||||
	ignore = untracked
 | 
					 | 
				
			||||||
[submodule "libs/physx"]
 | 
					[submodule "libs/physx"]
 | 
				
			||||||
	path = libs/physx
 | 
						path = libs/physx
 | 
				
			||||||
	url = https://git.barink.dev/Nigel/PhysX.git
 | 
						url = https://git.barink.dev/Nigel/PhysX.git
 | 
				
			||||||
[submodule "libs/entt"]
 | 
					 | 
				
			||||||
	path = libs/entt
 | 
					 | 
				
			||||||
	url = https://github.com/skypjack/entt.git
 | 
					 | 
				
			||||||
[submodule "libs/guizmo"]
 | 
					 | 
				
			||||||
	path = libs/guizmo
 | 
					 | 
				
			||||||
	url = https://github.com/CedricGuillemet/ImGuizmo.git
 | 
					 | 
				
			||||||
[submodule "libs/yaml-cpp"]
 | 
					 | 
				
			||||||
	path = libs/yaml-cpp
 | 
					 | 
				
			||||||
	url = https://git.barink.dev/Nigel/yaml-cpp.git
 | 
					 | 
				
			||||||
[submodule "libs/nativefiledialog"]
 | 
					 | 
				
			||||||
	path = libs/nativefiledialog
 | 
					 | 
				
			||||||
	url = https://git.barink.dev/Nigel/nativefiledialog.git
 | 
					 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "cmake.configureOnOpen": true,
 | 
				
			||||||
 | 
					    "files.associations": {
 | 
				
			||||||
 | 
					        "iosfwd": "cpp"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										82
									
								
								BarinkEngine/BarinkEngine.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								BarinkEngine/BarinkEngine.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,82 @@
 | 
				
			|||||||
 | 
					#include "BarinkEngine.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					EngineStatistics* ES;
 | 
				
			||||||
 | 
					BarinkEngine::InputManager InputSystem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(int argc, char* argv[]) {
 | 
				
			||||||
 | 
						// Setup performance sampler 
 | 
				
			||||||
 | 
						PerfomanceSamplerInit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Create the window 
 | 
				
			||||||
 | 
						BarinkWindow MainWindow = BarinkWindow(800, 600);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// =================================================
 | 
				
			||||||
 | 
						// Startup services 
 | 
				
			||||||
 | 
						// =================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Startup Renderer
 | 
				
			||||||
 | 
						BarinkEngine::Renderer renderer = BarinkEngine::Renderer();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Startup InputManager
 | 
				
			||||||
 | 
						InputSystem = BarinkEngine::InputManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						InputSystem.attach(&MainWindow);
 | 
				
			||||||
 | 
						InputSystem.setupGLFWInput(MainWindow.windowptr());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Startup GUI System
 | 
				
			||||||
 | 
						GUIManager GUISystem = GUIManager(&MainWindow);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Enable depth testing 
 | 
				
			||||||
 | 
						// NOTE: TODO Move this into the renderer
 | 
				
			||||||
 | 
						glEnable(GL_DEPTH_TEST);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// First call to setup game
 | 
				
			||||||
 | 
						Start();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						// Runtime loop
 | 
				
			||||||
 | 
						while (!MainWindow.WindowShouldClose()) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							SamplePerformance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Execute main logic 
 | 
				
			||||||
 | 
							InputSystem.PollEvents();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Update();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							renderer.Render();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ImmediateGraphicsDraw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							GUISystem.Render();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							MainWindow.SwapBuffers();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Shutdown game
 | 
				
			||||||
 | 
						Stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Shutdown Services
 | 
				
			||||||
 | 
						delete ES;
 | 
				
			||||||
 | 
						InputSystem.detach(&MainWindow);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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*>{};
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										23
									
								
								BarinkEngine/Include/AssetManager/ModelImporter.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								BarinkEngine/Include/AssetManager/ModelImporter.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#define TINYGLTF_IMPLEMENTATION
 | 
				
			||||||
 | 
					#define STB_IMAGE_IMPLEMENTATION
 | 
				
			||||||
 | 
					#define STB_IMAGE_WRITE_IMPLEMENTATION
 | 
				
			||||||
 | 
					#define TINYGLTF_NO_EXTERNAL_IMAGE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Graphics/Mesh.h"
 | 
				
			||||||
 | 
					#include <assimp/Importer.hpp>
 | 
				
			||||||
 | 
					#include <assimp/scene.h>
 | 
				
			||||||
 | 
					#include <assimp/postprocess.h> 
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ModelImporter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						static std::vector<BarinkEngine::Mesh>  Import(std::string path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						static BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene);
 | 
				
			||||||
 | 
						static std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										26
									
								
								BarinkEngine/Include/BarinkEngine.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								BarinkEngine/Include/BarinkEngine.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "glm/glm.hpp"
 | 
				
			||||||
 | 
					#include "graphics/Shader.h"
 | 
				
			||||||
 | 
					#include "graphics/Window.h"
 | 
				
			||||||
 | 
					#include "graphics/Texture.h"
 | 
				
			||||||
 | 
					#include "graphics/Camera.h"
 | 
				
			||||||
 | 
					#include "graphics/Renderable.h"
 | 
				
			||||||
 | 
					#include "Graphics/Material.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "spdlog/spdlog.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Input/InputManager.h"
 | 
				
			||||||
 | 
					#include "Graphics/Renderer.h"
 | 
				
			||||||
 | 
					#include "Graphics/GUI/GUIManager.h"
 | 
				
			||||||
 | 
					#include "Scene.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "PerfCounter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern void Start();
 | 
				
			||||||
 | 
					extern void Update();
 | 
				
			||||||
 | 
					extern void ImmediateGraphicsDraw();
 | 
				
			||||||
 | 
					extern void Stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern BarinkEngine::InputManager InputSystem;
 | 
				
			||||||
							
								
								
									
										12
									
								
								BarinkEngine/Include/Editor/EditorWindow.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								BarinkEngine/Include/Editor/EditorWindow.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class EditorWindow {
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
						std::string WindowTitle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						virtual void Show() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										19
									
								
								BarinkEngine/Include/Graphics/Buffer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								BarinkEngine/Include/Graphics/Buffer.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					class Buffer {
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						unsigned int id;
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int getBufferID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void createBuffer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void setBufferData(void* data, size_t dataSize, bool elementBuffer );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Bind(bool elementBuffer);
 | 
				
			||||||
 | 
						void Unbind(bool elementBuffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										22
									
								
								BarinkEngine/Include/Graphics/Camera.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								BarinkEngine/Include/Graphics/Camera.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <glm/glm.hpp>
 | 
				
			||||||
 | 
					#include <glm/gtc/matrix_transform.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Camera {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						glm::vec3 Position;
 | 
				
			||||||
 | 
						glm::vec3 Rotation;
 | 
				
			||||||
 | 
						float Zoom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Camera(glm::vec3 position, glm::vec3 rotation, float zoom );
 | 
				
			||||||
 | 
						~Camera();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glm::mat4 GetViewMatrix();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						glm::vec3 Front;  
 | 
				
			||||||
 | 
						glm::vec3 Right;
 | 
				
			||||||
 | 
						glm::vec3 Up;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										15
									
								
								BarinkEngine/Include/Graphics/GUI/GUIManager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								BarinkEngine/Include/Graphics/GUI/GUIManager.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "Graphics/Window.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class GUIManager {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						GUIManager(BarinkWindow* window);
 | 
				
			||||||
 | 
						~GUIManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Render();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						BarinkWindow* currentwindow;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										19
									
								
								BarinkEngine/Include/Graphics/Material.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								BarinkEngine/Include/Graphics/Material.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <glm/glm.hpp>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include "Shader.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Material {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						Material(const Shader& shader);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						void Apply();
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						glm::vec3 Color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						const Shader& shader;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										20
									
								
								BarinkEngine/Include/Graphics/Mesh.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								BarinkEngine/Include/Graphics/Mesh.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					#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;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										30
									
								
								BarinkEngine/Include/Graphics/RenderSurface.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								BarinkEngine/Include/Graphics/RenderSurface.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "BarinkEngine.h"
 | 
				
			||||||
 | 
					#include <vector>;
 | 
				
			||||||
 | 
					class RenderSurface 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						RenderSurface();
 | 
				
			||||||
 | 
						~RenderSurface();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						// would normally be a material
 | 
				
			||||||
 | 
						// however rendersurface is special and
 | 
				
			||||||
 | 
						// thus does not contain a material
 | 
				
			||||||
 | 
						Shader* shader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Basically a mesh
 | 
				
			||||||
 | 
						std::vector<glm::vec3> verts;
 | 
				
			||||||
 | 
						std::vector<unsigned int > indices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Buffer vertexBuffer;
 | 
				
			||||||
 | 
						Buffer elementBuffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VertexArray VAO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										37
									
								
								BarinkEngine/Include/Graphics/Renderable.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								BarinkEngine/Include/Graphics/Renderable.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					#include "Mesh.h"
 | 
				
			||||||
 | 
					#include "Buffer.h"
 | 
				
			||||||
 | 
					#include "Material.h"
 | 
				
			||||||
 | 
					#include "Texture.h"
 | 
				
			||||||
 | 
					#include "VertexArray.h"
 | 
				
			||||||
 | 
					#include "Scene.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Renderable  : public SceneNode {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						* NOTE: Should combine into a Mesh!!
 | 
				
			||||||
 | 
						*/
 | 
				
			||||||
 | 
						Buffer vertexBuffer;
 | 
				
			||||||
 | 
						Buffer elementBuffer;
 | 
				
			||||||
 | 
						//Buffer uv;
 | 
				
			||||||
 | 
						VertexArray VAO;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						GLuint UV_id;
 | 
				
			||||||
 | 
						Material* material;
 | 
				
			||||||
 | 
						Texture* texture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						Shader* shader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						~Renderable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static Renderable* Load(std::string& path);
 | 
				
			||||||
 | 
						void Draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						std::vector<BarinkEngine::Mesh> meshes;
 | 
				
			||||||
 | 
						Renderable(std::string& path);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										21
									
								
								BarinkEngine/Include/Graphics/Renderer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								BarinkEngine/Include/Graphics/Renderer.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "Graphics/Renderable.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace BarinkEngine {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						class Renderer {
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							Renderer();
 | 
				
			||||||
 | 
							~Renderer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void Render();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void Submit(Renderable* model);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							std::vector<Renderable*> models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										27
									
								
								BarinkEngine/Include/Graphics/Shader.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								BarinkEngine/Include/Graphics/Shader.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include <glm/glm.hpp>
 | 
				
			||||||
 | 
					#include <glm/gtc/type_ptr.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Shader {
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        char* readFile (const char* filePath);
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath);
 | 
				
			||||||
 | 
					        void Use();
 | 
				
			||||||
 | 
					        void setUniformMat4(std::string uniformName, glm::mat4 matrix4)const;
 | 
				
			||||||
 | 
					        void setUniformVec4(std::string uniformName, glm::vec4 vector4)const;
 | 
				
			||||||
 | 
					        void setUniformVec3(std::string uniformName, glm::vec3 vector3)const;
 | 
				
			||||||
 | 
					        void setUniformVec2(std::string uniformName, glm::vec2 vector2)const;
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										18
									
								
								BarinkEngine/Include/Graphics/VertexArray.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								BarinkEngine/Include/Graphics/VertexArray.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					#pragma once 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class VertexArray{
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					unsigned int id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					void Create();
 | 
				
			||||||
 | 
					void Bind();
 | 
				
			||||||
 | 
					void Unbind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void AttachAttribute(unsigned int index, int size, int stride);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										37
									
								
								BarinkEngine/Include/Graphics/Window.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								BarinkEngine/Include/Graphics/Window.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					#pragma once 
 | 
				
			||||||
 | 
					#define GLFW_STATIC
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					#include <GLFW/glfw3.h>
 | 
				
			||||||
 | 
					#include "../Include/EventSystem/EventListener.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class BarinkWindow : EventListener {
 | 
				
			||||||
 | 
					    private:
 | 
				
			||||||
 | 
					        GLFWwindow* window;
 | 
				
			||||||
 | 
					        bool FullScreen;
 | 
				
			||||||
 | 
					        bool VulkanSupported;
 | 
				
			||||||
 | 
					        int Width, Height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        static bool InitGLFW();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        BarinkWindow(const int width, const int height);
 | 
				
			||||||
 | 
					        ~BarinkWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        GLFWwindow* windowptr();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void ReceiveEvent(Event& incident) override;
 | 
				
			||||||
 | 
					        bool WindowShouldClose();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void Poll();
 | 
				
			||||||
 | 
					        void SwapBuffers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
							
								
								
									
										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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										29
									
								
								BarinkEngine/Include/Input/InputManager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								BarinkEngine/Include/Input/InputManager.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <list>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Graphics/Window.h"
 | 
				
			||||||
 | 
					#include "EventSystem/EventEmitter.h"
 | 
				
			||||||
 | 
					#include "../Include/Input/GLFWInput.h"
 | 
				
			||||||
 | 
					#include "BarinkEngine.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace BarinkEngine {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						class InputManager : public EventEmitter {
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							InputManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void PollEvents();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							void attach(BarinkWindow* window);
 | 
				
			||||||
 | 
							void detach(BarinkWindow* window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void setupGLFWInput(GLFWwindow* window);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							std::list<BarinkWindow*> windows;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										50
									
								
								BarinkEngine/Include/PerfCounter.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								BarinkEngine/Include/PerfCounter.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <chrono>
 | 
				
			||||||
 | 
					#include <imgui.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 struct EngineStatistics {
 | 
				
			||||||
 | 
						uint32_t lastSampleTime;
 | 
				
			||||||
 | 
						float frameTime;
 | 
				
			||||||
 | 
						uint32_t verts;
 | 
				
			||||||
 | 
						uint32_t DC;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint64_t frames;
 | 
				
			||||||
 | 
						uint64_t  FPS;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					extern EngineStatistics* ES;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void PerfomanceSamplerInit(){
 | 
				
			||||||
 | 
						ES = new EngineStatistics();
 | 
				
			||||||
 | 
						ES->frames = 0;
 | 
				
			||||||
 | 
						ES->lastSampleTime = 0;
 | 
				
			||||||
 | 
						ES->lastSampleTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void SamplePerformance(void) {
 | 
				
			||||||
 | 
						ES->frames++; 
 | 
				
			||||||
 | 
						ES->DC = 0; 
 | 
				
			||||||
 | 
						ES->verts = 0; 
 | 
				
			||||||
 | 
						unsigned int  now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); 
 | 
				
			||||||
 | 
						unsigned int MilliSecondsPast = now - ES->lastSampleTime; 
 | 
				
			||||||
 | 
						if (MilliSecondsPast >= 1000) {
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								ES->frameTime = (float)1000 / ES->frames; 
 | 
				
			||||||
 | 
								ES->FPS = ES->frames; 
 | 
				
			||||||
 | 
								ES->frames = 0; 
 | 
				
			||||||
 | 
								ES->lastSampleTime = now; 
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void ShowStats() {
 | 
				
			||||||
 | 
						ImGui::Begin("Statistics", false, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ImGui::Text("FPS: %i", ES->FPS);
 | 
				
			||||||
 | 
						ImGui::Text("Frame Time: %f", ES->frameTime);
 | 
				
			||||||
 | 
						ImGui::Text("Verts: %i", ES->verts);
 | 
				
			||||||
 | 
						ImGui::Text("Draw Calls: %i", ES->DC);
 | 
				
			||||||
 | 
						ImGui::End();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										47
									
								
								BarinkEngine/Include/Scene.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								BarinkEngine/Include/Scene.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "glm/glm.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					*	Scene should be a description of a game world 
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct Transform {
 | 
				
			||||||
 | 
						glm::vec3 Position;
 | 
				
			||||||
 | 
						glm::vec3 Rotation;
 | 
				
			||||||
 | 
						glm::vec3 Scale;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glm::mat4 ModelMatrix;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SceneNode {
 | 
				
			||||||
 | 
					public: 
 | 
				
			||||||
 | 
						std::string name;
 | 
				
			||||||
 | 
						Transform transform;
 | 
				
			||||||
 | 
						SceneNode* parent;
 | 
				
			||||||
 | 
						std::vector<SceneNode*> children;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void addChild(SceneNode& node);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Scene {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						SceneNode& GetSceneNode(std::string);
 | 
				
			||||||
 | 
						SceneNode& GetRoot();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Scene(std::string SceneName = "Default Scene");
 | 
				
			||||||
 | 
						~Scene();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						SceneNode* root;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										28
									
								
								BarinkEngine/Include/Scripting/LuaScript.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								BarinkEngine/Include/Scripting/LuaScript.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C"
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						#include "lauxlib.h"
 | 
				
			||||||
 | 
						#include "lua.h"
 | 
				
			||||||
 | 
						#include "lualib.h"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "LuaScriptingManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					class LuaScript {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						LuaScript(const std::string&);
 | 
				
			||||||
 | 
						void execute(lua_State& l);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						std::string filePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
							
								
								
									
										28
									
								
								BarinkEngine/Include/Scripting/LuaScriptingManager.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								BarinkEngine/Include/Scripting/LuaScriptingManager.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern "C"
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						#include "lauxlib.h"
 | 
				
			||||||
 | 
						#include "lua.h"
 | 
				
			||||||
 | 
						#include "lualib.h"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "LuaScript.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					class LuaScriptingManager 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						std::vector<LuaScript*> scripts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						LuaScriptingManager();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void ExecuteLuaString(const std::string&);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						lua_State* L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lua_State& getState();
 | 
				
			||||||
 | 
					};*/
 | 
				
			||||||
							
								
								
									
										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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										44
									
								
								BarinkEngine/Input/InputManager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								BarinkEngine/Input/InputManager.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					#include "Input/InputManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace BarinkEngine {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void InputManager::PollEvents()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							for (auto it = windows.begin(); it != windows.end(); ++it) {
 | 
				
			||||||
 | 
								(*it)->Poll();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void InputManager::setupGLFWInput(GLFWwindow* 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);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void InputManager::attach(BarinkWindow* window)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							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*>();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										52
									
								
								BarinkEngine/Scene.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								BarinkEngine/Scene.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,52 @@
 | 
				
			|||||||
 | 
					#include "Scene.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SceneNode* SearchInChildren(SceneNode* root, std::string name ) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (root->name == name)
 | 
				
			||||||
 | 
							return root;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SceneNode* found = nullptr;
 | 
				
			||||||
 | 
						for (auto child : root->children) {
 | 
				
			||||||
 | 
							found = SearchInChildren(child, name);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return found;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SceneNode& Scene::GetSceneNode(std::string name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return *SearchInChildren(root, name);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SceneNode& Scene::GetRoot()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return *root;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Scene::Scene(std::string sceneName)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// Create a root node
 | 
				
			||||||
 | 
						root = new SceneNode();
 | 
				
			||||||
 | 
						root->name = sceneName;
 | 
				
			||||||
 | 
						root->transform = Transform();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						root->transform.Position	= glm::vec3(0);
 | 
				
			||||||
 | 
						root->transform.Rotation	= glm::vec3(0);
 | 
				
			||||||
 | 
						root->transform.Scale		= glm::vec3(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						root->transform.ModelMatrix = glm::mat4(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Scene::~Scene()
 | 
				
			||||||
 | 
					{	
 | 
				
			||||||
 | 
						// Destruct scene!
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void SceneNode::addChild(SceneNode& node)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						children.push_back(&node);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										11
									
								
								BarinkEngine/Scripting/LuaScript.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								BarinkEngine/Scripting/LuaScript.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					#include "Scripting/LuaScript.h"
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					LuaScript::LuaScript(const std::string& path)
 | 
				
			||||||
 | 
					: filePath(path) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LuaScript::execute(lua_State& l)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						luaL_dofile(&l, filePath.c_str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
							
								
								
									
										18
									
								
								BarinkEngine/Scripting/LuaScriptingManager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								BarinkEngine/Scripting/LuaScriptingManager.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					#include "Scripting/LuaScriptingManager.h"
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					LuaScriptingManager::LuaScriptingManager()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						L = luaL_newstate();
 | 
				
			||||||
 | 
						luaL_openlibs(L);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void LuaScriptingManager::ExecuteLuaString(const std::string& code) {
 | 
				
			||||||
 | 
						luaL_dostring(L, code.c_str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					lua_State& LuaScriptingManager::getState()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return (*L);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
							
								
								
									
										47
									
								
								BarinkEngine/graphics/Buffer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								BarinkEngine/graphics/Buffer.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Buffer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int Buffer::getBufferID() {
 | 
				
			||||||
 | 
						return id;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Buffer::createBuffer() {
 | 
				
			||||||
 | 
						glGenBuffers(1, (GLuint*) &id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Buffer::setBufferData(void* data, size_t dataSize, bool elementBuffer = false ) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (elementBuffer) {
 | 
				
			||||||
 | 
							glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							glBufferData(GL_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Buffer::Bind(bool elementBuffer = false ) {
 | 
				
			||||||
 | 
						if (elementBuffer) {
 | 
				
			||||||
 | 
							glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							glBindBuffer(GL_ARRAY_BUFFER, id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Buffer::Unbind(bool elementBuffer = false) {
 | 
				
			||||||
 | 
						if (elementBuffer) {
 | 
				
			||||||
 | 
							glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							glBindBuffer(GL_ARRAY_BUFFER, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Buffer::Delete() {
 | 
				
			||||||
 | 
						glDeleteBuffers(1, (GLuint*) &id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										22
									
								
								BarinkEngine/graphics/Camera.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								BarinkEngine/graphics/Camera.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Camera.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
 | 
				
			||||||
 | 
					: Position(position), Rotation(rotation), Zoom(zoom) {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						Front = glm::vec3(-1.0f, 0.0f, 0.0f);
 | 
				
			||||||
 | 
						Right = glm::vec3(0.0f, 0.0f, 1.0f);
 | 
				
			||||||
 | 
						Up = glm::vec3(0.0f, 1.0f, 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Camera::~Camera() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					glm::mat4 Camera::GetViewMatrix() {
 | 
				
			||||||
 | 
						return glm::lookAt(
 | 
				
			||||||
 | 
							Position,
 | 
				
			||||||
 | 
							Position + Front,
 | 
				
			||||||
 | 
							Up
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										38
									
								
								BarinkEngine/graphics/GUI/GUIManager.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								BarinkEngine/graphics/GUI/GUIManager.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					#include "Graphics/GUI/GUIManager.h"
 | 
				
			||||||
 | 
					#include "imgui.h"
 | 
				
			||||||
 | 
					#include "backends/imgui_impl_opengl3.h"
 | 
				
			||||||
 | 
					#include <backends/imgui_impl_glfw.cpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GUIManager::GUIManager(BarinkWindow* window) 
 | 
				
			||||||
 | 
						: currentwindow(window)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    IMGUI_CHECKVERSION();
 | 
				
			||||||
 | 
					    ImGui::CreateContext();
 | 
				
			||||||
 | 
					    ImGuiIO& io = ImGui::GetIO();
 | 
				
			||||||
 | 
					    (void)io;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::StyleColorsDark();
 | 
				
			||||||
 | 
					    ImGui_ImplGlfw_InitForOpenGL(currentwindow->windowptr(), true);
 | 
				
			||||||
 | 
					    ImGui_ImplOpenGL3_Init("#version 440");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui_ImplGlfw_NewFrame();
 | 
				
			||||||
 | 
					    ImGui_ImplOpenGL3_NewFrame();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GUIManager::~GUIManager()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ImGui_ImplOpenGL3_Shutdown();
 | 
				
			||||||
 | 
					    ImGui_ImplGlfw_Shutdown();
 | 
				
			||||||
 | 
					    ImGui::DestroyContext();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void GUIManager::Render()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::Render();
 | 
				
			||||||
 | 
					    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								BarinkEngine/graphics/Material.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								BarinkEngine/graphics/Material.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					#include "../Include/Graphics/Material.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Material::Material(const Shader& shader) :
 | 
				
			||||||
 | 
					shader(shader) {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Material::Apply() {
 | 
				
			||||||
 | 
						shader.setUniformVec3("Color", Color);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										80
									
								
								BarinkEngine/graphics/ModelImporter.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								BarinkEngine/graphics/ModelImporter.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,80 @@
 | 
				
			|||||||
 | 
					#include "AssetManager/ModelImporter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::vector<BarinkEngine::Mesh> ModelImporter::Import(std::string path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    Assimp::Importer importer;
 | 
				
			||||||
 | 
					    const aiScene* scene = importer.ReadFile(path.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs);
 | 
				
			||||||
 | 
					    aiNode* currentNode = scene->mRootNode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return processNode(currentNode, scene);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					std::vector<BarinkEngine::Mesh> ModelImporter::processNode(aiNode* node, const aiScene* scene) {
 | 
				
			||||||
 | 
					    std::vector<BarinkEngine::Mesh> meshes;
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < node->mNumMeshes; i++) {
 | 
				
			||||||
 | 
					        aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
 | 
				
			||||||
 | 
					        meshes.push_back(processMesh(mesh, scene));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < node->mNumChildren; i++) {
 | 
				
			||||||
 | 
					       auto m2 =  processNode(node->mChildren[i], scene);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       for(auto m : m2) {
 | 
				
			||||||
 | 
					           meshes.push_back(m);
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return meshes;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene) {
 | 
				
			||||||
 | 
					    std::vector<unsigned int> indices;
 | 
				
			||||||
 | 
					    std::vector<BarinkEngine::Vertex> vertices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Process vertices
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
 | 
				
			||||||
 | 
					        BarinkEngine::Vertex v{};
 | 
				
			||||||
 | 
					        glm::vec3 vector;
 | 
				
			||||||
 | 
					        vector.x = mesh->mVertices[i].x;
 | 
				
			||||||
 | 
					        vector.y = mesh->mVertices[i].y;
 | 
				
			||||||
 | 
					        vector.z = mesh->mVertices[i].z;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        v.vertices = vector;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (mesh->mTextureCoords[0]) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            glm::vec2 texCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            texCoord.x = mesh->mTextureCoords[0][i].x;
 | 
				
			||||||
 | 
					            texCoord.y = mesh->mTextureCoords[0][i].y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            v.uv = texCoord;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					        vertices.push_back(v);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Process Indices
 | 
				
			||||||
 | 
					    for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
 | 
				
			||||||
 | 
					        aiFace face = mesh->mFaces[i];
 | 
				
			||||||
 | 
					        if (face.mNumIndices < 3)
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        for (unsigned int j = 0; j < face.mNumIndices; j++) {
 | 
				
			||||||
 | 
					            indices.push_back(face.mIndices[j]);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    BarinkEngine::Mesh result;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    result.vertices = vertices;
 | 
				
			||||||
 | 
					    result.elements = indices;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										46
									
								
								BarinkEngine/graphics/RenderSurface.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								BarinkEngine/graphics/RenderSurface.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					#include "Graphics/RenderSurface.h";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RenderSurface::RenderSurface(){
 | 
				
			||||||
 | 
						shader = new Shader("build/SandboxAppliction/Debug/renderSuface.vs", "build/SandboxApplication/Debug/renderSurface.fs");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						verts = std::vector<glm::vec3>{
 | 
				
			||||||
 | 
							{-0.5f, 0.5f, 0.0f}, // 0
 | 
				
			||||||
 | 
							{-0.5f, -0.5f, 0.0f}, // 1
 | 
				
			||||||
 | 
							{0.5f, -0.5f, 0.0f}, // 2
 | 
				
			||||||
 | 
							{0.5f, 0.5f, 0.0f}, // 3 
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						indices = std::vector<unsigned int>{
 | 
				
			||||||
 | 
							0,2,1,
 | 
				
			||||||
 | 
							0,3,2
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VAO.Create();
 | 
				
			||||||
 | 
						VAO.Bind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vertexBuffer.createBuffer();
 | 
				
			||||||
 | 
						vertexBuffer.Bind(false);
 | 
				
			||||||
 | 
						vertexBuffer.setBufferData(&verts[0], verts.size() * sizeof(glm::vec3), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						elementBuffer.createBuffer();
 | 
				
			||||||
 | 
						elementBuffer.Bind(true);
 | 
				
			||||||
 | 
						elementBuffer.setBufferData(&indices[0], indices.size() * sizeof(unsigned int), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VAO.AttachAttribute(0, 3, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vertexBuffer.Unbind(false);
 | 
				
			||||||
 | 
						VAO.Unbind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RenderSurface::~RenderSurface() {
 | 
				
			||||||
 | 
						delete shader;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void RenderSurface::Draw() {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										62
									
								
								BarinkEngine/graphics/Renderable.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								BarinkEngine/graphics/Renderable.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Renderable.h"
 | 
				
			||||||
 | 
					#include "AssetManager/ModelImporter.h"
 | 
				
			||||||
 | 
					#include "PerfCounter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renderable* Renderable::Load(std::string& path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return new Renderable(path);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renderable::Renderable(std::string& path)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    meshes = ModelImporter::Import(path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    transform.Scale = glm::vec3(1.0f);
 | 
				
			||||||
 | 
					    transform.Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
 | 
				
			||||||
 | 
					    transform.Position = glm::vec3(0.0f, 0.0f, 0.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    VAO.Create();
 | 
				
			||||||
 | 
					    VAO.Bind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    vertexBuffer.createBuffer();
 | 
				
			||||||
 | 
					    vertexBuffer.Bind(false);
 | 
				
			||||||
 | 
					    vertexBuffer.setBufferData(&meshes[0].vertices[0], meshes[0].vertices.size() * sizeof(BarinkEngine::Vertex), false);   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    elementBuffer.createBuffer();
 | 
				
			||||||
 | 
					    elementBuffer.Bind(true);
 | 
				
			||||||
 | 
					    elementBuffer.setBufferData(&meshes[0].elements[0], meshes[0].elements.size() * sizeof(unsigned int), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    VAO.AttachAttribute(0, 3, sizeof(BarinkEngine::Vertex));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(BarinkEngine::Vertex),(void* )offsetof(BarinkEngine::Vertex, vertices));
 | 
				
			||||||
 | 
					   glEnableVertexAttribArray(1);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					   vertexBuffer.Unbind(false);
 | 
				
			||||||
 | 
					  
 | 
				
			||||||
 | 
					   VAO.Unbind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renderable::~Renderable()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glDeleteBuffers(1, &UV_id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Renderable::Draw()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    VAO.Bind();
 | 
				
			||||||
 | 
					    elementBuffer.Bind(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glActiveTexture(GL_TEXTURE0);
 | 
				
			||||||
 | 
					    glUniform1i(glGetUniformLocation(shader->id, "Texture"), GL_TEXTURE0);
 | 
				
			||||||
 | 
					    texture->Bind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ES->verts = meshes[0].vertices.size();
 | 
				
			||||||
 | 
					    ES->DC++;
 | 
				
			||||||
 | 
					    glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
 | 
				
			||||||
 | 
					    VAO.Unbind();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										25
									
								
								BarinkEngine/graphics/Renderer.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								BarinkEngine/graphics/Renderer.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Renderer.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BarinkEngine::Renderer::Renderer()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						models = std::vector<Renderable*>();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BarinkEngine::Renderer::~Renderer()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// CleanUp!
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BarinkEngine::Renderer::Render()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (auto model : models) {
 | 
				
			||||||
 | 
							model->Draw();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BarinkEngine::Renderer::Submit(Renderable* model)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						models.push_back(model);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										124
									
								
								BarinkEngine/graphics/Shader.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										124
									
								
								BarinkEngine/graphics/Shader.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,124 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Shader.h"
 | 
				
			||||||
 | 
					#include "spdlog/spdlog.h"
 | 
				
			||||||
 | 
					Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    char infoLog[512];
 | 
				
			||||||
 | 
					    int succes;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    char* vertexCode = readFile(vertexShaderPath.c_str());
 | 
				
			||||||
 | 
					    //spdlog::info(vertexCode);
 | 
				
			||||||
 | 
					    unsigned int vertId = glCreateShader(GL_VERTEX_SHADER);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    glShaderSource(vertId, 1, &vertexCode, NULL);
 | 
				
			||||||
 | 
					    glCompileShader(vertId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes);
 | 
				
			||||||
 | 
					    if(!succes){
 | 
				
			||||||
 | 
					        glGetShaderInfoLog(vertId, 512, NULL, infoLog);
 | 
				
			||||||
 | 
					        spdlog::error( "Vertex shader has compile error {}", infoLog);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    char* fragmentCode = readFile(fragmentShaderPath.c_str());
 | 
				
			||||||
 | 
					    //spdlog::info(fragmentCode); 
 | 
				
			||||||
 | 
					    unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    glShaderSource(fragId, 1, &fragmentCode, NULL);
 | 
				
			||||||
 | 
					    glCompileShader(fragId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes);
 | 
				
			||||||
 | 
					    if(!succes){
 | 
				
			||||||
 | 
					        glGetShaderInfoLog(fragId, 512, NULL, infoLog);
 | 
				
			||||||
 | 
					        spdlog::error("Fragment shader has compile error {}", infoLog);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    id = glCreateProgram();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glAttachShader(id, vertId);
 | 
				
			||||||
 | 
					    glAttachShader(id, fragId);
 | 
				
			||||||
 | 
					    glLinkProgram(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int success;
 | 
				
			||||||
 | 
					    glGetProgramiv(id, GL_LINK_STATUS, &success);
 | 
				
			||||||
 | 
					    if(!success) {
 | 
				
			||||||
 | 
					        glGetProgramInfoLog(id, 512, NULL, infoLog);
 | 
				
			||||||
 | 
					        printf("ERROR::SHADER_PROGRAM::LINKING_FAILED\n %s", infoLog);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete vertexCode;
 | 
				
			||||||
 | 
					    delete fragmentCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					char* Shader::readFile (const char* filePath){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::ifstream file ;
 | 
				
			||||||
 | 
					    file.open(filePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(file.is_open() == false){
 | 
				
			||||||
 | 
					         spdlog::info("File not found.");
 | 
				
			||||||
 | 
					         return nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Determine the file size!
 | 
				
			||||||
 | 
					    file.seekg(0, std::ios::end);
 | 
				
			||||||
 | 
					    size_t filesize = file.tellg();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Undo previous seek.
 | 
				
			||||||
 | 
					    file.seekg(0, std::ios::beg);
 | 
				
			||||||
 | 
					    //spdlog::info("filesize: {}", filesize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Create a big enough buffer for the file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    size_t bufferSize = filesize + 3;
 | 
				
			||||||
 | 
					    char* FileBuffer = new char[bufferSize];
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					    memset(FileBuffer, '\0', bufferSize);
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					    // read the whole file
 | 
				
			||||||
 | 
					    file.read(FileBuffer, filesize);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return FileBuffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Shader::Use()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUseProgram(id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Shader::setUniformMat4(std::string uniformName, glm::mat4 matrix4) const
 | 
				
			||||||
 | 
					{    
 | 
				
			||||||
 | 
					    glUniformMatrix4fv(glGetUniformLocation(id, uniformName.c_str()), 1, GL_FALSE, glm::value_ptr(matrix4));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					void Shader::setUniformVec4(std::string uniformName, glm::vec4 vector4) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUniform4fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector4));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					void Shader::setUniformVec3(std::string uniformName, glm::vec3 vector3) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUniform3fv(glGetUniformLocation(id, uniformName.c_str()), 1, glm::value_ptr(vector3));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					void Shader::setUniformVec2(std::string uniformName, glm::vec2 vector2) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUniform2fv(glGetUniformLocation(id, uniformName.c_str()),1, glm::value_ptr(vector2));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Shader::setUniformFloat(std::string uniformName, float value) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUniform1f(glGetUniformLocation(id, uniformName.c_str()), value);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Shader::setUniformInt(std::string uniformName, int value) const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    glUniform1i(glGetUniformLocation(id, uniformName.c_str()), value);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										40
									
								
								BarinkEngine/graphics/Texture.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								BarinkEngine/graphics/Texture.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					#include "../Include/Graphics/Texture.h"
 | 
				
			||||||
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					#include <GLFW/glfw3.h>
 | 
				
			||||||
 | 
					#define STB_IMAGE_IMPLEMENTATION
 | 
				
			||||||
 | 
					#include "Graphics/stb_image.h"
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Texture::Texture(const std::string texturePath) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int width, height, channels;
 | 
				
			||||||
 | 
						unsigned char* data = stbi_load(texturePath.c_str(), &width, &height, &channels, 0);
 | 
				
			||||||
 | 
						std::cout << channels << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (data) {
 | 
				
			||||||
 | 
							glGenTextures(1, &Id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							glBindTexture(GL_TEXTURE_2D, Id);
 | 
				
			||||||
 | 
							glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
 | 
				
			||||||
 | 
							glGenerateMipmap(GL_TEXTURE_2D);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
 | 
				
			||||||
 | 
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 | 
				
			||||||
 | 
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
 | 
				
			||||||
 | 
							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else {
 | 
				
			||||||
 | 
							spdlog::error("Failed to load image (%s)", texturePath );
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						stbi_image_free(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Texture::Bind() {
 | 
				
			||||||
 | 
						glBindTexture(GL_TEXTURE_2D, Id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Texture::Unbind() {
 | 
				
			||||||
 | 
						glBindTexture(GL_TEXTURE_2D, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										25
									
								
								BarinkEngine/graphics/VertexArray.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								BarinkEngine/graphics/VertexArray.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					#include "Graphics/VertexArray.h"
 | 
				
			||||||
 | 
					#include <glad/glad.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void VertexArray::Create(){
 | 
				
			||||||
 | 
					    glGenVertexArrays(1, &id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void VertexArray::Bind(){
 | 
				
			||||||
 | 
					    glBindVertexArray(id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void VertexArray::Unbind(){
 | 
				
			||||||
 | 
					    glBindVertexArray(0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void VertexArray::Delete() {
 | 
				
			||||||
 | 
					    glDeleteVertexArrays(1, &id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void VertexArray::AttachAttribute(unsigned int index , int size, int stride  ){
 | 
				
			||||||
 | 
					    glVertexAttribPointer(index, size, GL_FLOAT, GL_FALSE, stride, 0);
 | 
				
			||||||
 | 
					    glEnableVertexAttribArray(0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -7,5 +7,5 @@ uniform sampler2D Texture;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void main(){
 | 
					void main(){
 | 
				
			||||||
	FragColor = vec4(color , 1.0f); // mix ( texture(Texture, TexCoord), vec4(Color, 1.0f), 1.0f);
 | 
						FragColor = mix ( texture(Texture, TexCoord), vec4(Color, 1.0f), 0.5f);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										87
									
								
								BarinkEngine/graphics/window.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								BarinkEngine/graphics/window.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,87 @@
 | 
				
			|||||||
 | 
					#include "Graphics/Window.h"
 | 
				
			||||||
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <GLFW/glfw3.h>
 | 
				
			||||||
 | 
					#include <spdlog/spdlog.h>
 | 
				
			||||||
 | 
					#include "../Include/EventSystem/Event.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool BarinkWindow::InitGLFW(){
 | 
				
			||||||
 | 
						if(!glfwInit())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							spdlog::error("Failed to initialise GLFW!");
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BarinkWindow::BarinkWindow(const int width, const int height) :
 | 
				
			||||||
 | 
					Width(width), Height(height), FullScreen(false){
 | 
				
			||||||
 | 
						if (InitGLFW()==false) {
 | 
				
			||||||
 | 
							exit(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if( !window)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							spdlog::error("GLFW failed to create window!");
 | 
				
			||||||
 | 
							glfwTerminate();
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glfwMakeContextCurrent(window);
 | 
				
			||||||
 | 
						if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
 | 
				
			||||||
 | 
							printf("Failed to initialize GLAD!\n");
 | 
				
			||||||
 | 
							exit(-1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Set vsync off !! 
 | 
				
			||||||
 | 
						glfwSwapInterval(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						VulkanSupported = glfwVulkanSupported();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glfwGetFramebufferSize(window, &Width, &Height);
 | 
				
			||||||
 | 
						glViewport(0,0, Width, Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BarinkWindow::~BarinkWindow(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glfwTerminate();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GLFWwindow* BarinkWindow::windowptr()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return window;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool BarinkWindow::WindowShouldClose(){
 | 
				
			||||||
 | 
						return glfwWindowShouldClose(window);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BarinkWindow::Poll()
 | 
				
			||||||
 | 
					{	
 | 
				
			||||||
 | 
						glfwPollEvents();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BarinkWindow::SwapBuffers() 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						glfwSwapBuffers(window);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void BarinkWindow::ReceiveEvent(Event& incident)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						std::cout << "EVENT RECEIVED: " <<  incident.name << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										83
									
								
								BarinkEngine/premake5.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								BarinkEngine/premake5.lua
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,83 @@
 | 
				
			|||||||
 | 
					project "BarinkEngine"
 | 
				
			||||||
 | 
					  kind "StaticLib"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buildmessage "Building BarinkEngine"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  includedirs {
 | 
				
			||||||
 | 
					    "Include/",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "../libs/lua/include",
 | 
				
			||||||
 | 
					    "../libs/spdlog/include",
 | 
				
			||||||
 | 
					    "../libs/glm",
 | 
				
			||||||
 | 
					    "../libs/GorillaAudio/include",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "../libs/physx/physx/include",
 | 
				
			||||||
 | 
					    "../libs/steam-audio/include",
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    "../libs/assimp/include",
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "../libs/glad/include",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "../libs/glfw/include",
 | 
				
			||||||
 | 
					    "../libs/glew/include",
 | 
				
			||||||
 | 
					    "../libs/glm",
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    "../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 {
 | 
				
			||||||
 | 
					    "../libs/steam-audio/lib/windows-x64",
 | 
				
			||||||
 | 
					    "../libs/lua",
 | 
				
			||||||
 | 
					    "../libs/spdlog/build/Release",
 | 
				
			||||||
 | 
					    "../libs/assimp/lib/Debug",
 | 
				
			||||||
 | 
					    "../libs/glfw/build/src/Debug",
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  files {
 | 
				
			||||||
 | 
					    "../libs/glad/src/glad.c",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    "./*.cpp",
 | 
				
			||||||
 | 
					    "./*.h",
 | 
				
			||||||
 | 
					    "./**/*.cpp",
 | 
				
			||||||
 | 
					    "./**/*.h"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  filter { "system:windows"}
 | 
				
			||||||
 | 
					    prebuildcommands {
 | 
				
			||||||
 | 
					      -- Copy shaders 
 | 
				
			||||||
 | 
					      "copy graphics\\shaders\\fragment.shader            ..\\build\\SandboxApplication\\Debug\\test.fs", 
 | 
				
			||||||
 | 
					      "copy graphics\\shaders\\vertex.shader              ..\\build\\SandboxApplication\\Debug\\test.vs",
 | 
				
			||||||
 | 
					      "copy graphics\\shaders\\RenderSurfaceFrag.shader   ..\\build\\SandboxApplication\\Debug\\RenderSurface.fs",
 | 
				
			||||||
 | 
					      "copy graphics\\shaders\\RenderSurfaceVert.shader   ..\\build\\SandboxApplication\\Debug\\RenderSurface.vs" 
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  filter { "system:linux" }
 | 
				
			||||||
 | 
					    prebuildcommands {
 | 
				
			||||||
 | 
					      -- Copy shaders
 | 
				
			||||||
 | 
					      "cp graphics/shaders/fragment.shader ../build/SandboxApplication/Debug/test.fs", 
 | 
				
			||||||
 | 
					      "cp graphics/shaders/vertex.shader ../build/SandboxApplication/Debug/test.vs",
 | 
				
			||||||
 | 
					      "cp graphics/shaders/RenderSurfaceFrag.shader ../build/SandboxApplication/Debug/RenderSurface.fs",
 | 
				
			||||||
 | 
					      "cp graphics/shaders/RenderSurfaceVert.shader ../build/SandboxApplication/Debug/RenderSurface.vs" 
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include('../ImGui')
 | 
				
			||||||
@ -1,46 +0,0 @@
 | 
				
			|||||||
project "Editor"
 | 
					 | 
				
			||||||
kind "ConsoleApp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
buildmessage "Building editor ..."
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
links{
 | 
					 | 
				
			||||||
  "YoggieEngine",
 | 
					 | 
				
			||||||
  "ImGuizmo",
 | 
					 | 
				
			||||||
  "yaml-cpp",
 | 
					 | 
				
			||||||
  "nfd.lib"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
includedirs{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  "../YoggieEngine/build/Debug",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  -- I'd prefer if didn't need these..
 | 
					 | 
				
			||||||
  -- We'll figure that out some time later
 | 
					 | 
				
			||||||
  "../libs/physx/physx/include",
 | 
					 | 
				
			||||||
  "../libs/physx/pxshared/include",
 | 
					 | 
				
			||||||
  incfolder["lua"],
 | 
					 | 
				
			||||||
  incfolder["spdlog"],
 | 
					 | 
				
			||||||
  incfolder["glm"],
 | 
					 | 
				
			||||||
  incfolder["assimp"],
 | 
					 | 
				
			||||||
  incfolder["glad"],
 | 
					 | 
				
			||||||
  incfolder["glfw"],
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  incfolder["imgui"],
 | 
					 | 
				
			||||||
  incfolder["imguizmo"],
 | 
					 | 
				
			||||||
  incfolder["entt"],
 | 
					 | 
				
			||||||
  incfolder["yamlcpp"],
 | 
					 | 
				
			||||||
  incfolder["nativefiledialog"],
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
libdirs {
 | 
					 | 
				
			||||||
  staticlib["yoggie"],
 | 
					 | 
				
			||||||
  staticlib["nativefiledialog"]
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
files { 
 | 
					 | 
				
			||||||
  "../libs/glad/src/glad.c",
 | 
					 | 
				
			||||||
  "./src/**.h",
 | 
					 | 
				
			||||||
  "./src/**.cpp"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								Editor/rsc/AssetIcon.png
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/rsc/AssetIcon.png
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Editor/rsc/AssetIcon.xcf
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/rsc/AssetIcon.xcf
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Editor/rsc/FodlerIcon.xcf
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/rsc/FodlerIcon.xcf
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Editor/rsc/FolderIcon.png
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/rsc/FolderIcon.png
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@ -1,46 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <filesystem>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/YoggieEngine.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
enum class ASSET_TYPE {
 | 
					 | 
				
			||||||
	Unknown = -1,
 | 
					 | 
				
			||||||
	Mesh,
 | 
					 | 
				
			||||||
	Texture,
 | 
					 | 
				
			||||||
	Material
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Asset {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	Asset(const char* name):  name(name) {}
 | 
					 | 
				
			||||||
	virtual ASSET_TYPE GetType() { return ASSET_TYPE::Unknown; }
 | 
					 | 
				
			||||||
	const char* GetName() const { return name.c_str(); }
 | 
					 | 
				
			||||||
	bool isFolder = false ;
 | 
					 | 
				
			||||||
protected:
 | 
					 | 
				
			||||||
	std::string name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class MeshAsset : Asset {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	MeshAsset(YoggieEngine::Mesh mesh) : Asset("New MeshAsset"), mesh(mesh) {}
 | 
					 | 
				
			||||||
	ASSET_TYPE  GetType() override { return ASSET_TYPE::Mesh; }
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
	YoggieEngine::Mesh& mesh;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class TextureAsset : Asset {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	TextureAsset (YoggieEngine::Texture texture): Asset("New TextureAsset"), texture(texture) {}
 | 
					 | 
				
			||||||
	ASSET_TYPE GetType() override { return ASSET_TYPE::Texture; }
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
	YoggieEngine::Texture& texture;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class MaterialAsset : Asset {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	MaterialAsset ()  : Asset("New MaterialAsset"){}
 | 
					 | 
				
			||||||
	ASSET_TYPE GetType() override { return ASSET_TYPE::Material; }
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,149 +0,0 @@
 | 
				
			|||||||
#include "AssetManager.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/AssetManager/ModelImporter.h"
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					 | 
				
			||||||
#include <spdlog/spdlog.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
std::vector<Asset> AssetManager::assets;
 | 
					 | 
				
			||||||
std::filesystem::path AssetManager::currentPath;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AssetManager::Init() 
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
	assets = std::vector<Asset>();
 | 
					 | 
				
			||||||
	currentPath = std::filesystem::path("."); 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AssetManager::BuildAssetView()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (currentPath.empty()) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (auto& dir_entry : std::filesystem::directory_iterator(currentPath))
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		auto asset = Asset(dir_entry.path().filename().string().c_str());
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		if (dir_entry.is_directory()) {
 | 
					 | 
				
			||||||
			asset.isFolder = true;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		assets.push_back(asset);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void AssetManager::setAssetPath(std::filesystem::path path) 
 | 
					 | 
				
			||||||
{ 
 | 
					 | 
				
			||||||
	currentPath = path; 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
YoggieEngine::Mesh* AssetManager::LoadFromAssetFile(const std::filesystem::path assetPath)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	YoggieEngine::Mesh imported;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	std::ifstream AssetFile;
 | 
					 | 
				
			||||||
	AssetFile.open(assetPath, std::ios::binary);
 | 
					 | 
				
			||||||
	if (AssetFile.is_open()) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		char* Header = (char*)malloc(8);
 | 
					 | 
				
			||||||
		unsigned long long  Vsize = 0;
 | 
					 | 
				
			||||||
		uint32_t Vnum = 0;
 | 
					 | 
				
			||||||
		uint32_t Enum = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Read header 
 | 
					 | 
				
			||||||
		AssetFile.read(Header, 8);
 | 
					 | 
				
			||||||
		AssetFile.read((char*)&Vsize, sizeof(unsigned long long));
 | 
					 | 
				
			||||||
		AssetFile.read((char*)&Vnum, sizeof(uint32_t));
 | 
					 | 
				
			||||||
		AssetFile.read((char*)&Enum, sizeof(uint32_t));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// print Header info 
 | 
					 | 
				
			||||||
		std::cout << "File has header: " << Header << std::endl;
 | 
					 | 
				
			||||||
		std::cout << "Vertex size: " << Vsize << std::endl;
 | 
					 | 
				
			||||||
		std::cout << "Number of Vertices: " << Vnum << std::endl;
 | 
					 | 
				
			||||||
		std::cout << "Number of Elements: " << Enum << std::endl;
 | 
					 | 
				
			||||||
		free(Header);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Load Vertices (Vertex + UV )
 | 
					 | 
				
			||||||
		imported.vertices = std::vector < YoggieEngine::Vertex>();
 | 
					 | 
				
			||||||
		for (int i = 0; i < Vnum; i++)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			YoggieEngine::Vertex data = YoggieEngine::Vertex();
 | 
					 | 
				
			||||||
			AssetFile.read((char*)&data, Vsize);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			imported.vertices.push_back(data);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// skip x bytes 
 | 
					 | 
				
			||||||
		AssetFile.ignore(sizeof(char) * 3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Load Elements
 | 
					 | 
				
			||||||
		imported.elements = std::vector<unsigned int>();
 | 
					 | 
				
			||||||
		for (int i = 0; i < Enum; i++) {
 | 
					 | 
				
			||||||
			unsigned int data = 0;
 | 
					 | 
				
			||||||
			AssetFile.read((char*)&data, sizeof(unsigned int));
 | 
					 | 
				
			||||||
			imported.elements.push_back(data);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		std::cout << "Failed ot open mesh " << std::endl;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
YoggieEngine::Renderable* AssetManager::LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	auto model = (YoggieEngine::ModelImporter()).Import(srcPath.string());
 | 
					 | 
				
			||||||
	YoggieEngine::Mesh* exportMesh = model->renderable->mesh;
 | 
					 | 
				
			||||||
	std::filesystem::path MeshFileName = assetFolder / srcPath.filename().replace_extension(".mesh");
 | 
					 | 
				
			||||||
	std::cout << "Save path: " << MeshFileName << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	std::ofstream meshAsset;
 | 
					 | 
				
			||||||
	meshAsset.open(MeshFileName.c_str(), std::ios::binary);
 | 
					 | 
				
			||||||
	if (meshAsset.is_open()) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// write a header
 | 
					 | 
				
			||||||
		static const char* HEADER = "MESH";
 | 
					 | 
				
			||||||
		meshAsset.write(HEADER, sizeof(HEADER));
 | 
					 | 
				
			||||||
		auto Vsize = sizeof(YoggieEngine::Vertex);
 | 
					 | 
				
			||||||
		std::cout << "size of vertex: " << Vsize << std::endl;
 | 
					 | 
				
			||||||
		std::cout << "Addr of vSize: " << &Vsize << std::endl;
 | 
					 | 
				
			||||||
		auto Vnum = exportMesh->vertices.size();
 | 
					 | 
				
			||||||
		auto Enum = exportMesh->elements.size();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		meshAsset.write((char*)&Vsize, sizeof(unsigned long long));
 | 
					 | 
				
			||||||
		meshAsset.write((char*)&Vnum, sizeof(uint32_t));
 | 
					 | 
				
			||||||
		meshAsset.write((char*)&Enum, sizeof(uint32_t));
 | 
					 | 
				
			||||||
		// write all vertices 
 | 
					 | 
				
			||||||
		for (auto vertice : exportMesh->vertices)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			meshAsset.write((char*)&vertice, sizeof(vertice));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// write 3 x 0 byte
 | 
					 | 
				
			||||||
		meshAsset.write((const char*)"\0\0\0", sizeof(char) * 3);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// write all indices 
 | 
					 | 
				
			||||||
		for (auto index : exportMesh->elements) {
 | 
					 | 
				
			||||||
			meshAsset.write((char*)&index, sizeof(index));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		meshAsset.close();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		spdlog::error("Failed to create/open mesh file.");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return model->renderable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,20 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <vector>
 | 
					 | 
				
			||||||
#include "Asset.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class AssetManager {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static void Init();
 | 
					 | 
				
			||||||
	static void BuildAssetView();
 | 
					 | 
				
			||||||
	static void setAssetPath(std::filesystem::path path);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static YoggieEngine::Mesh* LoadFromAssetFile(const std::filesystem::path assetPath);
 | 
					 | 
				
			||||||
	static YoggieEngine::Renderable* LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	static std::vector<Asset> assets ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
	static std::filesystem::path currentPath;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,66 +0,0 @@
 | 
				
			|||||||
#include "Project.h"
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <sstream>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <yaml-cpp/yaml.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Project::SaveProject(std::filesystem::path path, Project& project)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	YAML::Emitter projectYAML;
 | 
					 | 
				
			||||||
	projectYAML << YAML::BeginMap;
 | 
					 | 
				
			||||||
	projectYAML << YAML::Key << "Project" << YAML::Value << project.Name;	
 | 
					 | 
				
			||||||
	projectYAML << YAML::Key << "Directory" << YAML::Value << path.parent_path().u8string();
 | 
					 | 
				
			||||||
	projectYAML << YAML::EndMap;
 | 
					 | 
				
			||||||
	std::ofstream projectFile;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	projectFile.open(path.u8string());
 | 
					 | 
				
			||||||
	projectFile << projectYAML.c_str();
 | 
					 | 
				
			||||||
	projectFile.close();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Project::LoadProject(std::filesystem::path path, std::unique_ptr<Project>& project) 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	std::string YAMLProject;
 | 
					 | 
				
			||||||
	std::stringstream sstream;
 | 
					 | 
				
			||||||
	std::ifstream projectFile;
 | 
					 | 
				
			||||||
	projectFile.open(path.u8string());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sstream << projectFile.rdbuf();
 | 
					 | 
				
			||||||
	YAMLProject = sstream.str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	projectFile.close();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	YAML::Node node = YAML::Load(YAMLProject);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// this is probably not perfect but it seems to work for now
 | 
					 | 
				
			||||||
	project.release();
 | 
					 | 
				
			||||||
	project = std::make_unique<Project>(node.as<Project>());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	std::cout << "loading..." << project.get()->Name << std::endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace YAML {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	template<>
 | 
					 | 
				
			||||||
	class convert<Project> {
 | 
					 | 
				
			||||||
	public:
 | 
					 | 
				
			||||||
		static bool decode(const Node& node , Project& rhs) 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			if (!node.IsMap())
 | 
					 | 
				
			||||||
				return false;
 | 
					 | 
				
			||||||
			rhs.setName(node["Project"].as<std::string>());
 | 
					 | 
				
			||||||
			rhs.setProjectDirectory(node["Directory"].as<std::string>());
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,22 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <filesystem>
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
class Project {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	Project() = default;
 | 
					 | 
				
			||||||
	Project(const std::string& name): Name(name){}
 | 
					 | 
				
			||||||
	~Project() { std::cout << "Unloading project..." << Name << std::endl; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void setName(std::string& name) { Name = name; }
 | 
					 | 
				
			||||||
	const std::string& GetName()const { return Name; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void setProjectDirectory(std::string& path) { ProjectDirectory = std::filesystem::path(path); }
 | 
					 | 
				
			||||||
	const std::filesystem::path GetProjectDirectory() { return ProjectDirectory; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	static void SaveProject(std::filesystem::path path, Project& project);
 | 
					 | 
				
			||||||
	static void LoadProject(std::filesystem::path path, std::unique_ptr<Project>& project);
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
	std::string Name;
 | 
					 | 
				
			||||||
	std::filesystem::path ProjectDirectory;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,139 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <yaml-cpp/yaml.h>
 | 
					 | 
				
			||||||
#include <yaml-cpp/node/type.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <filesystem>
 | 
					 | 
				
			||||||
#include <fstream>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Scene/Entity.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void WriteFile(std::string& emitter, std::filesystem::path path) 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	std::cout << "Writing Scene file to: "  << path.u8string() << std::endl;
 | 
					 | 
				
			||||||
	std::ofstream sceneFile;
 | 
					 | 
				
			||||||
	sceneFile.open(path.u8string());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sceneFile << emitter.c_str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sceneFile.close();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector) {
 | 
					 | 
				
			||||||
	emitter << YAML::Flow << YAML::BeginSeq   << vector.x << vector.y << vector.x << YAML::EndSeq;
 | 
					 | 
				
			||||||
	return emitter;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 std::string Serialize( Scene& scene) {
 | 
					 | 
				
			||||||
	YAML::Emitter emitter;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	emitter << YAML::BeginMap;
 | 
					 | 
				
			||||||
	emitter << YAML::Key << "Scene" << YAML::Value << "test-Scene";
 | 
					 | 
				
			||||||
	emitter << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	scene.getReg().each([&scene, &emitter](auto enttNumber) {
 | 
					 | 
				
			||||||
		Entity entity = Entity(enttNumber, &scene);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		emitter << YAML::BeginMap;
 | 
					 | 
				
			||||||
		emitter << YAML::Key << "Entity" << YAML::Value << entity.GetComponent<IdentifierComponent>().name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (entity.HasComponent<IdentifierComponent>()) {
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Ident";
 | 
					 | 
				
			||||||
			emitter << YAML::BeginMap;
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<IdentifierComponent>().name;
 | 
					 | 
				
			||||||
			emitter << YAML::EndMap;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (entity.HasComponent<TransformComponent>()) {
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Transform" << YAML::Value ;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::BeginMap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Position";
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<TransformComponent>().Position;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Rotation";
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<TransformComponent>().Rotation;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Scale";
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<TransformComponent>().Scale;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::EndMap;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (entity.HasComponent<LightComponent>()) {
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Light";
 | 
					 | 
				
			||||||
			emitter << YAML::Value;
 | 
					 | 
				
			||||||
			emitter << YAML::BeginMap;
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "strength";
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<LightComponent>().Strength;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			emitter << YAML::Key << "Color";
 | 
					 | 
				
			||||||
			emitter << YAML::Value << entity.GetComponent<LightComponent>().Color;
 | 
					 | 
				
			||||||
			emitter << YAML::EndMap;
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		emitter << YAML::EndMap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	emitter << YAML::EndSeq;
 | 
					 | 
				
			||||||
	emitter << YAML::EndMap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return std::string(emitter.c_str());
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 void SaveScene(std::filesystem::path path, Scene& scene) {
 | 
					 | 
				
			||||||
	 std::string YAMLString = Serialize(scene);
 | 
					 | 
				
			||||||
	 WriteFile(YAMLString, path);
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 void LoadScene(std::filesystem::path path, Scene& scene)
 | 
					 | 
				
			||||||
 {
 | 
					 | 
				
			||||||
	auto sceneYAML = YAML::LoadFile(path.u8string());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!sceneYAML["Scene"]) {
 | 
					 | 
				
			||||||
		 spdlog::error("Not a scene file!");
 | 
					 | 
				
			||||||
		 return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	scene.getReg().clear();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	std::string SceneName = sceneYAML["Scene"].as<std::string>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	auto entities = sceneYAML["Entities"];
 | 
					 | 
				
			||||||
	 
 | 
					 | 
				
			||||||
	for (const auto& entity : entities) {
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
		std::string entityID = entity["Ident"].as<std::string>();
 | 
					 | 
				
			||||||
		YoggieEngine::Entity SE = scene.AddEntity(entityID);
 | 
					 | 
				
			||||||
		if (entity["Transform"]) 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			TransformComponent tc = SE.GetComponent<TransformComponent>();
 | 
					 | 
				
			||||||
			auto positionNode = entity["Transform"]["Position"];
 | 
					 | 
				
			||||||
			tc.Position =  glm::vec3(positionNode[0].as<float>(), positionNode[1].as<float>(), positionNode[2].as<float>());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto rotationNode = entity["Transform"]["Rotation"];
 | 
					 | 
				
			||||||
			tc.Rotation = glm::vec3(rotationNode[0].as<float>(), rotationNode[1].as<float>(), rotationNode[2].as<float>());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			auto scaleNode = entity["Transform"]["Scale"];
 | 
					 | 
				
			||||||
			tc.Scale = glm::vec3(scaleNode[0].as<float>(), scaleNode[1].as<float>(), scaleNode[2].as<float>());
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (entity["Light"]) {
 | 
					 | 
				
			||||||
			LightComponent lc = SE.AddComponent<LightComponent>();
 | 
					 | 
				
			||||||
			lc.Strength = entity["Light"]["strength"].as<float>();
 | 
					 | 
				
			||||||
			lc.Color = glm::vec3(entity["Light"]["Color"][0].as<float>(), entity["Light"]["Color"][1].as<float>(), entity["Light"]["Color"][2].as<float>());
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 }
 | 
					 | 
				
			||||||
@ -1,72 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
#include <nfd.h>
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <functional>
 | 
					 | 
				
			||||||
#include "Project.h"
 | 
					 | 
				
			||||||
struct DialogSpec {
 | 
					 | 
				
			||||||
    const std::string& id;
 | 
					 | 
				
			||||||
    const std::string& Title;
 | 
					 | 
				
			||||||
    const std::string& confirmText;
 | 
					 | 
				
			||||||
    DialogSpec() = default;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//classes based on RAII
 | 
					 | 
				
			||||||
class Dialog {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	Dialog( DialogSpec spec, std::function<void(std::string&)> onConfirm)
 | 
					 | 
				
			||||||
	: path(nullptr), location() {
 | 
					 | 
				
			||||||
        if (ImGui::BeginPopupModal(spec.id.c_str(), NULL, ImGuiWindowFlags_NoMove))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            ImGui::Text(spec.Title.c_str());
 | 
					 | 
				
			||||||
            ImGui::Separator();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::LabelText("##Directory", "Directory: %s", location.c_str());
 | 
					 | 
				
			||||||
            if (ImGui::Button("...")) {
 | 
					 | 
				
			||||||
                nfdresult_t result = NFD_OpenDialog(NULL, NULL, &path);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case (NFD_OKAY):
 | 
					 | 
				
			||||||
                    location = std::string(path);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_CANCEL" << std::endl;
 | 
					 | 
				
			||||||
                case (NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::Button(spec.confirmText.c_str(), ImVec2(120, 0)))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                onConfirm(location);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                ImGui::CloseCurrentPopup();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::SetItemDefaultFocus();
 | 
					 | 
				
			||||||
            ImGui::SameLine();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::Button("Cancel", ImVec2(120, 0)))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                ImGui::CloseCurrentPopup();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndPopup();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	~Dialog() {
 | 
					 | 
				
			||||||
		delete path;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
protected :
 | 
					 | 
				
			||||||
	char* path;
 | 
					 | 
				
			||||||
	std::string location;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@ -1,35 +0,0 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include "EditorConsole.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EditorConsole::EditorConsole()
 | 
					 | 
				
			||||||
	: Items(ImVector<char*>()), AutoScroll(false), ScrollToBottom(false)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	AddLog("Hello Editor console!");
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EditorConsole::~EditorConsole() {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void EditorConsole::Draw() {
 | 
					 | 
				
			||||||
	ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (int i = 0; i < Items.Size; i++) 
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		const char* item = Items[i];
 | 
					 | 
				
			||||||
		ImGui::TextUnformatted(item);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void EditorConsole::AddLog(const char* fmt, ...) {
 | 
					 | 
				
			||||||
	char buf[1024];
 | 
					 | 
				
			||||||
	va_list args;
 | 
					 | 
				
			||||||
	va_start(args, fmt);
 | 
					 | 
				
			||||||
	vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args);
 | 
					 | 
				
			||||||
	buf[IM_ARRAYSIZE(buf) - 1] = 0;
 | 
					 | 
				
			||||||
	va_end(args);
 | 
					 | 
				
			||||||
	Items.push_back(strdup(buf));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,18 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class EditorConsole 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	EditorConsole();
 | 
					 | 
				
			||||||
	~EditorConsole();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void Draw();
 | 
					 | 
				
			||||||
	void AddLog(const  char* fmt, ...);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
	ImVector<char*> Items;
 | 
					 | 
				
			||||||
	bool AutoScroll;
 | 
					 | 
				
			||||||
	bool ScrollToBottom;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,14 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class EditorWindow {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	EditorWindow(const std::string& name, ImGuiWindowFlags_ flags = ImGuiWindowFlags_None ) { ImGui::Begin(name.c_str(), false ,flags); }
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	~EditorWindow() { ImGui::End(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,71 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
#include <backends/imgui_impl_opengl3.h>
 | 
					 | 
				
			||||||
#include <backends/imgui_impl_glfw.h>
 | 
					 | 
				
			||||||
#include <ImGuizmo.h>
 | 
					 | 
				
			||||||
#include "../../src/YoggieEngine.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class GUIRenderer {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	GUIRenderer(YoggieEngine::NativeWindow& window ) {
 | 
					 | 
				
			||||||
		IMGUI_CHECKVERSION();
 | 
					 | 
				
			||||||
		ImGui::CreateContext();
 | 
					 | 
				
			||||||
		ImGuiIO& io = ImGui::GetIO();
 | 
					 | 
				
			||||||
		io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
 | 
					 | 
				
			||||||
		io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
 | 
					 | 
				
			||||||
		io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui::StyleColorsDark();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
 | 
					 | 
				
			||||||
		ImGui_ImplOpenGL3_Init("#version 450");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
 | 
					 | 
				
			||||||
		ImGuizmo::SetOrthographic(true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void Begin ()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		ImGui_ImplGlfw_NewFrame();
 | 
					 | 
				
			||||||
		ImGui_ImplOpenGL3_NewFrame();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui::NewFrame();
 | 
					 | 
				
			||||||
		ImGuizmo::BeginFrame();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void End()
 | 
					 | 
				
			||||||
	{	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui::EndFrame();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui::Render();
 | 
					 | 
				
			||||||
		ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			GLFWwindow* last_context = glfwGetCurrentContext();
 | 
					 | 
				
			||||||
			ImGui::UpdatePlatformWindows();
 | 
					 | 
				
			||||||
			ImGui::RenderPlatformWindowsDefault();
 | 
					 | 
				
			||||||
			glfwMakeContextCurrent(last_context);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	~GUIRenderer(){
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		ImGui_ImplOpenGL3_Shutdown();
 | 
					 | 
				
			||||||
		ImGui_ImplGlfw_Shutdown();
 | 
					 | 
				
			||||||
		ImGui::DestroyContext();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,172 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class MainMenuBar {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	MainMenuBar() { ImGui::BeginMainMenuBar(); }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void ApplicationMenu(std::unique_ptr<Project>& project) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Application")) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Load Project"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                nfdresult_t result = NFD_OpenDialog({ "yproj" }, NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case(NFD_OKAY):
 | 
					 | 
				
			||||||
                    Project::LoadProject(path, project);
 | 
					 | 
				
			||||||
                    AssetManager::setAssetPath(project.get()->GetProjectDirectory());
 | 
					 | 
				
			||||||
                    AssetManager::BuildAssetView();
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Save project as...")) {
 | 
					 | 
				
			||||||
                nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case(NFD_OKAY):
 | 
					 | 
				
			||||||
                    std::cout << "Save as: " << path << std::endl;
 | 
					 | 
				
			||||||
                    Project::SaveProject(path, *project.get());
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Preferences"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Exit"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                // TODO: Exit application
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void SceneMenu(std::unique_ptr<Project>& project,  Scene& scene) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Scene")) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Save scene"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                nfdresult_t result = NFD_SaveDialog({ "yscene" }, NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case(NFD_OKAY):
 | 
					 | 
				
			||||||
                    SaveScene(path, scene);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Load scene"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                auto result = NFD_OpenDialog({ "yscene" }, NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case (NFD_OKAY):
 | 
					 | 
				
			||||||
                    LoadScene(path, scene);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Add Entity"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                scene.AddEntity("New Entity");
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Import Model"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                auto result = NFD_OpenDialog("obj,fbx,gltf", NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case(NFD_OKAY):
 | 
					 | 
				
			||||||
                    // Import Model
 | 
					 | 
				
			||||||
                    AssetManager::LoadFromSource(
 | 
					 | 
				
			||||||
                        path,
 | 
					 | 
				
			||||||
                        project.get()->GetProjectDirectory() / "Assets"
 | 
					 | 
				
			||||||
                    );
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::MenuItem("Import MeshAsset (temp)"))
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                auto result = NFD_OpenDialog("mesh", NULL, &path);
 | 
					 | 
				
			||||||
                switch (result) {
 | 
					 | 
				
			||||||
                case(NFD_OKAY):
 | 
					 | 
				
			||||||
                    AssetManager::LoadFromAssetFile(path);
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_CANCEL):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                case(NFD_ERROR):
 | 
					 | 
				
			||||||
                    break;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void DebugMenu() 
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Debug")) {
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void SelectMenu() {
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Select")) {
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void WindowMenu() {
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Window")) {
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void Help() {
 | 
					 | 
				
			||||||
        if (ImGui::BeginMenu("Help")) {
 | 
					 | 
				
			||||||
            ImGui::EndMenu();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	~MainMenuBar() { ImGui::EndMainMenuBar(); }
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    char* path = nullptr;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,362 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <glm/glm.hpp>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
#include "../../libs/guizmo/ImGuizmo.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/YoggieEngine.h"
 | 
					 | 
				
			||||||
#include "../../src/Scene/Entity.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "EditorWindow.h"
 | 
					 | 
				
			||||||
#include "EditorConsole.h"
 | 
					 | 
				
			||||||
#include "../Project/Project.h"
 | 
					 | 
				
			||||||
#include "../AssetManagement/AssetManager.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
typedef void ( *voidFunction ) (void);
 | 
					 | 
				
			||||||
using namespace YoggieEngine;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
auto matrix = glm::mat4(1.0f);
 | 
					 | 
				
			||||||
auto worldOrigin = glm::mat4(1.0f);
 | 
					 | 
				
			||||||
auto projection = glm::perspective(45.0f, 0.89f, 0.001f, 1.0f);
 | 
					 | 
				
			||||||
auto view = glm::mat4(1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
inline void ComponentView(const std::string& componentName, voidFunction func)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    ImGuiWindowFlags_ window_flags = ImGuiWindowFlags_None;
 | 
					 | 
				
			||||||
    ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
 | 
					 | 
				
			||||||
    ImGui::BeginChild(componentName.c_str());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    func();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::EndChild();
 | 
					 | 
				
			||||||
    ImGui::PopStyleVar();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Inspector : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
	Inspector() : EditorWindow("Inspector") {}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void AddComponentDropDown(Entity& selected ) 
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
		static char* names[] = { "Script Component", "Camera Component" };
 | 
					 | 
				
			||||||
        if (ImGui::Button("Add Component"))
 | 
					 | 
				
			||||||
            ImGui::OpenPopup("Component picker");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::SameLine();
 | 
					 | 
				
			||||||
        if (ImGui::BeginPopup("Component picker")) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            for (int i = 0; i < IM_ARRAYSIZE(names); i++)
 | 
					 | 
				
			||||||
                if (ImGui::MenuItem(names[i])) {
 | 
					 | 
				
			||||||
                    std::cout << "Add a " << names[i] << " to "
 | 
					 | 
				
			||||||
                        << selected.GetComponent<IdentifierComponent>().name << std::endl;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndPopup();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        ImGui::NewLine();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
    void ShowComponents(Entity& selected) 
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
        auto component = selected.GetComponent<IdentifierComponent>();
 | 
					 | 
				
			||||||
        char* buf = new char(component.name.size());
 | 
					 | 
				
			||||||
        strcpy(buf, component.name.c_str());
 | 
					 | 
				
			||||||
        ImGui::InputText("Name:", buf, sizeof(buf), ImGuiInputTextFlags_ReadOnly);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (selected.HasComponent<TransformComponent>()) {
 | 
					 | 
				
			||||||
            auto& transform = selected.GetComponent<TransformComponent>();
 | 
					 | 
				
			||||||
            if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
 | 
					 | 
				
			||||||
                ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.01f);
 | 
					 | 
				
			||||||
                ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.01f);
 | 
					 | 
				
			||||||
                ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.01f, 0.0f);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (selected.HasComponent<Render3DComponent>()) {
 | 
					 | 
				
			||||||
            auto& render3d = selected.GetComponent<Render3DComponent>();
 | 
					 | 
				
			||||||
            if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {
 | 
					 | 
				
			||||||
                ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (selected.HasComponent<LightComponent>()) {
 | 
					 | 
				
			||||||
            auto& light = selected.GetComponent<LightComponent>();
 | 
					 | 
				
			||||||
            if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
 | 
					 | 
				
			||||||
                ImGui::DragFloat("Strength", &light.Strength, 0.001f);
 | 
					 | 
				
			||||||
                ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color));
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (selected.HasComponent <CameraComponent>()) {
 | 
					 | 
				
			||||||
            auto& camera = selected.GetComponent<CameraComponent>();
 | 
					 | 
				
			||||||
            static float Zoom = 90;
 | 
					 | 
				
			||||||
            static glm::vec3 Position, Rotation = glm::vec3(0.0f);
 | 
					 | 
				
			||||||
            ComponentView("Camera", [] {
 | 
					 | 
				
			||||||
                ImGui::SliderFloat("Zoom", &Zoom, 10, 190);
 | 
					 | 
				
			||||||
            ImGui::InputFloat3("Position:", &Position[0]);
 | 
					 | 
				
			||||||
            ImGui::InputFloat3("Rotation:", &Rotation[0]);
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (selected.HasComponent<ScriptComponent>()) {
 | 
					 | 
				
			||||||
            ComponentView("Scripting", [] {
 | 
					 | 
				
			||||||
                ImGui::LabelText("##--", "Hello scripting");
 | 
					 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SceneExplorer : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    SceneExplorer(entt::entity& selected , Scene& scene) : EditorWindow("SceneExplorer") {
 | 
					 | 
				
			||||||
        scene.getReg().each([&](entt::entity enttNumber) {
 | 
					 | 
				
			||||||
            Entity entity = Entity(enttNumber, &scene);
 | 
					 | 
				
			||||||
            auto id = entity.GetComponent<IdentifierComponent>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (ImGui::Selectable(id.name.c_str(), enttNumber == selected)) {
 | 
					 | 
				
			||||||
                selected = enttNumber;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Viewport : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    Viewport (Framebuffer& fb, Camera cam ) : EditorWindow("SceneView") 
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ImVec2 WinPos = ImGui::GetWindowPos();
 | 
					 | 
				
			||||||
        ImVec2 ContentRegionMin = ImGui::GetWindowContentRegionMin();
 | 
					 | 
				
			||||||
        ImVec2 ContentRegionMax = ImGui::GetWindowContentRegionMax();
 | 
					 | 
				
			||||||
        ImVec2 ScreenSpaceMin = { ContentRegionMin.x + WinPos.x, ContentRegionMin.y + WinPos.y };
 | 
					 | 
				
			||||||
        ImVec2 ScreenSpaceMax = { ContentRegionMax.x + WinPos.x,ContentRegionMax.y + WinPos.y };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::Image(
 | 
					 | 
				
			||||||
            (void*)(intptr_t)fb.GetColourAttachment(),
 | 
					 | 
				
			||||||
            ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGuizmo::Enable(true);
 | 
					 | 
				
			||||||
        ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y,ContentRegionMax.x, ContentRegionMax.y);
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        ImGuizmo::ViewManipulate(glm::value_ptr(cam.ViewMatrix), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
 | 
					 | 
				
			||||||
        ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
 | 
					 | 
				
			||||||
      
 | 
					 | 
				
			||||||
        // Matrix is the model matrix we would want to manipulate
 | 
					 | 
				
			||||||
        ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(matrix));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int selectedGfxAPI = 0;
 | 
					 | 
				
			||||||
int selectedPhysicsEngine = 0;
 | 
					 | 
				
			||||||
glm::vec3 Gravity = glm::vec3(0.0f, -9.81f, 0.0f);
 | 
					 | 
				
			||||||
bool ShowAdvancedOptions = false;
 | 
					 | 
				
			||||||
bool DebugEngine = false;
 | 
					 | 
				
			||||||
class Settings : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    Settings() : EditorWindow("Settings") 
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ImGui::LabelText("##title-settings", "Fine grain control over the engine!");
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        if (ImGui::BeginCombo("Graphics API", GraphicsAPI[selectedGfxAPI])) {
 | 
					 | 
				
			||||||
            for (int i = 0; i < 3; i++) {
 | 
					 | 
				
			||||||
                bool isSelected = i == selectedGfxAPI;
 | 
					 | 
				
			||||||
                if (ImGui::Selectable(GraphicsAPI[i], isSelected)) {
 | 
					 | 
				
			||||||
                    selectedGfxAPI = i;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if(isSelected)
 | 
					 | 
				
			||||||
                    ImGui::SetItemDefaultFocus();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
         
 | 
					 | 
				
			||||||
            ImGui::EndCombo();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::NewLine();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ImGui::BeginCombo("Physics Engine", PhysicsEngine[selectedPhysicsEngine])) {
 | 
					 | 
				
			||||||
            for (int i = 0; i < 2; i++) {
 | 
					 | 
				
			||||||
                bool isSelected = i == selectedPhysicsEngine;
 | 
					 | 
				
			||||||
                if (ImGui::Selectable(PhysicsEngine[i], isSelected)) {
 | 
					 | 
				
			||||||
                    selectedGfxAPI = i;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (isSelected)
 | 
					 | 
				
			||||||
                    ImGui::SetItemDefaultFocus();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::EndCombo();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::InputFloat3("Gravity", glm::value_ptr(Gravity));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::NewLine();
 | 
					 | 
				
			||||||
        if (ImGui::Button("Show Advanced options ")) {
 | 
					 | 
				
			||||||
            ShowAdvancedOptions = !ShowAdvancedOptions;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ShowAdvancedOptions) 
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            ImGui::Checkbox("Debug Engine", &DebugEngine);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const char* PhysicsEngine[2] = {
 | 
					 | 
				
			||||||
        "PhysX",
 | 
					 | 
				
			||||||
        "Jolt Physics"
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const char* GraphicsAPI[3] = {
 | 
					 | 
				
			||||||
        "OpenGL",
 | 
					 | 
				
			||||||
        "Vulkan",
 | 
					 | 
				
			||||||
        "Metal (Apple)"
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ProjectInfo : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    ProjectInfo(Project& project) : EditorWindow("Project Info") {
 | 
					 | 
				
			||||||
        ImGui::Text("Project: %s", project.GetName().c_str());
 | 
					 | 
				
			||||||
        ImGui::Text("Directory: %s", project.GetProjectDirectory().u8string().c_str());
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Console : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Console() : EditorWindow("Console") {
 | 
					 | 
				
			||||||
    s_console = std::make_unique<EditorConsole>();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
void Show() {
 | 
					 | 
				
			||||||
    s_console.get()->Draw();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private: 
 | 
					 | 
				
			||||||
    std::unique_ptr<EditorConsole> s_console;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class AssetFinder : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    AssetFinder() : EditorWindow("Assets") {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (ImGui::BeginTable("##resources", 3))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f));
 | 
					 | 
				
			||||||
            ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f));
 | 
					 | 
				
			||||||
            ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Texture folderIcon = Texture("rsc/folderIcon.png");
 | 
					 | 
				
			||||||
            Texture assetIcon = Texture("rsc/assetIcon.png");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            int row = 0;
 | 
					 | 
				
			||||||
            int column = 0;
 | 
					 | 
				
			||||||
            for (auto& asset : AssetManager::assets) {
 | 
					 | 
				
			||||||
                if (column % 3 == 0) {
 | 
					 | 
				
			||||||
                    ImGui::TableNextRow();
 | 
					 | 
				
			||||||
                    column = 0;
 | 
					 | 
				
			||||||
                    row++;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                ImGui::TableSetColumnIndex(column);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (asset.isFolder) {
 | 
					 | 
				
			||||||
                    ImGui::ImageButton(
 | 
					 | 
				
			||||||
                        (ImTextureID)folderIcon.GetID(),
 | 
					 | 
				
			||||||
                        ImVec2{ (float)iconSize,(float)iconSize });
 | 
					 | 
				
			||||||
                    ImGui::Text(asset.GetName(), row);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                else {
 | 
					 | 
				
			||||||
                    ImGui::ImageButton(
 | 
					 | 
				
			||||||
                        (ImTextureID)assetIcon.GetID(),
 | 
					 | 
				
			||||||
                        ImVec2{ (float)iconSize, (float)iconSize });
 | 
					 | 
				
			||||||
                    ImGui::Text(asset.GetName(), row);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                column++;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            ImGui::PopStyleColor(3);
 | 
					 | 
				
			||||||
            ImGui::EndTable();
 | 
					 | 
				
			||||||
            const GLuint textures[2]{ assetIcon.GetID(), folderIcon.GetID() };
 | 
					 | 
				
			||||||
            glDeleteTextures(2,  textures );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    int iconSize = 60;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define RuntimeControlWindowFlags (ImGuiWindowFlags_)(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct ButtonInfo {
 | 
					 | 
				
			||||||
    const char* Name;
 | 
					 | 
				
			||||||
    ImVec4 Color;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class RuntimeControls : EditorWindow {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    RuntimeControls() : EditorWindow("RuntimeControls", RuntimeControlWindowFlags) {
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - ( numButtons * buttonSize.x ));
 | 
					 | 
				
			||||||
        for (int i = 0; i < numButtons; i++) {
 | 
					 | 
				
			||||||
            ImVec4 color = button[i].Color;
 | 
					 | 
				
			||||||
            ImGui::PushStyleColor(ImGuiCol_Button, color);
 | 
					 | 
				
			||||||
            const float strengthIncrease = 1.5f;
 | 
					 | 
				
			||||||
            ImGui::PushStyleColor(
 | 
					 | 
				
			||||||
                ImGuiCol_ButtonHovered, 
 | 
					 | 
				
			||||||
                ImVec4{
 | 
					 | 
				
			||||||
                    color.x * strengthIncrease,
 | 
					 | 
				
			||||||
                    color.y * strengthIncrease,
 | 
					 | 
				
			||||||
                    color.z * strengthIncrease,
 | 
					 | 
				
			||||||
                    color.w 
 | 
					 | 
				
			||||||
                } 
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
            if (ImGui::Button(button[i].Name, buttonSize)) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            ImGui::PopStyleColor();
 | 
					 | 
				
			||||||
            ImGui::PopStyleColor();
 | 
					 | 
				
			||||||
            ImGui::SameLine();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    ImVec2 buttonSize = ImVec2{ 90 ,25 };
 | 
					 | 
				
			||||||
    unsigned int numButtons = 2;
 | 
					 | 
				
			||||||
    ButtonInfo button[2] = {
 | 
					 | 
				
			||||||
        {"Play" , ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001* 69, 1.0f}},
 | 
					 | 
				
			||||||
        {"Simulate", ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f}}
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,218 +0,0 @@
 | 
				
			|||||||
#include "../../YoggieEngine/src/EntryPoint.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/AssetManager/ModelImporter.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Physics/Physics.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <nfd.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <glm/glm.hpp>
 | 
					 | 
				
			||||||
#include <glm/gtc/type_ptr.hpp>
 | 
					 | 
				
			||||||
#include <glm/gtc/matrix_transform.hpp>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "UI/GUIRenderer.h"
 | 
					 | 
				
			||||||
#include "UI/Widgets.h"
 | 
					 | 
				
			||||||
#include "Project/Project.h"
 | 
					 | 
				
			||||||
#include "SceneSerializer.h"
 | 
					 | 
				
			||||||
#include "AssetManagement/AssetManager.h"
 | 
					 | 
				
			||||||
#include "UI/MainMenuBar.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const unsigned int MS_PER_UPDATE = 2;
 | 
					 | 
				
			||||||
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
RendererConfig EditorSceneRendererConfig{
 | 
					 | 
				
			||||||
    1200, // Screen Width
 | 
					 | 
				
			||||||
    700, // Screen Height
 | 
					 | 
				
			||||||
    glm::vec3{0,0,0}, // Clear Color
 | 
					 | 
				
			||||||
    true // Depth testing  
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class Editor : public Application {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    Editor() 
 | 
					 | 
				
			||||||
        : Application("Editor"),
 | 
					 | 
				
			||||||
        AppWindow(1200,700),
 | 
					 | 
				
			||||||
        framebuffer(new Framebuffer(1200,700)),
 | 
					 | 
				
			||||||
        viewportRenderer(EditorSceneRendererConfig),
 | 
					 | 
				
			||||||
        EditorGUIRenderer(AppWindow),
 | 
					 | 
				
			||||||
        Selected((entt::entity)-1)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        viewportRenderer.setCurrentFrameBuffer(*framebuffer);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void RenderScene() {
 | 
					 | 
				
			||||||
        // submit DrawCommands for all render3DComponents            
 | 
					 | 
				
			||||||
        auto group = ActiveScene.getReg().view<TransformComponent, Render3DComponent>();
 | 
					 | 
				
			||||||
        group.each([&](auto enity, TransformComponent& t, Render3DComponent& renderComponent) {
 | 
					 | 
				
			||||||
            viewportRenderer.Submit(renderComponent, t);
 | 
					 | 
				
			||||||
            });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        viewportRenderer.Render();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void RenderEditorGUI() {
 | 
					 | 
				
			||||||
        EditorGUIRenderer.Begin();
 | 
					 | 
				
			||||||
        ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Show a menu bar
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            MainMenuBar menuBar = MainMenuBar();
 | 
					 | 
				
			||||||
            menuBar.ApplicationMenu(CurrentProject);
 | 
					 | 
				
			||||||
            menuBar.SceneMenu(CurrentProject, ActiveScene);
 | 
					 | 
				
			||||||
            menuBar.SelectMenu();
 | 
					 | 
				
			||||||
            menuBar.WindowMenu();
 | 
					 | 
				
			||||||
            menuBar.DebugMenu();
 | 
					 | 
				
			||||||
            menuBar.Help();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
                ProjectInfo projectInfo(*(CurrentProject.get()));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Viewport sceneview = Viewport(*framebuffer, viewportRenderer.getCamera());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            RuntimeControls rc = RuntimeControls();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            SceneExplorer explorer(Selected, ActiveScene);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Inspector inspector = Inspector();
 | 
					 | 
				
			||||||
            if (ActiveScene.getReg().valid(Selected)) {
 | 
					 | 
				
			||||||
                Entity SelectedEntity = Entity(Selected, &ActiveScene);
 | 
					 | 
				
			||||||
                inspector.AddComponentDropDown(SelectedEntity);
 | 
					 | 
				
			||||||
                inspector.ShowComponents(SelectedEntity);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Settings settings = Settings();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            // AssetFinder assetsView = AssetFinder();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            Console console = Console();
 | 
					 | 
				
			||||||
            console.Show();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::ShowDemoWindow();
 | 
					 | 
				
			||||||
        ImGui::ShowMetricsWindow();
 | 
					 | 
				
			||||||
        EditorGUIRenderer.End();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void Run() override
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        CreateTestProject(CurrentProject, ActiveScene);
 | 
					 | 
				
			||||||
        ActiveScene.Start();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Create the physics engine demo!
 | 
					 | 
				
			||||||
        Physics Physics;
 | 
					 | 
				
			||||||
        //Physics.Demo();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        double previous = glfwGetTime();
 | 
					 | 
				
			||||||
        double lag = 0.0;
 | 
					 | 
				
			||||||
        while (!AppWindow.WindowShouldClose())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            double current = glfwGetTime();
 | 
					 | 
				
			||||||
            double elapsed = current - previous;
 | 
					 | 
				
			||||||
            previous = current;
 | 
					 | 
				
			||||||
            lag += elapsed;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            AppWindow.Poll();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (SimulatePhysics)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                Physics.Step(1.0f / 60.0f);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            while (lag >= MS_PER_UPDATE) 
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                ActiveScene.Update();
 | 
					 | 
				
			||||||
                lag -= MS_PER_UPDATE;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            RenderScene();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            RenderEditorGUI();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            AppWindow.SwapBuffers();
 | 
					 | 
				
			||||||
            glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        delete framebuffer;
 | 
					 | 
				
			||||||
        ActiveScene.Stop();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    NativeWindow AppWindow;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    Framebuffer* framebuffer;
 | 
					 | 
				
			||||||
    Renderer viewportRenderer;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    GUIRenderer EditorGUIRenderer;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Editor State 
 | 
					 | 
				
			||||||
    bool SimulatePhysics = false;
 | 
					 | 
				
			||||||
    entt::entity  Selected;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::unique_ptr<Project> CurrentProject;
 | 
					 | 
				
			||||||
    Scene ActiveScene;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
YoggieEngine::Application* CreateApplication() {
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
    return new Editor();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene ) {
 | 
					 | 
				
			||||||
    project = std::make_unique<Project>();
 | 
					 | 
				
			||||||
    std::string path = (std::filesystem::current_path()).string();
 | 
					 | 
				
			||||||
    project.get()->setProjectDirectory(path);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    AssetManager::Init();
 | 
					 | 
				
			||||||
    AssetManager::setAssetPath(project.get()->GetProjectDirectory());
 | 
					 | 
				
			||||||
    AssetManager::BuildAssetView();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Create a level and load it as the current level
 | 
					 | 
				
			||||||
    auto importer = ModelImporter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Create a cube 
 | 
					 | 
				
			||||||
    auto model = importer.Import("build/Debug/Models/Cube.obj");
 | 
					 | 
				
			||||||
    auto cube = scene.AddEntity("Cube");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    auto& render3DComponent = cube.AddComponent<Render3DComponent>();
 | 
					 | 
				
			||||||
    render3DComponent.mesh = *(model->renderable->mesh);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cube.GetComponent<TransformComponent>().Position = glm::vec3(1.0f, 0.0f, 5.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    auto cube2 = scene.AddEntity("Cube1");
 | 
					 | 
				
			||||||
    auto& rendercube2 = cube2.AddComponent<Render3DComponent>();
 | 
					 | 
				
			||||||
    rendercube2.mesh = *(model->renderable->mesh);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // create an ambient light source
 | 
					 | 
				
			||||||
    auto AmbientLight = scene.AddEntity("AmbientLight");
 | 
					 | 
				
			||||||
    auto light = AmbientLight.AddComponent<LightComponent>();
 | 
					 | 
				
			||||||
    light.Color = glm::vec3(1.0f);
 | 
					 | 
				
			||||||
    light.Strength = 1.0f;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										26
									
								
								Features.md
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								Features.md
									
									
									
									
									
								
							@ -1,26 +0,0 @@
 | 
				
			|||||||
# Yoggie Engine features
 | 
					 | 
				
			||||||
## Features
 | 
					 | 
				
			||||||
**NOTE** __Not in any particular order__    
 | 
					 | 
				
			||||||
- Rendering
 | 
					 | 
				
			||||||
    - OpenGL
 | 
					 | 
				
			||||||
    - Vulkan
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Logging
 | 
					 | 
				
			||||||
    - Different for debug and release
 | 
					 | 
				
			||||||
    - Different per OS
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
- Physics
 | 
					 | 
				
			||||||
    -  PhysX
 | 
					 | 
				
			||||||
    - Alternative for non-nvidia stuff?!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Basic Entity Component system
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Graphical scripting ??
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
- Scripting support ( idk what language)
 | 
					 | 
				
			||||||
    - LUA
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
- Configuration options 
 | 
					 | 
				
			||||||
    - JSON 
 | 
					 | 
				
			||||||
    - LUA
 | 
					 | 
				
			||||||
    - YAML
 | 
					 | 
				
			||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
project "ImGui"
 | 
					project "ImGUI_Opengl3"
 | 
				
			||||||
  kind "StaticLib"
 | 
					  kind "StaticLib"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  includedirs {
 | 
					  includedirs {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
project "ImGuizmo"
 | 
					 | 
				
			||||||
  kind "StaticLib"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  includedirs {
 | 
					 | 
				
			||||||
    "../libs/glfw/include",
 | 
					 | 
				
			||||||
    "../libs/ImGui",
 | 
					 | 
				
			||||||
    "../libs/guizmo"
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  files {
 | 
					 | 
				
			||||||
    "../libs/guizmo/*.cpp",
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  libdirs{
 | 
					 | 
				
			||||||
    "../libs/ImGui",
 | 
					 | 
				
			||||||
    "../libs/glad"
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  include("../ImGui")
 | 
					 | 
				
			||||||
							
								
								
									
										
											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.
										
									
								
							
							
								
								
									
										54
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								README.md
									
									
									
									
									
								
							@ -1,18 +1,54 @@
 | 
				
			|||||||
# Yoggie Engine
 | 
					# BarinkEngine
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					    ,---,.                                           ,-.    ,---,.                                                  
 | 
				
			||||||
 | 
					  ,'  .'  \                   ,--,               ,--/ /|  ,'  .' |                      ,--,                        
 | 
				
			||||||
 | 
					,---.' .' |           __  ,-,--.'|        ,---,,--. :/ |,---.'   |     ,---,          ,--.'|        ,---,           
 | 
				
			||||||
 | 
					|   |  |: |         ,' ,'/ /|  |,     ,-+-. /  :  : ' / |   |   .' ,-+-. /  | ,----._,|  |,     ,-+-. /  |          
 | 
				
			||||||
 | 
					:   :  :  / ,--.--. '  | |' `--'_    ,--.'|'   |  '  /  :   :  |-,,--.'|'   |/   /  ' `--'_    ,--.'|'   |  ,---.   
 | 
				
			||||||
 | 
					:   |    ; /       \|  |   ,,' ,'|  |   |  ,"' '  |  :  :   |  ;/|   |  ,"' |   :     ,' ,'|  |   |  ,"' | /     \  
 | 
				
			||||||
 | 
					|   :     .--.  .-. '  :  / '  | |  |   | /  | |  |   \ |   :   .|   | /  | |   | .\  '  | |  |   | /  | |/    /  | 
 | 
				
			||||||
 | 
					|   |   . |\__\/: . |  | '  |  | :  |   | |  | '  : |. \|   |  |-|   | |  | .   ; ';  |  | :  |   | |  | .    ' / | 
 | 
				
			||||||
 | 
					'   :  '; |," .--.; ;  : |  '  : |__|   | |  |/|  | ' \ '   :  ;/|   | |  |/'   .   . '  : |__|   | |  |/'   ;   /| 
 | 
				
			||||||
 | 
					|   |  | ;/  /  ,.  |  , ;  |  | '.'|   | |--' '  : |--'|   |    |   | |--'  `---`-'| |  | '.'|   | |--' '   |  / | 
 | 
				
			||||||
 | 
					|   :   /;  :   .'   ---'   ;  :    |   |/     ;  |,'   |   :   .|   |/      .'__/\_: ;  :    |   |/     |   :    | 
 | 
				
			||||||
 | 
					|   | ,' |  ,     .-./      |  ,   /'---'      '--'     |   | ,' '---'       |   :    |  ,   /'---'       \   \  /  
 | 
				
			||||||
 | 
					`----'    `--`---'           ---`-'                     `----'                \   \  / ---`-'              `----'   
 | 
				
			||||||
 | 
					                                                                               `--`-'         
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<img src="Screenshots/Yoggie.webp" width="400" ></img>
 | 
					## Features
 | 
				
			||||||
 | 
					**NOTE** __Not in any particular order__    
 | 
				
			||||||
 | 
					- Rendering
 | 
				
			||||||
 | 
					    - OpenGL
 | 
				
			||||||
 | 
					    - Vulkan
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Logging
 | 
				
			||||||
 | 
					    - Different for debug and release
 | 
				
			||||||
 | 
					    - Different per OS
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					- Physics
 | 
				
			||||||
 | 
					    -  PhysX
 | 
				
			||||||
 | 
					    - Alternative for non-nvidia stuff?!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Basic Entity Component system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Graphical scripting ??
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Scripting support ( idk what language)
 | 
				
			||||||
 | 
					    - LUA
 | 
				
			||||||
 | 
					- Configuration options 
 | 
				
			||||||
 | 
					    - JSON 
 | 
				
			||||||
 | 
					    - LUA
 | 
				
			||||||
 | 
					    - others ?!?!?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Screenshots
 | 
					## Screenshots
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<img src="Screenshots/screen1.png" width="300"></img>   \
 | 
					<img src="Screenshots/screen1.png" width="300"></img>
 | 
				
			||||||
<img src="Screenshots/screen2.png" width="300"></img>   \
 | 
					<img src="Screenshots/screen2.png" width="300"></img>
 | 
				
			||||||
<img src="Screenshots/YoggieEditor.png" width="300"></img>  \
 | 
					
 | 
				
			||||||
<img src="Screenshots/YoggieEditor_workingGuizmo.png" width="300"></img>    \
 | 
					 | 
				
			||||||
<img src="Screenshots/YoggieEditorV0.2.png" width="300"></img>
 | 
					 | 
				
			||||||
## Planning
 | 
					## Planning
 | 
				
			||||||
see [TODO](docs/TODO.md)    \
 | 
					see [TODO](docs/TODO.md)
 | 
				
			||||||
see [Features](Features.md)
 | 
					
 | 
				
			||||||
_NOTE:_ 
 | 
					_NOTE:_ 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The planning is moving away from markdown in favor 
 | 
					The planning is moving away from markdown in favor 
 | 
				
			||||||
 | 
				
			|||||||
@ -1,39 +0,0 @@
 | 
				
			|||||||
project "Runtime"
 | 
					 | 
				
			||||||
kind "ConsoleApp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
buildmessage "Building the runtime ..."
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
links{
 | 
					 | 
				
			||||||
  "YoggieEngine"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
includedirs{
 | 
					 | 
				
			||||||
  "./../YoggieEngine/src",
 | 
					 | 
				
			||||||
  -- I'd prefer if didn't need these..
 | 
					 | 
				
			||||||
  -- We'll figure that out some time later
 | 
					 | 
				
			||||||
  "./../libs/lua/include",
 | 
					 | 
				
			||||||
  "./../libs/spdlog/include",
 | 
					 | 
				
			||||||
  "./../libs/glm",
 | 
					 | 
				
			||||||
  "./../libs/GorillaAudio/include",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  "./../libs/assimp/include",
 | 
					 | 
				
			||||||
  "./../libs/glad/include",
 | 
					 | 
				
			||||||
  "./../libs/glfw/include",
 | 
					 | 
				
			||||||
  "./../libs/tinygltf",
 | 
					 | 
				
			||||||
  "./../libs/glew/include",
 | 
					 | 
				
			||||||
  "./../libs/glm",
 | 
					 | 
				
			||||||
  "./../libs/ImGui",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  "./include"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
libdirs {
 | 
					 | 
				
			||||||
  './../YoggieEngine/build/Debug'
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
files { 
 | 
					 | 
				
			||||||
  "./src/*.h",
 | 
					 | 
				
			||||||
  "./src/*.cpp"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,6 +0,0 @@
 | 
				
			|||||||
#include <iostream>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	std::cout << "Welcome to the runtime!" << std::endl;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,40 +0,0 @@
 | 
				
			|||||||
project "SandboxApp"
 | 
					 | 
				
			||||||
kind "ConsoleApp"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
buildmessage "Building SandboxApp ..."
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
links{
 | 
					 | 
				
			||||||
  "YoggieEngine"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
includedirs{
 | 
					 | 
				
			||||||
  "./../YoggieEngine/Include",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  -- I'd prefer if didn't need these..
 | 
					 | 
				
			||||||
  -- We'll figure that out some time later
 | 
					 | 
				
			||||||
  "./../libs/lua/include",
 | 
					 | 
				
			||||||
  "./../libs/spdlog/include",
 | 
					 | 
				
			||||||
  "./../libs/glm",
 | 
					 | 
				
			||||||
  "./../libs/GorillaAudio/include",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  "./../libs/assimp/include",
 | 
					 | 
				
			||||||
  "./../libs/glad/include",
 | 
					 | 
				
			||||||
  "./../libs/glfw/include",
 | 
					 | 
				
			||||||
  "./../libs/tinygltf",
 | 
					 | 
				
			||||||
  "./../libs/glew/include",
 | 
					 | 
				
			||||||
  "./../libs/glm",
 | 
					 | 
				
			||||||
  "./../libs/ImGui",
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  "../libs/entt/src",
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
libdirs {
 | 
					 | 
				
			||||||
  './../YoggieEngine/build/Debug'
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
files { 
 | 
					 | 
				
			||||||
  "./src/*.h",
 | 
					 | 
				
			||||||
  "./src/*.cpp"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,87 +0,0 @@
 | 
				
			|||||||
#include "GUI.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SceneExplorer(const std::string& PanelName) {
 | 
					 | 
				
			||||||
    ImGui::Begin(PanelName.c_str()); 
 | 
					 | 
				
			||||||
        //if (ImGui::ListBoxHeader("##ObjectList")) {
 | 
					 | 
				
			||||||
            //Node& current = scene.GetRoot();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
           //Node* next = ¤t;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
           // Show first node
 | 
					 | 
				
			||||||
           //ImGui::Selectable(next->name.c_str(), true);
 | 
					 | 
				
			||||||
           // ImGui::Selectable("Scene Node", true);
 | 
					 | 
				
			||||||
            // ImGui::Indent();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
             /*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
             if (next->children.size() != 0) {
 | 
					 | 
				
			||||||
                 for (auto child : next->children)
 | 
					 | 
				
			||||||
                 {
 | 
					 | 
				
			||||||
                     std::string& name = child->name;
 | 
					 | 
				
			||||||
                     ImGui::Selectable(name.c_str(), false);
 | 
					 | 
				
			||||||
                 }
 | 
					 | 
				
			||||||
             }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
             */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
         //   ImGui::ListBoxFooter();
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
}  
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CameraTool() {
 | 
					 | 
				
			||||||
    static float Zoom = 0;
 | 
					 | 
				
			||||||
    static glm::vec3 Position = glm::vec3(0.0f, 0.0f, 0.0f);
 | 
					 | 
				
			||||||
    static glm::vec3 Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::Begin("Camera");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::SliderFloat("Zoom:", &Zoom, 10, 190);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::InputFloat3("Position:", &Position[0]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::InputFloat3("Rotation:", &Rotation[0]);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ScriptingTool(char* code) {
 | 
					 | 
				
			||||||
    ImGui::Begin("Scripting");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::Text("Lua Code");
 | 
					 | 
				
			||||||
    ImGui::InputTextMultiline("##", code, 255);
 | 
					 | 
				
			||||||
    bool runCode = ImGui::Button("Run");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void SceneView(Framebuffer& framebuffer ) {
 | 
					 | 
				
			||||||
    ImGui::Begin("Viewport");
 | 
					 | 
				
			||||||
        ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{800, 600});
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* void transformWindow(Transform& transform, std::string PanelName) {
 | 
					 | 
				
			||||||
    ImGui::Begin(PanelName.c_str());
 | 
					 | 
				
			||||||
    ImGui::InputFloat3("Position:", (float*)&transform.Position[0]);
 | 
					 | 
				
			||||||
    ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]);
 | 
					 | 
				
			||||||
    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();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,11 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include "imgui.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/BarinkEngine.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Graphics/Memory/Framebuffer.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void CameraTool();
 | 
					 | 
				
			||||||
void ScriptingTool(char* code);
 | 
					 | 
				
			||||||
///void transformWindow(Transform& transform, std::string PanelName);
 | 
					 | 
				
			||||||
void materialWindow(Material& material, std::string PanelName);
 | 
					 | 
				
			||||||
void SceneExplorer(const std::string& PanelName);
 | 
					 | 
				
			||||||
void SceneView(Framebuffer& framebuffer);
 | 
					 | 
				
			||||||
@ -1,123 +0,0 @@
 | 
				
			|||||||
#include <imgui.h>
 | 
					 | 
				
			||||||
#include "GUI.h"
 | 
					 | 
				
			||||||
#include "Util.h"
 | 
					 | 
				
			||||||
#include <entt/entt.hpp>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/BarinkEngine.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Scene/Components.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Scene/Scene.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/Scene/Entity.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/AssetManager/ModelImporter.h"
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/PerfCounter.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* Define globals
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
Scene scene;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
BarinkEngine::Renderable* renderable;
 | 
					 | 
				
			||||||
BarinkEngine::SceneObject* object;
 | 
					 | 
				
			||||||
Entity cube;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* Runs once at startup 
 | 
					 | 
				
			||||||
* - USe to initialize the game/sandbox/demo
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
void Start() {
 | 
					 | 
				
			||||||
    auto importer = BarinkEngine::ModelImporter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Load in asset(S)
 | 
					 | 
				
			||||||
    object = importer.Import("build/Debug/Models/Cube.obj");
 | 
					 | 
				
			||||||
    renderable = object->renderable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Add Entities to the scene
 | 
					 | 
				
			||||||
    cube  = scene.AddEntity("cube");
 | 
					 | 
				
			||||||
    auto& render3DComponent = cube.AddComponent<BarinkEngine::Render3DComponent>();
 | 
					 | 
				
			||||||
    render3DComponent.mesh = *renderable->mesh;
 | 
					 | 
				
			||||||
    cube.GetComponent<BarinkEngine::TransformComponent>()
 | 
					 | 
				
			||||||
        .transform = glm::rotate(glm::mat4(1.0f), 32.0f, glm::vec3(0.5f,1.0f,0.0f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Create a second cube
 | 
					 | 
				
			||||||
   
 | 
					 | 
				
			||||||
    auto cube2 = scene.AddEntity("Cube2");
 | 
					 | 
				
			||||||
    auto& cube2Render = cube2.AddComponent<BarinkEngine::Render3DComponent>();
 | 
					 | 
				
			||||||
    cube2Render.mesh = *renderable->mesh;
 | 
					 | 
				
			||||||
    cube2Render.color = glm::vec3(0.0f, 1.0f, 0.0f);
 | 
					 | 
				
			||||||
    auto& cube2Trans = cube2.GetComponent<BarinkEngine::TransformComponent>();
 | 
					 | 
				
			||||||
    cube2Trans.transform = glm::translate( glm::mat4(1.0f), glm::vec3(1.0f,0.0f, 5.0f));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Create a light 
 | 
					 | 
				
			||||||
    auto AmbientLight = scene.AddEntity("AmbientLight");
 | 
					 | 
				
			||||||
    AmbientLight.AddComponent<BarinkEngine::LightComponent>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    renderer.Prepare(scene);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* Runs every frame
 | 
					 | 
				
			||||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
void ImmediateGraphicsDraw() 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    // Show internal BarinkEngine stats
 | 
					 | 
				
			||||||
    EngineInstrumentation::ShowStats();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::Begin("Scene view");
 | 
					 | 
				
			||||||
    auto group = scene.getReg().view<BarinkEngine::IdentifierComponent>();
 | 
					 | 
				
			||||||
    group.each([](auto entity, BarinkEngine::IdentifierComponent& identifier) {
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        ImGui::Text("%s", identifier.name.c_str());
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::ShowMetricsWindow();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    ImGui::Begin("Settings");
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        auto& a = cube.GetComponent<BarinkEngine::Render3DComponent>();
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
        auto& b = cube.GetComponent<BarinkEngine::TransformComponent>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::DragFloat3("Color", &a.color[0], 0.01f, 0.0f, 1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ImGui::DragFloat3("Position", &b.transform[3][0], 0.01f, 0.0f, 16.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        auto l = scene.getReg().view<BarinkEngine::LightComponent>();
 | 
					 | 
				
			||||||
        l.each([](auto entity, BarinkEngine::LightComponent& light) {
 | 
					 | 
				
			||||||
            ImGui::Text("Lighting");
 | 
					 | 
				
			||||||
            ImGui::SliderFloat("Intensity", &light.Strength, 0.0f, 1.0f);
 | 
					 | 
				
			||||||
            ImGui::SliderFloat3("l-Color", &light.Color[0], 0.0f, 1.0f);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    ImGui::End();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* Runs every frame
 | 
					 | 
				
			||||||
* - Meant for game logic ( non-physics related) 
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
void Update()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void Render() 
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    renderer.Render(scene);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
* Runs at the end of the program
 | 
					 | 
				
			||||||
* - Meant for cleanup
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
void Stop()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,6 +0,0 @@
 | 
				
			|||||||
#pragma once
 | 
					 | 
				
			||||||
#include "../../YoggieEngine/src/BarinkEngine.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//void PrintSceneTree(Node& node, int depth);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//glm::mat4 CalculateModelMat(Transform& transform);
 | 
					 | 
				
			||||||
							
								
								
									
										41
									
								
								SandboxApplication/GUI.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								SandboxApplication/GUI.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
				
			|||||||
 | 
					#include "GUI.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CameraTool(Camera* cam) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::Begin("Camera");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::InputFloat3("Position:", &cam->Position[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::End();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void ScriptingTool(char* code) {
 | 
				
			||||||
 | 
					    ImGui::Begin("Scripting");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::InputTextMultiline("Lua Script", code, 255);
 | 
				
			||||||
 | 
					    bool runCode = ImGui::Button("Run");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ImGui::End();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void transformWindow(Transform& transform, std::string PanelName) {
 | 
				
			||||||
 | 
					    ImGui::Begin(PanelName.c_str());
 | 
				
			||||||
 | 
					    ImGui::InputFloat3("Position:", (float*)&transform.Position[0]);
 | 
				
			||||||
 | 
					    ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]);
 | 
				
			||||||
 | 
					    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();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										8
									
								
								SandboxApplication/GUI.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								SandboxApplication/GUI.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +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);
 | 
				
			||||||
 | 
					void materialWindow(Material& material, std::string PanelName);
 | 
				
			||||||
							
								
								
									
										176
									
								
								SandboxApplication/Sandbox.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										176
									
								
								SandboxApplication/Sandbox.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,176 @@
 | 
				
			|||||||
 | 
					#include "BarinkEngine.h"
 | 
				
			||||||
 | 
					#include "imgui.h"
 | 
				
			||||||
 | 
					#include "GUI.h"
 | 
				
			||||||
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* Define globals
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					Camera* cam;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Shader* shader;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renderable* Cube;
 | 
				
			||||||
 | 
					Material* matCube;
 | 
				
			||||||
 | 
					Texture* textureCube;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Renderable* Cube2;
 | 
				
			||||||
 | 
					Material* matCube2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char* code = new char[254];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
 | 
				
			||||||
 | 
					const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* Runs once at startup 
 | 
				
			||||||
 | 
					* - USe to initialize the game/sandbox/demo
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void Start() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					        Building a very basic scene graph
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    SceneNode MyCube = SceneNode();
 | 
				
			||||||
 | 
					    MyCube.name = "MyCube";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SceneNode MyBaby = SceneNode();
 | 
				
			||||||
 | 
					    MyBaby.name = "Baby";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SceneNode MySecondCube = SceneNode();
 | 
				
			||||||
 | 
					    MySecondCube.name = "MySecondCube";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MyCube.addChild(MyBaby);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    Scene scene = Scene("My awesome Game Scene");
 | 
				
			||||||
 | 
					    scene.GetRoot().addChild(MyCube);
 | 
				
			||||||
 | 
					    scene.GetRoot().addChild(MySecondCube);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   // Walk scene graph
 | 
				
			||||||
 | 
					    PrintSceneTree(scene.GetRoot(),0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    shader = new Shader(vertexShaderSource, fragmentShaderSource);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    textureCube = new Texture("build/SandboxApplication/Debug/Textures/wall.jpg");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    matCube = new Material(*shader);
 | 
				
			||||||
 | 
					    matCube->Color = glm::vec3(1.0, 0.0, 0.0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    matCube2 = new Material(*shader);
 | 
				
			||||||
 | 
					    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 
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    Cube = Renderable::Load(lanternPath);
 | 
				
			||||||
 | 
					    Cube2 = Renderable::Load(cubePath);
 | 
				
			||||||
 | 
					    Cube->addChild(*Cube2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* Runs every frame
 | 
				
			||||||
 | 
					* - Use to draw Immediate mode graphics (Not meant for HUD's )
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void ImmediateGraphicsDraw() {
 | 
				
			||||||
 | 
					    ImGui::NewFrame();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Show ImGui demo such that I can easily look
 | 
				
			||||||
 | 
					    // at possible GUI elements to use
 | 
				
			||||||
 | 
					    ImGui::ShowDemoWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Show internal BarinkEngine stats
 | 
				
			||||||
 | 
					    ShowStats();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Show different tooling for this specific sandbox
 | 
				
			||||||
 | 
					    CameraTool(cam);
 | 
				
			||||||
 | 
					    ScriptingTool(code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    transformWindow(Cube->transform, "Transform (Cube)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    transformWindow(Cube2->transform, "Transform (Cube2)");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    materialWindow(*matCube, "Material Cube");
 | 
				
			||||||
 | 
					    materialWindow(*matCube2, "Material Cube2");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* Runs every frame
 | 
				
			||||||
 | 
					* - Meant for game logic ( non-physics related) 
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void Update()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /*
 | 
				
			||||||
 | 
					    * NOTE: this needs to move to the renderer
 | 
				
			||||||
 | 
					    * Render code should not appear in the sandbox file
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					    glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    shader->Use();
 | 
				
			||||||
 | 
					    shader->setUniformMat4("P", projection);
 | 
				
			||||||
 | 
					    shader->setUniformMat4("M", CalculateModelMat(Cube->transform));
 | 
				
			||||||
 | 
					    shader->setUniformMat4("V", cam->GetViewMatrix());
 | 
				
			||||||
 | 
					    matCube->Apply();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Cube->Draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    shader->setUniformMat4("M", CalculateModelMat(Cube2->transform));
 | 
				
			||||||
 | 
					    matCube2->Apply();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Cube2->Draw();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* Runs at the end of the program
 | 
				
			||||||
 | 
					* - Meant for cleanup
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					void Stop() {
 | 
				
			||||||
 | 
					    // Cleanup
 | 
				
			||||||
 | 
					    Cube->VAO.Delete();
 | 
				
			||||||
 | 
					    Cube->elementBuffer.Delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Cube2->VAO.Delete();
 | 
				
			||||||
 | 
					    Cube2->elementBuffer.Delete();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete Cube2;
 | 
				
			||||||
 | 
					    delete Cube;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete matCube;
 | 
				
			||||||
 | 
					    delete matCube2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    delete shader;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,7 +1,6 @@
 | 
				
			|||||||
#include "Util.h"
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					void PrintSceneTree(SceneNode& node, int depth) {
 | 
				
			||||||
* void PrintSceneTree(Node& node, int depth) {
 | 
					 | 
				
			||||||
    // Indent name based on depth
 | 
					    // Indent name based on depth
 | 
				
			||||||
    std::cout << " ";
 | 
					    std::cout << " ";
 | 
				
			||||||
    for (int i = 0; i < depth; i++) {
 | 
					    for (int i = 0; i < depth; i++) {
 | 
				
			||||||
@ -31,5 +30,3 @@ glm::mat4 CalculateModelMat(Transform& transform) {
 | 
				
			|||||||
    return tran * rot * scale;
 | 
					    return tran * rot * scale;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										6
									
								
								SandboxApplication/Util.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								SandboxApplication/Util.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include "BarinkEngine.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void PrintSceneTree(SceneNode& node, int depth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					glm::mat4 CalculateModelMat(Transform& transform);
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								Screenshots/Yoggie.webp
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Screenshots/Yoggie.webp
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Screenshots/YoggieEditor.png
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Screenshots/YoggieEditor.png
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Screenshots/YoggieEditorV0.2.png
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Screenshots/YoggieEditorV0.2.png
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Screenshots/YoggieEditor_workingGuizmo.png
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Screenshots/YoggieEditor_workingGuizmo.png
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user