#include #include #include #include #include /* * extern "C" { #include "lauxlib.h" #include "lua.h" #include "lualib.h" } */ int main (int argc, char *argv[] ){ Mesh mesh; mesh.vertices = { 0.5f, 0.5f, 0.0f, // top, right 0.5f, -0.5f, 0.0f, // bottom right -0.5f, -0.5f, 0.0f, // bottom left -0.5f, 0.5f, 0.0f // top left }; mesh.elements = { 0,1,3, 1,2,3 }; BarinkWindow GameWindow(800, 600); std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; Shader shader (vertexShaderSource, fragmentShaderSource); spdlog::info("Working directory: {}", argv[0]); /* * lua_State* L = luaL_newstate(); luaL_openlibs(L); luaL_dostring(L, "print('BarinkEngine')"); luaL_dofile(L,"./script.lua"); */ unsigned int VBO, VAO, EBO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); spdlog::info("Vertices: {}", mesh.vertices.size()); glBindVertexArray(VAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * mesh.vertices.size() , &mesh.vertices[0], GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int) * mesh.elements.size(), &mesh.elements[0], GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); while (!GameWindow.WindowShouldClose()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT) ; shader.Use(); glBindVertexArray(VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glBindVertexArray(0); GameWindow.Poll(); } glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &EBO); }