Compare commits
No commits in common. "23ac663667cd8d0da66360be64cee5f4adc3026b" and "29e715b92abcb7c57ac29482fbdd26c494a4e840" have entirely different histories.
23ac663667
...
29e715b92a
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,11 +1,12 @@
|
||||
**/build/
|
||||
**/intermediates/
|
||||
build/
|
||||
intermediates/
|
||||
tools/
|
||||
*.make
|
||||
Makefile
|
||||
.vscode/
|
||||
libs/lua
|
||||
libs/glad
|
||||
Debug/
|
||||
*.sln
|
||||
*.vcxproj
|
||||
*.vcxproj.filters
|
||||
|
@ -34,7 +34,7 @@ project "BarinkEngine"
|
||||
"assimp-vc143-mtd",
|
||||
"glfw3",
|
||||
|
||||
"ImGui",
|
||||
"ImGUI_Opengl3",
|
||||
}
|
||||
|
||||
|
||||
@ -55,9 +55,26 @@ project "BarinkEngine"
|
||||
"./src/**/*.h"
|
||||
}
|
||||
|
||||
prebuildcommands
|
||||
{
|
||||
ok,err = os.copyfile("BarinkEngine/src/Graphics/shaders/*" ,"SandboxApp/build/Debug/")
|
||||
}
|
||||
|
||||
|
||||
filter { "system:windows"}
|
||||
prebuildcommands {
|
||||
-- Copy shaders
|
||||
"copy src\\graphics\\shaders\\fragment.shader ..\\build\\SandboxApplication\\Debug\\test.fs",
|
||||
"copy src\\graphics\\shaders\\vertex.shader ..\\build\\SandboxApplication\\Debug\\test.vs",
|
||||
"copy src\\graphics\\shaders\\RenderSurfaceFrag.shader ..\\build\\SandboxApplication\\Debug\\RenderSurface.fs",
|
||||
"copy src\\graphics\\shaders\\RenderSurfaceVert.shader ..\\build\\SandboxApplication\\Debug\\RenderSurface.vs"
|
||||
}
|
||||
|
||||
|
||||
|
||||
filter { "system:linux" }
|
||||
prebuildcommands {
|
||||
-- Copy shaders
|
||||
"cp src/graphics/shaders/fragment.shader ../build/SandboxApplication/Debug/test.fs",
|
||||
"cp src/graphics/shaders/vertex.shader ../build/SandboxApplication/Debug/test.vs",
|
||||
"cp src/graphics/shaders/RenderSurfaceFrag.shader ../build/SandboxApplication/Debug/RenderSurface.fs",
|
||||
"cp src/graphics/shaders/RenderSurfaceVert.shader ../build/SandboxApplication/Debug/RenderSurface.vs"
|
||||
}
|
||||
|
||||
include('../ImGui')
|
||||
|
@ -35,7 +35,28 @@ void GUIManager::Render()
|
||||
|
||||
ImGui::NewFrame();
|
||||
|
||||
|
||||
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
|
||||
|
||||
ImGui::Begin("##App");
|
||||
// Show a menu bar
|
||||
ImGui::BeginMainMenuBar();
|
||||
|
||||
if (ImGui::BeginMenu("Application")) {
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Exit")) {
|
||||
// TODO: Exit application
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
|
||||
|
||||
|
||||
ImmediateGraphicsDraw();
|
||||
ImGui::End();
|
||||
|
@ -22,49 +22,6 @@ BarinkEngine::Renderer::~Renderer()
|
||||
// glDeleteBuffers(1, &UV_id);
|
||||
}
|
||||
|
||||
|
||||
void BarinkEngine::Renderer::Render()
|
||||
{
|
||||
Angle += 0.0001f;
|
||||
|
||||
for (auto model : models) {
|
||||
// Push matrices etc ....
|
||||
model->vertexarray.Bind();
|
||||
|
||||
model->elementBuffer.Bind(true);
|
||||
|
||||
if (model->material == nullptr) {
|
||||
std::cout << "No material attached!" << std::endl;
|
||||
// continue; //NOTE: Or use some default Material
|
||||
}
|
||||
else {
|
||||
model->material->shader.Use();
|
||||
model->material->Apply();
|
||||
|
||||
model->material->shader.setUniformVec3("Color", model->material->Color);
|
||||
|
||||
|
||||
model->material->shader.setUniformMat4("M", glm::rotate(glm::mat4(), Angle, glm::vec3(0.5f, 0.5f, 0.0f)));
|
||||
model->material->shader.setUniformMat4("V", cam.GetViewMatrix());
|
||||
model->material->shader.setUniformMat4("P", projection);
|
||||
// Update perf counters
|
||||
ES.verts = model->mesh->vertices.size();
|
||||
ES.DC++;
|
||||
|
||||
glDrawElements(GL_TRIANGLES,
|
||||
static_cast<unsigned int>(model->mesh->elements.size()),
|
||||
GL_UNSIGNED_INT,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
model->vertexarray.Unbind();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BarinkEngine::Renderer::Render(Framebuffer& framebuffer)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.GetId());
|
||||
|
@ -19,8 +19,6 @@ namespace BarinkEngine {
|
||||
Renderer();
|
||||
~Renderer();
|
||||
|
||||
|
||||
void Render();
|
||||
void Render(Framebuffer& framebuffer);
|
||||
|
||||
void Submit(Renderable* model);
|
||||
|
@ -1,138 +0,0 @@
|
||||
#include "../../BarinkEngine/src/BarinkEngine.h"
|
||||
#include "../../BarinkEngine/src/Scene/SceneManager.h"
|
||||
#include "../../BarinkEngine/src/Scene/SceneNodeTypes.h"
|
||||
#include "../../BarinkEngine/src/AssetManager/ModelImporter.h"
|
||||
#include "../../BarinkEngine/src/Graphics/Framebuffer.h"
|
||||
#include <imgui.h>
|
||||
|
||||
/*
|
||||
* Define globals
|
||||
*/
|
||||
Shader* shader;
|
||||
|
||||
char* code = new char[254];
|
||||
|
||||
const std::string vertexShaderSource = "build/Debug/test.vs";
|
||||
const std::string fragmentShaderSource = "build/Debug/test.fs";
|
||||
|
||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
|
||||
Framebuffer* framebuffer;
|
||||
Scene* Level1;
|
||||
BarinkEngine::SceneObject* cube;
|
||||
/*
|
||||
* Runs once at startup
|
||||
* - USe to initialize the game/sandbox/demo
|
||||
*/
|
||||
void Start() {
|
||||
// Build a basic test scene
|
||||
// NOTE: This will later be done through an editor
|
||||
|
||||
// Create a level and load it as the current level
|
||||
std::string levelName("Test Level");
|
||||
Level1 = SceneManager::CreateScene(levelName);
|
||||
SceneManager::LoadScene(*Level1);
|
||||
|
||||
shader = new Shader(vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
// Create a cube node
|
||||
|
||||
cube = MI->Import("build/Debug/Models/cube.obj");
|
||||
cube->renderable->material = new Material(*shader);
|
||||
cube->renderable->material->Color = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
|
||||
// What is in cube now ??
|
||||
std::cout << "mesh vertices: " << cube->renderable->mesh->vertices.size() << std::endl;
|
||||
std::cout << "mesh elements: " << cube->renderable->mesh->elements.size() << std::endl;
|
||||
|
||||
Level1->GetRoot().addChild(*cube);
|
||||
|
||||
memset(code, '\0', 254);
|
||||
framebuffer = new Framebuffer();
|
||||
|
||||
std::cout << "Colour attachment id; " << framebuffer->GetColourAttachment() << std::endl;
|
||||
// TODO: Move to runtime/ Engine
|
||||
// NOTE: Submits should later be done through walking the sceneTree
|
||||
|
||||
renderer.Submit(cube->renderable);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs every frame
|
||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
|
||||
*/
|
||||
void ImmediateGraphicsDraw()
|
||||
{
|
||||
|
||||
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
|
||||
|
||||
// Show a menu bar
|
||||
ImGui::BeginMainMenuBar();
|
||||
|
||||
if (ImGui::BeginMenu("Application")) {
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Exit")) {
|
||||
// TODO: Exit application
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
|
||||
|
||||
// Show internal BarinkEngine stats
|
||||
ShowStats();
|
||||
|
||||
ImGui::Begin("Viewport");
|
||||
ImGui::Image((void*)(intptr_t)framebuffer->GetColourAttachment(), ImVec2{ 800,600 });
|
||||
ImGui::End();
|
||||
|
||||
static float Zoom = 90;
|
||||
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();
|
||||
|
||||
ImGui::Begin("Scripting");
|
||||
ImGui::Text("Lua Code");
|
||||
ImGui::InputTextMultiline("##", code, 255);
|
||||
bool runCode = ImGui::Button("Run");
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Begin("Scene Explorer");
|
||||
ImGui::End();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs every frame
|
||||
* - Meant for game logic ( non-physics related)
|
||||
*/
|
||||
void Update()
|
||||
{
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetId());
|
||||
|
||||
renderer.Render(*framebuffer);
|
||||
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs at the end of the program
|
||||
* - Meant for cleanup
|
||||
*/
|
||||
void Stop()
|
||||
{
|
||||
delete framebuffer;
|
||||
delete MI;
|
||||
delete shader;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
project "ImGui"
|
||||
project "ImGUI_Opengl3"
|
||||
kind "StaticLib"
|
||||
|
||||
includedirs {
|
||||
|
@ -1,39 +0,0 @@
|
||||
project "Runtime"
|
||||
kind "ConsoleApp"
|
||||
|
||||
buildmessage "Building the runtime ..."
|
||||
|
||||
links{
|
||||
"BarinkEngine"
|
||||
}
|
||||
|
||||
includedirs{
|
||||
"./../BarinkEngine/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 {
|
||||
'./../build/BarinkEngine/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{
|
||||
"BarinkEngine"
|
||||
}
|
||||
|
||||
includedirs{
|
||||
"./../BarinkEngine/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",
|
||||
|
||||
|
||||
"./include"
|
||||
|
||||
}
|
||||
|
||||
libdirs {
|
||||
'./../build/BarinkEngine/Debug'
|
||||
}
|
||||
|
||||
files {
|
||||
"./include/*.h",
|
||||
"./src/*.cpp"
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
project "Editor"
|
||||
project "SandboxApplication"
|
||||
kind "ConsoleApp"
|
||||
|
||||
buildmessage "Building editor ..."
|
||||
buildmessage "Building Sandbox ..."
|
||||
|
||||
links{
|
||||
"BarinkEngine"
|
@ -3,7 +3,7 @@
|
||||
#include "../../BarinkEngine/src/Scene/SceneNodeTypes.h"
|
||||
#include "../../BarinkEngine/src/AssetManager/ModelImporter.h"
|
||||
#include "../../BarinkEngine/src/Graphics/Framebuffer.h"
|
||||
#include <imgui.h>
|
||||
#include "imgui.h"
|
||||
#include "GUI.h"
|
||||
#include "Util.h"
|
||||
|
||||
@ -14,10 +14,11 @@ Shader* shader;
|
||||
|
||||
char* code = new char[254];
|
||||
|
||||
const std::string vertexShaderSource = "build/Debug/test.vs";
|
||||
const std::string fragmentShaderSource = "build/Debug/test.fs";
|
||||
const std::string vertexShaderSource = "../build/SandboxApplication/Debug/test.vs";
|
||||
const std::string fragmentShaderSource = "../build/SandboxApplication/Debug/test.fs";
|
||||
|
||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
|
||||
Framebuffer* framebuffer;
|
||||
Scene* Level1;
|
||||
BarinkEngine::SceneObject* cube;
|
||||
/*
|
||||
@ -25,6 +26,8 @@ BarinkEngine::SceneObject* cube;
|
||||
* - USe to initialize the game/sandbox/demo
|
||||
*/
|
||||
void Start() {
|
||||
// Build a basic test scene
|
||||
// NOTE: This will later be done through an editor
|
||||
|
||||
// Create a level and load it as the current level
|
||||
std::string levelName("Test Level");
|
||||
@ -35,7 +38,7 @@ void Start() {
|
||||
|
||||
// Create a cube node
|
||||
|
||||
cube = MI->Import("build/Debug/Models/cube.obj");
|
||||
cube = MI->Import("../build/SandboxApplication/Debug/Models/cube.obj");
|
||||
cube->renderable->material = new Material(*shader);
|
||||
cube->renderable->material->Color = glm::vec3(1.0f, 0.0f, 0.0f);
|
||||
|
||||
@ -46,7 +49,9 @@ void Start() {
|
||||
Level1->GetRoot().addChild(*cube);
|
||||
|
||||
memset(code, '\0', 254);
|
||||
|
||||
framebuffer = new Framebuffer();
|
||||
|
||||
std::cout << "Colour attachment id; "<< framebuffer->GetColourAttachment() << std::endl;
|
||||
// TODO: Move to runtime/ Engine
|
||||
// NOTE: Submits should later be done through walking the sceneTree
|
||||
|
||||
@ -62,6 +67,14 @@ void ImmediateGraphicsDraw()
|
||||
{
|
||||
// Show internal BarinkEngine stats
|
||||
ShowStats();
|
||||
SceneView(*framebuffer);
|
||||
|
||||
// Show different tooling for this specific sandbox
|
||||
CameraTool();
|
||||
ScriptingTool(code);
|
||||
|
||||
SceneExplorer( "Scene Explorer");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -70,9 +83,11 @@ void ImmediateGraphicsDraw()
|
||||
*/
|
||||
void Update()
|
||||
{
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, framebuffer->GetId());
|
||||
|
||||
renderer.Render();
|
||||
renderer.Render(*framebuffer);
|
||||
|
||||
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -81,6 +96,7 @@ void Update()
|
||||
*/
|
||||
void Stop()
|
||||
{
|
||||
delete framebuffer;
|
||||
delete MI;
|
||||
delete shader;
|
||||
}
|
15
premake5.lua
15
premake5.lua
@ -3,12 +3,11 @@ workspace "BarinkEngine"
|
||||
|
||||
language "C++"
|
||||
cppdialect "C++17"
|
||||
architecture "x86_64"
|
||||
|
||||
targetdir "./%{prj.name}/build/%{cfg.buildcfg}"
|
||||
objdir "./%{prj.name}/intermediates/%{cfg.buildcfg}"
|
||||
|
||||
startproject("SandboxApp")
|
||||
targetdir "./build/%{prj.name}/%{cfg.buildcfg}"
|
||||
objdir "./intermediates/%{prj.name}/%{cfg.buildcfg}"
|
||||
|
||||
architecture "x86_64"
|
||||
|
||||
filter "configurations:Debug"
|
||||
defines {"DEBUG"}
|
||||
@ -18,8 +17,6 @@ workspace "BarinkEngine"
|
||||
defines {"NDEBUG"}
|
||||
optimize "On"
|
||||
|
||||
|
||||
include("./SandboxApplication")
|
||||
|
||||
include("./BarinkEngine")
|
||||
include("./Runtime")
|
||||
include ("./Editor")
|
||||
include("./SandboxApp")
|
||||
|
Loading…
Reference in New Issue
Block a user