Basic rectangle drawing

This commit is contained in:
2022-04-30 20:20:07 +02:00
parent ddf7e14682
commit f547ff1b8f
8 changed files with 93 additions and 40 deletions

View File

@ -10,36 +10,74 @@ extern "C"
#include "lualib.h"
}
float 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
};
unsigned int indices[] = {
0,1,3,
1,2,3
};
int main (int argc, char *argv[] ){
BarinkWindow GameWindow(800, 600);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)){
printf("Failed to initialize GLAD!\n");
return -1;
}
std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
//Shader shader (vertexShaderSource, fragmentShaderSource);
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");
luaL_dofile(L,"./script.lua");
unsigned int VBO, VAO, EBO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glGenBuffers(1, &EBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
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) ;
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);
}

View File

@ -0,0 +1 @@
print("Hello world!")