Update UI code, Fix bugs

This commit is contained in:
MrLetsplay 2022-11-05 13:47:17 +01:00
parent fd71242a42
commit 04df1078b4
4 changed files with 25 additions and 23 deletions

View File

@ -26,11 +26,11 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(KEKENGINE_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/src/kekengine/res")
set(KEKGAME_RESOURCE_DIR "${CMAKE_SOURCE_DIR}/src/kekgame/res")
file(GLOB KEKENGINE_SOURCE_FILES "src/kekengine/cpp/*.cpp")
file(GLOB_RECURSE KEKENGINE_SOURCE_FILES "src/kekengine/cpp/*.cpp")
file(GLOB_RECURSE KEKENGINE_RESOURCE_FILES "${KEKENGINE_RESOURCE_DIR}/*")
file(GLOB_RECURSE KEKENGINE_RELATIVE_RESOURCE_FILES RELATIVE ${KEKENGINE_RESOURCE_DIR} "${KEKENGINE_RESOURCE_DIR}/*")
file(GLOB KEKGAME_SOURCE_FILES "src/kekgame/cpp/*.cpp")
file(GLOB_RECURSE KEKGAME_SOURCE_FILES "src/kekgame/cpp/*.cpp")
file(GLOB_RECURSE KEKGAME_RESOURCE_FILES "${KEKGAME_RESOURCE_DIR}/*")
file(GLOB_RECURSE KEKGAME_RELATIVE_RESOURCE_FILES RELATIVE ${KEKGAME_RESOURCE_DIR} "${KEKGAME_RESOURCE_DIR}/*")

View File

@ -35,17 +35,17 @@ Mesh::Mesh(std::vector<Vertex> vertices, std::vector<uint32_t> indices, Material
glVertexArrayVertexBuffer(vao, KEK_MESH_VERTEX_BUFFER_BINDING, vbo, 0, sizeof(Vertex));
glEnableVertexArrayAttrib(vao, KEK_VERTEX_SHADER_IN_POSITION);
glVertexArrayAttribFormat(vao, KEK_VERTEX_SHADER_IN_POSITION, sizeof(float), GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribBinding(vao, KEK_VERTEX_SHADER_IN_POSITION, KEK_MESH_VERTEX_BUFFER_BINDING);
glEnableVertexArrayAttrib(vao, KEK_MESH_VERTEX_SHADER_IN_POSITION);
glVertexArrayAttribFormat(vao, KEK_MESH_VERTEX_SHADER_IN_POSITION, 3, GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribBinding(vao, KEK_MESH_VERTEX_SHADER_IN_POSITION, KEK_MESH_VERTEX_BUFFER_BINDING);
glEnableVertexArrayAttrib(vao, KEK_VERTEX_SHADER_IN_NORMAL);
glVertexArrayAttribFormat(vao, KEK_VERTEX_SHADER_IN_NORMAL, sizeof(float), GL_FLOAT, GL_FALSE, offsetof(Vertex, normal));
glVertexArrayAttribBinding(vao, KEK_VERTEX_SHADER_IN_NORMAL, KEK_MESH_VERTEX_BUFFER_BINDING);
glEnableVertexArrayAttrib(vao, KEK_MESH_VERTEX_SHADER_IN_NORMAL);
glVertexArrayAttribFormat(vao, KEK_MESH_VERTEX_SHADER_IN_NORMAL, 3, GL_FLOAT, GL_FALSE, offsetof(Vertex, normal));
glVertexArrayAttribBinding(vao, KEK_MESH_VERTEX_SHADER_IN_NORMAL, KEK_MESH_VERTEX_BUFFER_BINDING);
glEnableVertexArrayAttrib(vao, KEK_VERTEX_SHADER_IN_TEXCOORD);
glVertexArrayAttribFormat(vao, KEK_VERTEX_SHADER_IN_TEXCOORD, sizeof(float), GL_FLOAT, GL_FALSE, offsetof(Vertex, texCoords));
glVertexArrayAttribBinding(vao, KEK_VERTEX_SHADER_IN_TEXCOORD, KEK_MESH_VERTEX_BUFFER_BINDING);
glEnableVertexArrayAttrib(vao, KEK_MESH_VERTEX_SHADER_IN_TEXCOORD);
glVertexArrayAttribFormat(vao, KEK_MESH_VERTEX_SHADER_IN_TEXCOORD, 2, GL_FLOAT, GL_FALSE, offsetof(Vertex, texCoords));
glVertexArrayAttribBinding(vao, KEK_MESH_VERTEX_SHADER_IN_TEXCOORD, KEK_MESH_VERTEX_BUFFER_BINDING);
glVertexArrayElementBuffer(vao, ebo);

View File

@ -109,16 +109,16 @@ RectangleElement::RectangleElement(UIValue x, UIValue y, UIValue w, UIValue h):
this->h = h;
color = Colors::BLACK;
glGenVertexArrays(1, &vao);
glGenBuffers(1, &vbo);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(rectangleVerts), rectangleVerts, GL_STATIC_DRAW);
glCreateVertexArrays(1, &vao);
glCreateBuffers(1, &vbo);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
glEnableVertexAttribArray(0);
glNamedBufferData(vbo, sizeof(rectangleVerts), rectangleVerts, GL_STATIC_DRAW);
glBindVertexArray(0);
glVertexArrayVertexBuffer(vao, KEK_UI_VERTEX_BUFFER_BINDING, vbo, 0, 2 * sizeof(float));
glEnableVertexArrayAttrib(vao, KEK_UI_RECT_VERTEX_SHADER_IN_POSITION);
glVertexArrayAttribFormat(vao, KEK_UI_RECT_VERTEX_SHADER_IN_POSITION, 2, GL_FLOAT, GL_FALSE, 0);
glVertexArrayAttribBinding(vao, KEK_UI_RECT_VERTEX_SHADER_IN_POSITION, KEK_UI_VERTEX_BUFFER_BINDING);
}
RectangleElement::~RectangleElement() {

View File

@ -3,12 +3,14 @@
#define KEK_SUCCESS 0
#define KEK_ERROR 1
#define KEK_VERTEX_SHADER_IN_POSITION 0
#define KEK_VERTEX_SHADER_IN_NORMAL 1
#define KEK_VERTEX_SHADER_IN_TEXCOORD 2
#define KEK_MESH_VERTEX_SHADER_IN_POSITION 0
#define KEK_MESH_VERTEX_SHADER_IN_NORMAL 1
#define KEK_MESH_VERTEX_SHADER_IN_TEXCOORD 2
#define KEK_MESH_VERTEX_BUFFER_BINDING 0
#define KEK_UI_RECT_VERTEX_SHADER_IN_POSITION 0
#define KEK_UI_VERTEX_BUFFER_BINDING 0
#define KEK_UNIFORM_LIGHTS_BINDING 0
#define KEK_LIGHT_LIMIT 64 // Also in shader/include/constants.glsl