Commit 7f22e481 authored by Daniel Bross's avatar Daniel Bross 😽
Browse files

Fixed small compilation errors. Added glBufferData with nullptr.

parent 2d685590
No preview for this file type
No preview for this file type
......@@ -4,7 +4,7 @@ EXECUTABLE_NAME=altered
DEBUG=-DDEBUG=1
OPT=-O0
WIGNORE="-Wno-reserved-id-macro -Wno-deprecated -Wno-format-nonliteral -Wno-int-to-void-pointer-cast -Wno-undef -Wno-missing-variable-declarations -Wno-nested-anon-types -Wno-variadic-macros -Wno-old-style-cast -Wno-sign-conversion -Wno-cast-align -Wno-gnu-anonymous-struct -Wno-c++98-compat -Wno-padded -Wdocumentation -Wdocumentation-unknown-command -Wno-double-promotion -Wno-c++98-compat-pedantic -Wno-missing-prototypes -Wno-float-equal -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments -Wno-writable-strings -Wno-global-constructors -Wno-switch-enum -Wno-char-subscripts -Wno-unused-function"
WIGNORE="-Wno-reserved-id-macro -Wno-deprecated -Wno-format-nonliteral -Wno-int-to-void-pointer-cast -Wno-undef -Wno-missing-variable-declarations -Wno-nested-anon-types -Wno-variadic-macros -Wno-old-style-cast -Wno-sign-conversion -Wno-cast-align -Wno-gnu-anonymous-struct -Wno-extra-semi-stmt -Wno-c++98-compat -Wno-padded -Wdocumentation -Wdocumentation-unknown-command -Wno-double-promotion -Wno-c++98-compat-pedantic -Wno-missing-prototypes -Wno-float-equal -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments -Wno-writable-strings -Wno-global-constructors -Wno-switch-enum -Wno-char-subscripts -Wno-unused-function"
CommonCompilerFlags="-pthread -isystem ../libs -isystem ../libs/glfw/include -isystem ../libs/glad/include -isystem ../libs/fmod/include -isystem ../libs/libcurl/include -isystem ../libs/gameanalytics/source/gameanalytics"
CommonLinkerFlags="../libs/glad/osx/glad.o -L/usr/local/lib -L../libs/glfw/osx/ -L../libs/fmod/lib/osx/ -ldl -lc++ -lm -lz -lfmod -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -o $EXECUTABLE_NAME -rpath @executable_path"
......
......@@ -3,7 +3,8 @@
#define VC_EXTRA_LEAN
#endif
#include "assimp_loader.cpp"
//#include "assimp_loader.cpp"
#include "imgui/imgui.h"
#include "shared.h"
......@@ -862,10 +863,10 @@ int main(int argc, char **args)
init_renderer(game, renderer, &reload_queue, &reload_thread, particle_api);
if(import_file("../assets/models/arrow.obj"))
{
printf("Arrow loaded successfuly!\n");
}
// if(import_file("../assets/models/arrow.obj"))
// {
// printf("Arrow loaded successfuly!\n");
// }
scene::SceneManager *scene_manager = scene::create_scene_manager(&platform_state->perm_arena, renderer);
......
......@@ -446,9 +446,10 @@ static void create_instance_buffer(Buffer *buffer, size_t buffer_size, rendering
}
buffer->usage = get_usage(buffer_usage);
buffer->size = buffer_size;
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)buffer_size, nullptr, buffer->usage);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)buffer->size, nullptr, buffer->usage);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -491,6 +492,8 @@ static void update_uniform_buffer(UniformBuffer *buffer, rendering::UniformBuffe
// glBindBuffer(GL_UNIFORM_BUFFER, buffer->ubo);
// @Incomplete: Consider updating with offset as well
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
glBufferSubData(GL_UNIFORM_BUFFER, 0, size, buffer->memory);
}
......@@ -1551,8 +1554,9 @@ static void load_texture(Texture* texture, TextureFiltering filtering, TextureWr
i32 mip = 4;
#if defined(__APPLE__)
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, width, height, 0, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glGenerateMipmap(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_2D);
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, width, height, 0, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glGenerateMipmap(GL_TEXTURE_2D);
#else
......@@ -1797,7 +1801,7 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL_TRUE);
//glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL_TRUE);
#endif
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
......@@ -2402,6 +2406,7 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
Buffer *buffer = renderer->render.instancing.internal_float_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
if(renderer->render.instancing.dirty_float_buffers[handle])
{
......@@ -2423,7 +2428,8 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
Buffer *buffer = renderer->render.instancing.internal_float2_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
if(renderer->render.instancing.dirty_float2_buffers[handle])
{
......@@ -2445,7 +2451,8 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
Buffer *buffer = renderer->render.instancing.internal_float3_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
if(renderer->render.instancing.dirty_float3_buffers[handle])
{
......@@ -2468,7 +2475,8 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
Buffer *buffer = renderer->render.instancing.internal_float4_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
if(renderer->render.instancing.dirty_float4_buffers[handle])
{
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(size * count), buf_ptr);
......@@ -2490,28 +2498,29 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
Buffer *buffer = renderer->render.instancing.internal_mat4_buffers[handle];
GLsizei vec4_size = sizeof(math::Vec4);
glEnableVertexAttribArray(array_num);
glEnableVertexAttribArray(array_num + 1);
glEnableVertexAttribArray(array_num + 2);
glEnableVertexAttribArray(array_num + 3);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glEnableVertexAttribArray(array_num);
glEnableVertexAttribArray(array_num + 1);
glEnableVertexAttribArray(array_num + 2);
glEnableVertexAttribArray(array_num + 3);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBufferData(GL_ARRAY_BUFFER, buffer->size, NULL, GL_DYNAMIC_DRAW);
if(renderer->render.instancing.dirty_mat4_buffers[handle])
{
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(size * count), &((math::Mat4*)buf_ptr)[0]);
renderer->render.instancing.dirty_mat4_buffers[handle] = false;
}
glVertexAttribPointer(array_num, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)0);
glVertexAttribPointer(array_num + 1, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(vec4_size));
glVertexAttribPointer(array_num + 2, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(2 * vec4_size));
glVertexAttribPointer(array_num + 3, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(3 * vec4_size));
glVertexAttribPointer(array_num, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)0);
glVertexAttribPointer(array_num + 1, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(vec4_size));
glVertexAttribPointer(array_num + 2, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(2 * vec4_size));
glVertexAttribPointer(array_num + 3, 4, GL_FLOAT, GL_FALSE, 4 * vec4_size, (void *)(3 * vec4_size));
glVertexAttribDivisor(array_num, 1);
glVertexAttribDivisor(array_num + 1, 1);
glVertexAttribDivisor(array_num + 2, 1);
glVertexAttribDivisor(array_num + 3, 1);
glVertexAttribDivisor(array_num, 1);
glVertexAttribDivisor(array_num + 1, 1);
glVertexAttribDivisor(array_num + 2, 1);
glVertexAttribDivisor(array_num + 3, 1);
}
break;
case rendering::ValueType::INTEGER:
......
......@@ -57,6 +57,8 @@ struct Buffer
GLint vertex_count;
GLint index_buffer_size;
GLint index_buffer_count;
size_t size;
GLenum usage;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment