Improved shader definition loader
This commit is contained in:
@ -1,29 +1,36 @@
|
||||
#include <glad/glad.h>
|
||||
#include <MyGraphicsEngine/Shader.h>
|
||||
#include <MyGraphicsEngine/Window.h>
|
||||
#include <MyGraphicsEngine/Mesh.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
extern "C"
|
||||
/*
|
||||
* extern "C"
|
||||
{
|
||||
#include "lauxlib.h"
|
||||
#include "lua.h"
|
||||
#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[] ){
|
||||
|
||||
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";
|
||||
@ -32,10 +39,15 @@ int main (int argc, char *argv[] ){
|
||||
|
||||
spdlog::info("Working directory: {}", argv[0]);
|
||||
|
||||
lua_State* L = luaL_newstate();
|
||||
/*
|
||||
* lua_State* L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
luaL_dostring(L, "print('BarinkEngine')");
|
||||
luaL_dofile(L,"./script.lua");
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int VBO, VAO, EBO;
|
||||
|
||||
@ -43,14 +55,14 @@ int main (int argc, char *argv[] ){
|
||||
glGenBuffers(1, &VBO);
|
||||
glGenBuffers(1, &EBO);
|
||||
|
||||
|
||||
spdlog::info("Vertices: {}", mesh.vertices.size());
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
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(indices), indices, GL_STATIC_DRAW);
|
||||
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);
|
||||
|
Reference in New Issue
Block a user