Reorganising the game engine structure. Getting things ready for real development of the engine
This commit is contained in:
parent
4625ca657b
commit
3446bc2399
34
BarinkEngine/BarinkEngine.cpp
Normal file
34
BarinkEngine/BarinkEngine.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "Include/BarinkEngine.h"
|
||||||
|
|
||||||
|
extern void Start(int argc, char* argv[]);
|
||||||
|
extern void UpdateApplication();
|
||||||
|
|
||||||
|
using namespace BarinkEngine;
|
||||||
|
|
||||||
|
bool ShouldQuit = false;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
|
// Start Engine
|
||||||
|
Engine::Startup();
|
||||||
|
|
||||||
|
Start(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
|
while (!ShouldQuit) {
|
||||||
|
//InputManager::PollEvents();
|
||||||
|
|
||||||
|
UpdateApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Kill Engine
|
||||||
|
Engine::Shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
10
BarinkEngine/Engine.cpp
Normal file
10
BarinkEngine/Engine.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "include/BarinkEngine.h"
|
||||||
|
namespace BarinkEngine {
|
||||||
|
void Engine::Startup() {
|
||||||
|
std::cout << "Starting Engine! vroom vroom!" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Engine::Shutdown() {
|
||||||
|
std::cout << "ShutDown Engine!" << std::endl;
|
||||||
|
}
|
||||||
|
};
|
28
BarinkEngine/Include/BarinkEngine.h
Normal file
28
BarinkEngine/Include/BarinkEngine.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
#include "Engine.h"
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include "../MemoryManager.h"
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
#include <MyGraphicsEngine/Shader.h>
|
||||||
|
#include <MyGraphicsEngine/Window.h>
|
||||||
|
#include <MyGraphicsEngine/Camera.h>
|
||||||
|
#include <MyGraphicsEngine/Renderable.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "lauxlib.h"
|
||||||
|
#include "lua.h"
|
||||||
|
#include "lualib.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
10
BarinkEngine/Include/Engine.h
Normal file
10
BarinkEngine/Include/Engine.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
namespace BarinkEngine {
|
||||||
|
|
||||||
|
static class Engine {
|
||||||
|
public:
|
||||||
|
static void Startup();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
34
BarinkEngine/premake5.lua
Normal file
34
BarinkEngine/premake5.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
project "BarinkEngine"
|
||||||
|
kind "StaticLib"
|
||||||
|
|
||||||
|
buildmessage "Building BarinkEngine"
|
||||||
|
|
||||||
|
includedirs{
|
||||||
|
"./../libs/lua/include",
|
||||||
|
"./libs/spdlog/include",
|
||||||
|
|
||||||
|
"./../libs/glm",
|
||||||
|
"./../MyGraphicsEngine/include",
|
||||||
|
|
||||||
|
"./../libs/GorillaAudio/include"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
libdirs {
|
||||||
|
"./../libs/lua",
|
||||||
|
"./../libs/spdlog/build/Release"
|
||||||
|
}
|
||||||
|
|
||||||
|
links {
|
||||||
|
"lua54",
|
||||||
|
"spdlog",
|
||||||
|
"MyGraphicsEngine"
|
||||||
|
}
|
||||||
|
|
||||||
|
files {
|
||||||
|
"./*.cpp",
|
||||||
|
"./*.h",
|
||||||
|
"./**/*.cpp",
|
||||||
|
"./**/*.h"
|
||||||
|
}
|
||||||
|
|
17
MemoryManager.h
Normal file
17
MemoryManager.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int HeapAllocations = 0;
|
||||||
|
static int HeapDeallocations = 0;
|
||||||
|
|
||||||
|
void* operator new(std::size_t sz) {
|
||||||
|
HeapAllocations++;
|
||||||
|
return std::malloc(sz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator delete(void* ptr) noexcept {
|
||||||
|
HeapDeallocations++;
|
||||||
|
std::free(ptr);
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
#include <MyGraphicsEngine/Buffer.h>
|
#include "include/MyGraphicsEngine/Buffer.h"
|
||||||
|
|
||||||
|
|
||||||
int Buffer::getBufferID() {
|
int Buffer::getBufferID() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <MyGraphicsEngine/Camera.h>
|
#include "include/MyGraphicsEngine/Camera.h"
|
||||||
|
|
||||||
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
|
Camera::Camera(glm::vec3 position, glm::vec3 rotation, float zoom)
|
||||||
: Position(position), Rotation(rotation), Zoom(zoom) {
|
: Position(position), Rotation(rotation), Zoom(zoom) {
|
||||||
|
@ -3,27 +3,27 @@
|
|||||||
|
|
||||||
void ModelImporter::ImportFBX(std::string path)
|
void ModelImporter::ImportFBX(std::string path)
|
||||||
{
|
{
|
||||||
spdlog::warn("ImportFBX not implemented!");
|
//spdlog::warn("ImportFBX not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelImporter::ImportBlend(std::string path)
|
void ModelImporter::ImportBlend(std::string path)
|
||||||
{
|
{
|
||||||
spdlog::warn("ImportBlend not implemented!");
|
//spdlog::warn("ImportBlend not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelImporter::ImportGLTF(std::string path)
|
void ModelImporter::ImportGLTF(std::string path)
|
||||||
{
|
{
|
||||||
spdlog::warn("ImportGLTF not implemented!");
|
//spdlog::warn("ImportGLTF not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelImporter::ImportOBJ(std::string path)
|
void ModelImporter::ImportOBJ(std::string path)
|
||||||
{
|
{
|
||||||
spdlog::warn("ImportOBJ not implemented!");
|
//spdlog::warn("ImportOBJ not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelImporter::Import(std::string path)
|
void ModelImporter::Import(std::string path)
|
||||||
{
|
{
|
||||||
spdlog::warn("Import not implemented!");
|
//spdlog::warn("Import not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<BarinkEngine::Mesh> ModelImporter::Test() {
|
std::vector<BarinkEngine::Mesh> ModelImporter::Test() {
|
||||||
@ -51,7 +51,7 @@ std::vector<BarinkEngine::Mesh> ModelImporter::Test() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
spdlog::info("======= Assimp ======");
|
//spdlog::info("======= Assimp ======");
|
||||||
|
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene* scene = importer.ReadFile("build/SandboxApplication/Debug/Cube.obj", aiProcess_Triangulate | aiProcess_FlipUVs);
|
const aiScene* scene = importer.ReadFile("build/SandboxApplication/Debug/Cube.obj", aiProcess_Triangulate | aiProcess_FlipUVs);
|
||||||
@ -94,7 +94,7 @@ BarinkEngine::Mesh ModelImporter::processMesh(aiMesh* mesh, const aiScene* scene
|
|||||||
vertices.push_back(vector);
|
vertices.push_back(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
spdlog::info("{} == {}", mesh->mNumVertices, vertices.size());
|
//spdlog::info("{} == {}", mesh->mNumVertices, vertices.size());
|
||||||
|
|
||||||
// Process Indices
|
// Process Indices
|
||||||
for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
|
for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
|
||||||
|
@ -1,50 +1,51 @@
|
|||||||
#include "Renderable.h"
|
#include "include/MyGraphicsEngine/Renderable.h"
|
||||||
|
#include "include/AssetManager/ModelImporter.h"
|
||||||
Renderable Renderable::Load()
|
|
||||||
{
|
Renderable Renderable::Load()
|
||||||
return Renderable();
|
{
|
||||||
}
|
return Renderable();
|
||||||
|
}
|
||||||
Renderable::Renderable()
|
|
||||||
{
|
Renderable::Renderable()
|
||||||
|
{
|
||||||
meshes = ModelImporter::Test();
|
|
||||||
|
meshes = ModelImporter::Test();
|
||||||
transform.Scale = glm::vec3(1.0f);
|
|
||||||
transform.Rotation = glm::vec3(0.0f, 90.0f, 0.0f);
|
transform.Scale = glm::vec3(1.0f);
|
||||||
transform.Position = glm::vec3(0.0f, 0.0f, -10.0f);
|
transform.Rotation = glm::vec3(0.0f, 90.0f, 0.0f);
|
||||||
|
transform.Position = glm::vec3(0.0f, 0.0f, -10.0f);
|
||||||
|
|
||||||
VAO.Create();
|
|
||||||
VAO.Bind();
|
VAO.Create();
|
||||||
|
VAO.Bind();
|
||||||
|
|
||||||
vertexBuffer.createBuffer();
|
|
||||||
vertexBuffer.Bind(false);
|
vertexBuffer.createBuffer();
|
||||||
vertexBuffer.setBufferData(&meshes[0].vertices[0], meshes[0].vertices.size() * sizeof(glm::vec3), false);
|
vertexBuffer.Bind(false);
|
||||||
|
vertexBuffer.setBufferData(&meshes[0].vertices[0], meshes[0].vertices.size() * sizeof(glm::vec3), false);
|
||||||
|
|
||||||
elementBuffer.createBuffer();
|
|
||||||
elementBuffer.Bind(true);
|
elementBuffer.createBuffer();
|
||||||
elementBuffer.setBufferData(&meshes[0].elements[0], meshes[0].elements.size() * sizeof(unsigned int), true);
|
elementBuffer.Bind(true);
|
||||||
|
elementBuffer.setBufferData(&meshes[0].elements[0], meshes[0].elements.size() * sizeof(unsigned int), true);
|
||||||
VAO.AttachAttribute(0, 3, 0);
|
|
||||||
|
VAO.AttachAttribute(0, 3, 0);
|
||||||
vertexBuffer.Unbind(false);
|
|
||||||
VAO.Unbind();
|
vertexBuffer.Unbind(false);
|
||||||
|
VAO.Unbind();
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
Renderable::~Renderable()
|
|
||||||
{
|
Renderable::~Renderable()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
void Renderable::Draw()
|
|
||||||
{
|
void Renderable::Draw()
|
||||||
VAO.Bind();
|
{
|
||||||
elementBuffer.Bind(true);
|
VAO.Bind();
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
|
elementBuffer.Bind(true);
|
||||||
VAO.Unbind();
|
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(meshes[0].elements.size()), GL_UNSIGNED_INT, NULL);
|
||||||
|
VAO.Unbind();
|
||||||
}
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
#include "MyGraphicsEngine/Shader.h"
|
#include "include/MyGraphicsEngine/Shader.h"
|
||||||
|
|
||||||
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
|
Shader::Shader(const std::string vertexShaderPath, const std::string fragmentShaderPath)
|
||||||
{
|
{
|
||||||
@ -6,7 +6,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
|||||||
int succes;
|
int succes;
|
||||||
|
|
||||||
char* vertexCode = readFile(vertexShaderPath.c_str());
|
char* vertexCode = readFile(vertexShaderPath.c_str());
|
||||||
spdlog::info(vertexCode);
|
//spdlog::info(vertexCode);
|
||||||
unsigned int vertId = glCreateShader(GL_VERTEX_SHADER);
|
unsigned int vertId = glCreateShader(GL_VERTEX_SHADER);
|
||||||
|
|
||||||
glShaderSource(vertId, 1, &vertexCode, NULL);
|
glShaderSource(vertId, 1, &vertexCode, NULL);
|
||||||
@ -15,13 +15,13 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
|||||||
glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes);
|
glGetShaderiv(vertId, GL_COMPILE_STATUS, &succes);
|
||||||
if(!succes){
|
if(!succes){
|
||||||
glGetShaderInfoLog(vertId, 512, NULL, infoLog);
|
glGetShaderInfoLog(vertId, 512, NULL, infoLog);
|
||||||
spdlog::error( "Vertex shader has compile error {}", infoLog);
|
//spdlog::error( "Vertex shader has compile error {}", infoLog);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* fragmentCode = readFile(fragmentShaderPath.c_str());
|
char* fragmentCode = readFile(fragmentShaderPath.c_str());
|
||||||
spdlog::info(fragmentCode);
|
//spdlog::info(fragmentCode);
|
||||||
unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER);
|
unsigned int fragId = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
|
|||||||
glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes);
|
glGetShaderiv(fragId, GL_COMPILE_STATUS, &succes);
|
||||||
if(!succes){
|
if(!succes){
|
||||||
glGetShaderInfoLog(fragId, 512, NULL, infoLog);
|
glGetShaderInfoLog(fragId, 512, NULL, infoLog);
|
||||||
spdlog::error("Fragment shader has compile error {}", infoLog);
|
//spdlog::error("Fragment shader has compile error {}", infoLog);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ char* Shader::readFile (const char* filePath){
|
|||||||
file.open(filePath);
|
file.open(filePath);
|
||||||
|
|
||||||
if(file.is_open() == false){
|
if(file.is_open() == false){
|
||||||
spdlog::info("File not found.");
|
//spdlog::info("File not found.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ char* Shader::readFile (const char* filePath){
|
|||||||
|
|
||||||
// Undo previous seek.
|
// Undo previous seek.
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
spdlog::info("filesize: {}", filesize);
|
//spdlog::info("filesize: {}", filesize);
|
||||||
|
|
||||||
|
|
||||||
// Create a big enough buffer for the file
|
// Create a big enough buffer for the file
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <MyGraphicsEngine/VertexArray.h>
|
#include "include/MyGraphicsEngine/VertexArray.h"
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
|
|
||||||
void VertexArray::Create(){
|
void VertexArray::Create(){
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
#define TINYGLTF_NO_EXTERNAL_IMAGE
|
||||||
|
|
||||||
#include <MyGraphicsEngine/Mesh.h>
|
#include "../MyGraphicsEngine/Mesh.h"
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class ModelImporter {
|
class ModelImporter {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace BarinkEngine{
|
namespace BarinkEngine{
|
||||||
|
|
||||||
class Mesh {
|
class Mesh {
|
||||||
|
30
MyGraphicsEngine/include/MyGraphicsEngine/Renderable.h
Normal file
30
MyGraphicsEngine/include/MyGraphicsEngine/Renderable.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include "Mesh.h"
|
||||||
|
#include "Transform.h"
|
||||||
|
#include "Buffer.h"
|
||||||
|
#include "VertexArray.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
#include <MyGraphicsEngine/AssetManager/ModelImporter.h>
|
||||||
|
#include <MyGraphicsEngine/MyGraphicsEngine/Buffer.h>
|
||||||
|
#include <MyGraphicsEngine/MyGraphicsEngine/VertexArray.h>
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Renderable {
|
||||||
|
private:
|
||||||
|
std::vector<BarinkEngine::Mesh> meshes;
|
||||||
|
Renderable();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Buffer vertexBuffer;
|
||||||
|
Buffer elementBuffer;
|
||||||
|
VertexArray VAO;
|
||||||
|
Transform transform;
|
||||||
|
~Renderable();
|
||||||
|
|
||||||
|
static Renderable Load();
|
||||||
|
void Draw();
|
||||||
|
|
||||||
|
};
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <glad/glad.h>
|
#include <glad/glad.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <glad/glad.h>
|
|
||||||
#define GLFW_STATIC
|
#define GLFW_STATIC
|
||||||
|
|
||||||
|
#include <glad/glad.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BarinkWindow{
|
class BarinkWindow{
|
||||||
private:
|
private:
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
49
MyGraphicsEngine/premake5.lua
Normal file
49
MyGraphicsEngine/premake5.lua
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
|
||||||
|
project "MyGraphicsEngine"
|
||||||
|
kind "StaticLib"
|
||||||
|
|
||||||
|
buildmessage "Building MyGraphicsEngine ..."
|
||||||
|
|
||||||
|
includedirs {
|
||||||
|
"../libs/assimp/include",
|
||||||
|
"../libs/glad/include",
|
||||||
|
"../libs/glfw/include",
|
||||||
|
"../libs/tinygltf",
|
||||||
|
"../libs/glew/include",
|
||||||
|
"../libs/glm",
|
||||||
|
"../libs/ImGui",
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
libdirs{
|
||||||
|
"../libs/assimp/lib/Debug",
|
||||||
|
"../libs/glfw/build/src/Debug",
|
||||||
|
"../libs/ImGui"
|
||||||
|
}
|
||||||
|
|
||||||
|
links {
|
||||||
|
"assimp-vc143-mtd",
|
||||||
|
"glfw3",
|
||||||
|
}
|
||||||
|
|
||||||
|
files {
|
||||||
|
"../libs/ImGui/*.cpp",
|
||||||
|
"../libs/ImGui/backends/imgui_impl_glfw.cpp",
|
||||||
|
"../libs/ImGui/backends/imgui_impl_Opengl3.cpp",
|
||||||
|
"../libs/glad/src/glad.c",
|
||||||
|
"./*.cpp",
|
||||||
|
"./*.h",
|
||||||
|
"./**/*.cpp",
|
||||||
|
"./**/*.shader",
|
||||||
|
"./**/*.h"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-- NOTE: make these copy instructions more flexible
|
||||||
|
ok, err = os.copyfile("shaders/fragment.shader", "../build/SandboxApplication/Debug/test.fs")
|
||||||
|
if err then error("Copy fragment shader source failed!") end
|
||||||
|
|
||||||
|
ok, err = os.copyfile("shaders/vertex.shader", "../build/SandboxApplication/Debug/test.vs")
|
||||||
|
if err then error("Copy vertex shader source failed!") end
|
@ -1,11 +1,12 @@
|
|||||||
#include "MyGraphicsEngine/Window.h"
|
#include "include/MyGraphicsEngine/Window.h"
|
||||||
#include <spdlog/spdlog.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
bool BarinkWindow::InitGLFW(){
|
bool BarinkWindow::InitGLFW(){
|
||||||
if(!glfwInit())
|
if(!glfwInit())
|
||||||
{
|
{
|
||||||
spdlog::error("Failed to initialise GLFW!");
|
// spdlog::error("Failed to initialise GLFW!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ Width(width), Height(height), FullScreen(false){
|
|||||||
|
|
||||||
if( !window)
|
if( !window)
|
||||||
{
|
{
|
||||||
spdlog::error("GLFW failed to create window!");
|
// spdlog::error("GLFW failed to create window!");
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <vector>
|
|
||||||
#include <spdlog/spdlog.h>
|
|
||||||
#include <MyGraphicsEngine/Mesh.h>
|
|
||||||
#include <MyGraphicsEngine/Transform.h>
|
|
||||||
#include <include/AssetManager/ModelImporter.h>
|
|
||||||
#include <include/MyGraphicsEngine/Buffer.h>
|
|
||||||
#include <include/MyGraphicsEngine/VertexArray.h>
|
|
||||||
class Renderable {
|
|
||||||
private:
|
|
||||||
std::vector<BarinkEngine::Mesh> meshes;
|
|
||||||
Renderable();
|
|
||||||
|
|
||||||
public:
|
|
||||||
Buffer vertexBuffer;
|
|
||||||
Buffer elementBuffer;
|
|
||||||
VertexArray VAO;
|
|
||||||
Transform transform;
|
|
||||||
~Renderable();
|
|
||||||
|
|
||||||
static Renderable Load();
|
|
||||||
void Draw();
|
|
||||||
|
|
||||||
};
|
|
@ -1,30 +1,18 @@
|
|||||||
#include <string>
|
#include <BarinkEngine.h>
|
||||||
|
|
||||||
#include <MyGraphicsEngine/Shader.h>
|
void Start(int argc, char* argv[]) {
|
||||||
#include <MyGraphicsEngine/Window.h>
|
|
||||||
#include <MyGraphicsEngine/Camera.h>
|
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
std::cout << "Hello start!" << std::endl;
|
||||||
|
std::cout << "h" << std::endl;
|
||||||
|
// BarinkWindow GameWindow(800, 600);
|
||||||
|
|
||||||
#include "imgui.h"
|
}
|
||||||
#include "backends/imgui_impl_glfw.h"
|
|
||||||
#include "backends/imgui_impl_opengl3.h"
|
|
||||||
#include "Renderable.h"
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
|
void UpdateApplication()
|
||||||
|
{
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#include "lauxlib.h"
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lualib.h"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include <gorilla/gau.h>
|
|
||||||
#include <gorilla/ga.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
@ -33,8 +21,6 @@ int main(int argc, char* argv[]) {
|
|||||||
getcwd(cwd, 256);
|
getcwd(cwd, 256);
|
||||||
spdlog::info("Working directory: {}", cwd);
|
spdlog::info("Working directory: {}", cwd);
|
||||||
|
|
||||||
|
|
||||||
BarinkWindow GameWindow(800, 600);
|
|
||||||
|
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
@ -61,21 +47,6 @@ int main(int argc, char* argv[]) {
|
|||||||
luaL_dofile(L,"build/SandboxApplication/Debug/script.lua");
|
luaL_dofile(L,"build/SandboxApplication/Debug/script.lua");
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* gau_Manager* mgr;
|
|
||||||
ga_Mixer* mixer;
|
|
||||||
ga_Sound sound;
|
|
||||||
ga_Handle handle;
|
|
||||||
gau_SampleSourceLoop* loopSrc = 0;
|
|
||||||
gau_SampleSourceLoop** pLoopSrc = &loopSrc;
|
|
||||||
gc_int32 loop = 0;
|
|
||||||
gc_int32 quit = 0;
|
|
||||||
|
|
||||||
|
|
||||||
gc_initialize(0);
|
|
||||||
mgr = gau_manager_create();
|
|
||||||
mixer = gau_manager_mixer(mgr);
|
|
||||||
*/
|
|
||||||
|
|
||||||
char* lua_code = new char[255];
|
char* lua_code = new char[255];
|
||||||
memset(lua_code, '\0', 255);
|
memset(lua_code, '\0', 255);
|
||||||
@ -162,3 +133,4 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
109
premake5.lua
109
premake5.lua
@ -1,104 +1,43 @@
|
|||||||
workspace "BarinkEngine"
|
workspace "BarinkEngine"
|
||||||
configurations { "Debug", "Test", "Release" }
|
configurations { "Debug", "Test", "Release" }
|
||||||
|
|
||||||
language "C++"
|
language "C++"
|
||||||
cppdialect "C++17"
|
cppdialect "C++17"
|
||||||
|
|
||||||
targetdir "./build/%{prj.name}/%{cfg.buildcfg}"
|
targetdir "./build/%{prj.name}/%{cfg.buildcfg}"
|
||||||
objdir "./intermediates/%{prj.name}/%{cfg.buildcfg}"
|
objdir "./intermediates/%{prj.name}/%{cfg.buildcfg}"
|
||||||
|
|
||||||
architecture "x86_64"
|
architecture "x86_64"
|
||||||
|
|
||||||
|
|
||||||
|
filter "configurations:Debug"
|
||||||
|
defines {"DEBUG"}
|
||||||
|
symbols "On"
|
||||||
|
|
||||||
|
filter "configurations:Release"
|
||||||
|
defines {"NDEBUG"}
|
||||||
|
optimize "On"
|
||||||
|
|
||||||
|
|
||||||
project "SandboxApplication"
|
project "SandboxApplication"
|
||||||
kind "ConsoleApp"
|
kind "ConsoleApp"
|
||||||
|
|
||||||
buildmessage "Building BarinkEngineSandbox ..."
|
buildmessage "Building Sandbox ..."
|
||||||
|
|
||||||
includedirs {
|
|
||||||
"./libs/assimp/include",
|
|
||||||
"./libs/glad/include",
|
|
||||||
"./MyGraphicsEngine",
|
|
||||||
"./MyGraphicsEngine/include",
|
|
||||||
"./libs/spdlog/include",
|
|
||||||
"./libs/glm",
|
|
||||||
"./libs/GorillaAudio/include",
|
|
||||||
"./libs/lua/include",
|
|
||||||
"./libs/glfw/include",
|
|
||||||
"./libs/ImGui",
|
|
||||||
"./libs/lua/include"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
libdirs{
|
|
||||||
"./libs/spdlog/build/Release",
|
|
||||||
"./libs/glfw/build/src/Debug",
|
|
||||||
"./libs/lua",
|
|
||||||
"./libs/ImGui"
|
|
||||||
}
|
|
||||||
|
|
||||||
links{
|
links{
|
||||||
"lua54",
|
"BarinkEngine"
|
||||||
"spdlog",
|
|
||||||
"glfw3",
|
|
||||||
"MyGraphicsEngine"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
includedirs{
|
||||||
|
"./BarinkEngine/include"
|
||||||
|
}
|
||||||
|
|
||||||
files {
|
files {
|
||||||
"./libs/ImGui/*.cpp",
|
"./SandboxApplication/*.h",
|
||||||
"./libs/ImGui/backends/imgui_impl_glfw.cpp",
|
"./SandboxApplication/*.cpp"
|
||||||
"./libs/ImGui/backends/imgui_impl_Opengl3.cpp",
|
|
||||||
"SandboxApplication/*.cpp"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defines {"DEBUG"}
|
|
||||||
|
|
||||||
symbols "On"
|
include("./BarinkEngine")
|
||||||
|
|
||||||
-- NOTE: make these copy instructions more flexible
|
include("./MyGraphicsEngine")
|
||||||
ok, err = os.copyfile("MyGraphicsEngine/shaders/fragment.shader", "build/SandboxApplication/Debug/test.fs")
|
|
||||||
if err then error("Copy fragment shader source failed!") end
|
|
||||||
|
|
||||||
ok, err = os.copyfile("MyGraphicsEngine/shaders/vertex.shader", "build/SandboxApplication/Debug/test.vs")
|
|
||||||
if err then error("Copy vertex shader source failed!") end
|
|
||||||
|
|
||||||
|
|
||||||
project "MyGraphicsEngine"
|
|
||||||
kind "StaticLib"
|
|
||||||
|
|
||||||
buildmessage "Building MyGraphicsEngine ..."
|
|
||||||
|
|
||||||
includedirs {
|
|
||||||
"./libs/assimp/include",
|
|
||||||
"./libs/glad/include",
|
|
||||||
"./libs/glfw/include",
|
|
||||||
"./libs/tinygltf",
|
|
||||||
"./libs/glew/include",
|
|
||||||
"./libs/spdlog/include",
|
|
||||||
"./libs/glm",
|
|
||||||
"./MyGraphicsEngine/include"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
libdirs{
|
|
||||||
"./libs/spdlog/build/Release",
|
|
||||||
"./libs/assimp/lib/Debug",
|
|
||||||
"./libs/glfw/build/src/Debug"
|
|
||||||
}
|
|
||||||
|
|
||||||
links {
|
|
||||||
"spdlog",
|
|
||||||
"assimp-vc143-mtd",
|
|
||||||
"glfw3"
|
|
||||||
}
|
|
||||||
|
|
||||||
files {
|
|
||||||
"./libs/glad/src/glad.c",
|
|
||||||
"./MyGraphicsEngine/**/*.*" ,
|
|
||||||
"./MyGraphicsEngine/*.*"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
filter "configurations:Debug"
|
|
||||||
defines {"DEBUG"}
|
|
||||||
symbols "On"
|
|
||||||
|
|
||||||
filter "configurations:Release"
|
|
||||||
defines {"NDEBUG"}
|
|
||||||
optimize "On"
|
|
Loading…
Reference in New Issue
Block a user