Added abstracted window

Added Lua interpreter
This commit is contained in:
Nigel Barink 2022-04-28 21:02:54 +02:00
parent 168b936945
commit 86b0506bbb
5 changed files with 46 additions and 15 deletions

View File

@ -1,3 +1,6 @@
{ {
"cmake.configureOnOpen": true "cmake.configureOnOpen": true,
"files.associations": {
"iosfwd": "cpp"
}
} }

View File

@ -16,7 +16,9 @@ class BarinkWindow{
BarinkWindow(const int width, const int height); BarinkWindow(const int width, const int height);
~BarinkWindow(); ~BarinkWindow();
void EnterLoop(); bool WindowShouldClose();
void Poll();
}; };

View File

@ -1,6 +1,7 @@
#include "MyGraphicsEngine/Window.h" #include "MyGraphicsEngine/Window.h"
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
bool BarinkWindow::InitGLFW(){ bool BarinkWindow::InitGLFW(){
if(!glfwInit()) if(!glfwInit())
{ {
@ -31,6 +32,8 @@ Width(width), Height(height), FullScreen(false){
glViewport(0,0, Width, Height); glViewport(0,0, Width, Height);
} }
@ -39,13 +42,12 @@ BarinkWindow::~BarinkWindow(){
glfwTerminate(); glfwTerminate();
} }
void BarinkWindow::EnterLoop(){ bool BarinkWindow::WindowShouldClose(){
while(!glfwWindowShouldClose(window)) return glfwWindowShouldClose(window);
{ }
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window); void BarinkWindow::Poll()
glfwPollEvents(); {
glfwSwapBuffers(window);
} glfwPollEvents();
} }

View File

@ -3,6 +3,15 @@
#include <MyGraphicsEngine/Window.h> #include <MyGraphicsEngine/Window.h>
#include <string> #include <string>
extern "C"
{
#include "lauxlib.h"
#include "lua.h"
#include "lualib.h"
}
int main (int argc, char *argv[] ){ 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 vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; 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();
}
} }

View File

@ -13,17 +13,19 @@ workspace "BarinkEngine"
includedirs { includedirs {
"./libs/glad/include", "./libs/glad/include",
"./MyGraphicsEngine/include" "./MyGraphicsEngine/include",
"./libs/lua-5.4.4/lua"
} }
libdirs{ libdirs{
"./libs/spdlog-1.9.1/build" "./libs/spdlog-1.9.1/build",
"./libs/lua-5.4.4/lua"
} }
links{ links{
"liblua",
"spdlog", "spdlog",
"glfw3", "glfw3",
"X11", "X11",