From 86b0506bbbdecc11ab9830f2bdc30536991d7a2b Mon Sep 17 00:00:00 2001 From: Nigel Date: Thu, 28 Apr 2022 21:02:54 +0200 Subject: [PATCH] Added abstracted window Added Lua interpreter --- .vscode/settings.json | 5 +++- .../include/MyGraphicsEngine/Window.h | 4 ++- MyGraphicsEngine/window.cpp | 18 +++++++------ SandboxApplication/Sandbox.cpp | 26 +++++++++++++++++-- premake5.lua | 8 +++--- 5 files changed, 46 insertions(+), 15 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 0db5873..d23f8a5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "cmake.configureOnOpen": true + "cmake.configureOnOpen": true, + "files.associations": { + "iosfwd": "cpp" + } } \ No newline at end of file diff --git a/MyGraphicsEngine/include/MyGraphicsEngine/Window.h b/MyGraphicsEngine/include/MyGraphicsEngine/Window.h index 60d3f06..b84a197 100644 --- a/MyGraphicsEngine/include/MyGraphicsEngine/Window.h +++ b/MyGraphicsEngine/include/MyGraphicsEngine/Window.h @@ -16,7 +16,9 @@ class BarinkWindow{ BarinkWindow(const int width, const int height); ~BarinkWindow(); - void EnterLoop(); + bool WindowShouldClose(); + + void Poll(); }; \ No newline at end of file diff --git a/MyGraphicsEngine/window.cpp b/MyGraphicsEngine/window.cpp index 4f695f9..3174696 100644 --- a/MyGraphicsEngine/window.cpp +++ b/MyGraphicsEngine/window.cpp @@ -1,6 +1,7 @@ #include "MyGraphicsEngine/Window.h" #include + bool BarinkWindow::InitGLFW(){ if(!glfwInit()) { @@ -31,6 +32,8 @@ Width(width), Height(height), FullScreen(false){ glViewport(0,0, Width, Height); + + } @@ -39,13 +42,12 @@ BarinkWindow::~BarinkWindow(){ glfwTerminate(); } -void BarinkWindow::EnterLoop(){ - while(!glfwWindowShouldClose(window)) - { - glClear(GL_COLOR_BUFFER_BIT); +bool BarinkWindow::WindowShouldClose(){ + return glfwWindowShouldClose(window); +} - glfwSwapBuffers(window); - glfwPollEvents(); - - } +void BarinkWindow::Poll() +{ + glfwSwapBuffers(window); + glfwPollEvents(); } \ No newline at end of file diff --git a/SandboxApplication/Sandbox.cpp b/SandboxApplication/Sandbox.cpp index 860d894..8d3c313 100644 --- a/SandboxApplication/Sandbox.cpp +++ b/SandboxApplication/Sandbox.cpp @@ -3,6 +3,15 @@ #include #include +extern "C" + { + #include "lauxlib.h" + #include "lua.h" + #include "lualib.h" +} + + + int main (int argc, char *argv[] ){ @@ -15,9 +24,22 @@ int main (int argc, char *argv[] ){ } std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; - Shader(vertexShaderSource, fragmentShaderSource); + //Shader shader (vertexShaderSource, fragmentShaderSource); + + lua_State* L = luaL_newstate(); + luaL_openlibs(L); + luaL_dostring(L, "print('BarinkEngine')"); + luaL_dofile(L,"script.lua"); + + glClearColor(0.2f, 0.2f, 0.2f, 1.0f); + + + + while (!GameWindow.WindowShouldClose()) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) ; - GameWindow.EnterLoop(); + GameWindow.Poll(); + } } diff --git a/premake5.lua b/premake5.lua index 1ce0a01..957a0b3 100644 --- a/premake5.lua +++ b/premake5.lua @@ -13,17 +13,19 @@ workspace "BarinkEngine" includedirs { "./libs/glad/include", - "./MyGraphicsEngine/include" + "./MyGraphicsEngine/include", + "./libs/lua-5.4.4/lua" } libdirs{ - "./libs/spdlog-1.9.1/build" - + "./libs/spdlog-1.9.1/build", + "./libs/lua-5.4.4/lua" } links{ + "liblua", "spdlog", "glfw3", "X11",