Commit 6d2f910a authored by Niels Bross's avatar Niels Bross
Browse files

Merge branch 'develop' of gitlab.com:glitchheart/glitchheartengine into develop

parents 7508c25e 3b167e97
......@@ -12,155 +12,160 @@ struct Camera
CameraMode mode;
r32 zoom;
math::Vec3 position;
math::Vec3 target;
math::Vec3 forward;
math::Vec3 right;
math::Vec3 up;
math::Vec3 pos;
math::Mat4 view_matrix;
math::Mat4 projection_matrix;
r32 yaw;
r32 pitch;
r32 near_plane;
r32 far_plane;
r32 fov;
};
static Camera create_camera(math::Vec3 position, math::Vec3 target, math::Mat4 projection_matrix)
static Camera create_camera(math::Vec3 forward, math::Mat4 view_matrix, math::Mat4 projection_matrix)
{
Camera camera;
camera.mode = CameraMode::FREE_ROAM;
camera.position = position;
camera.target = target;
camera.forward = math::normalize(target - position);
camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward));
camera.up = math::normalize(math::cross(camera.forward, camera.right));
camera.forward = math::Vec3(0, 0, 1);
camera.right = math::Vec3(1, 0, 0);
camera.up = math::Vec3(0, 1, 0);
camera.yaw = (r32)atan2(camera.forward.x, camera.forward.z) / DEGREE_IN_RADIANS;
camera.pitch = (r32)asin(camera.forward.y) / DEGREE_IN_RADIANS;
camera.view_matrix = math::look_at(camera.forward, camera.position);
camera.view_matrix = view_matrix;
camera.projection_matrix = projection_matrix;
return(camera);
}
static void translate_forward(Camera &camera, r32 amount)
{
r32 dist = math::distance(camera.target, camera.position);
camera.position += camera.forward * amount;
camera.view_matrix = math::look_at(camera.forward, camera.position);
camera.target = camera.position + camera.forward * dist;
}
static void translate_up(Camera &camera, r32 amount)
{
r32 dist = math::distance(camera.target, camera.position);
camera.position += camera.up * amount;
camera.view_matrix = math::look_at(camera.forward, camera.position);
camera.target = camera.position + camera.forward * dist;
}
static void translate_right(Camera &camera, r32 amount)
static Camera create_camera(math::Vec3 position, math::Vec3 target, math::Mat4 projection_matrix)
{
r32 dist = math::distance(camera.target, camera.position);
camera.position += camera.right * amount;
camera.view_matrix = math::look_at(camera.forward, camera.position);
camera.target = camera.position + camera.forward * dist;
Camera camera;
return(camera);
}
static void update_rotation(Camera &camera)
{
r32 pitch = camera.pitch * DEGREE_IN_RADIANS;
r32 yaw = camera.yaw * DEGREE_IN_RADIANS;
r32 dist = math::distance(camera.target, camera.position);
camera.forward.x = math::cos(pitch) * math::sin(yaw);
camera.forward.y = math::sin(pitch);
camera.forward.z = math::cos(pitch) * math::cos(yaw);
camera.forward = math::normalize(camera.forward);
/* static void translate_forward(Camera &camera, r32 amount) */
/* { */
/* r32 dist = math::distance(camera.target, camera.position); */
/* camera.position += camera.forward * amount; */
/* camera.view_matrix = math::look_at(camera.forward, camera.position); */
/* camera.target = camera.position + camera.forward * dist; */
/* } */
/* static void translate_up(Camera &camera, r32 amount) */
/* { */
/* r32 dist = math::distance(camera.target, camera.position); */
/* camera.position += camera.up * amount; */
/* camera.view_matrix = math::look_at(camera.forward, camera.position); */
/* camera.target = camera.position + camera.forward * dist; */
/* } */
/* static void translate_right(Camera &camera, r32 amount) */
/* { */
/* r32 dist = math::distance(camera.target, camera.position); */
/* camera.position += camera.right * amount; */
/* camera.view_matrix = math::look_at(camera.forward, camera.position); */
/* camera.target = camera.position + camera.forward * dist; */
/* } */
/* static void update_rotation(Camera &camera) */
/* { */
/* r32 pitch = camera.pitch * DEGREE_IN_RADIANS; */
/* r32 yaw = camera.yaw * DEGREE_IN_RADIANS; */
/* r32 dist = math::distance(camera.target, camera.position); */
/* camera.forward.x = math::cos(pitch) * math::sin(yaw); */
/* camera.forward.y = math::sin(pitch); */
/* camera.forward.z = math::cos(pitch) * math::cos(yaw); */
/* camera.forward = math::normalize(camera.forward); */
camera.target = camera.position + camera.forward * dist;
/* camera.target = camera.position + camera.forward * dist; */
camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward));
camera.up = math::normalize(math::cross(camera.forward, camera.right));
/* camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward)); */
/* camera.up = math::normalize(math::cross(camera.forward, camera.right)); */
camera.view_matrix = math::look_at(camera.forward, camera.position);
}
/* camera.view_matrix = math::look_at(camera.forward, camera.position); */
/* } */
static void update_arcball_rotation(Camera &camera, r32 pitch_amount, r32 yaw_amount)
{
r32 pitch = pitch_amount * DEGREE_IN_RADIANS;
r32 yaw = yaw_amount * DEGREE_IN_RADIANS;
/* static void update_arcball_rotation(Camera &camera, r32 pitch_amount, r32 yaw_amount) */
/* { */
/* assert(false); */
/* /\* r32 pitch = pitch_amount * DEGREE_IN_RADIANS; *\/ */
/* /\* r32 yaw = yaw_amount * DEGREE_IN_RADIANS; *\/ */
math::Vec3 camera_focus_vector = camera.position - camera.target;
/* /\* math::Vec3 camera_focus_vector = camera.position - camera.target; *\/ */
math::Quat orientation = math::Quat();
orientation = math::rotate(orientation, pitch, camera.right);
orientation = math::rotate(orientation, yaw, math::Vec3(0.0f, 1.0f, 0.0f));
camera.position = to_matrix(orientation) * camera_focus_vector + camera.target;
/* /\* math::Quat orientation = math::Quat(); *\/ */
/* /\* orientation = math::rotate(orientation, pitch, camera.right); *\/ */
/* /\* orientation = math::rotate(orientation, yaw, math::Vec3(0.0f, 1.0f, 0.0f)); *\/ */
/* /\* camera.position = to_matrix(orientation) * camera_focus_vector + camera.target; *\/ */
camera.forward = math::normalize(camera.target - camera.position);
camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward));
camera.up = math::normalize(math::cross(camera.forward, camera.right));
/* /\* camera.forward = math::normalize(camera.target - camera.position); *\/ */
/* /\* camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward)); *\/ */
/* /\* camera.up = math::normalize(math::cross(camera.forward, camera.right)); *\/ */
camera.view_matrix = math::look_at(camera.forward, camera.position);
}
/* /\* camera.view_matrix = math::look_at(camera.forward, camera.position); *\/ */
/* } */
static void rotate_around_x(Camera &camera, r32 amount)
{
camera.pitch += amount;
/* static void rotate_around_x(Camera &camera, r32 amount) */
/* { */
/* camera.pitch += amount; */
if(camera.pitch > 89.0f)
camera.pitch = 89.0f;
if(camera.pitch < -89.0f)
camera.pitch = -89.0f;
if(camera.mode == CameraMode::FREE_ROAM)
update_rotation(camera);
else
update_arcball_rotation(camera, amount * 10.0f, 0.0f);
}
static void invert_pitch(Camera &camera)
{
camera.pitch = -camera.pitch;
update_rotation(camera);
}
static void rotate_around_y(Camera &camera, r32 amount)
{
camera.yaw += amount;
if(camera.mode == CameraMode::FREE_ROAM)
update_rotation(camera);
else
update_arcball_rotation(camera, 0.0f, -amount * 10.0f);
}
static void center(Camera &camera)
{
camera.mode = CameraMode::CENTERED;
}
static void set_target(Camera &camera, math::Vec3 target)
{
camera.target = target;
/* if(camera.pitch > 89.0f) */
/* camera.pitch = 89.0f; */
/* if(camera.pitch < -89.0f) */
/* camera.pitch = -89.0f; */
/* if(camera.mode == CameraMode::FREE_ROAM) */
/* update_rotation(camera); */
/* else */
/* update_arcball_rotation(camera, amount * 10.0f, 0.0f); */
/* } */
/* static void invert_pitch(Camera &camera) */
/* { */
/* camera.pitch = -camera.pitch; */
/* update_rotation(camera); */
/* } */
/* static void rotate_around_y(Camera &camera, r32 amount) */
/* { */
/* camera.yaw += amount; */
/* if(camera.mode == CameraMode::FREE_ROAM) */
/* update_rotation(camera); */
/* else */
/* update_arcball_rotation(camera, 0.0f, -amount * 10.0f); */
/* } */
/* static void center(Camera &camera) */
/* { */
/* camera.mode = CameraMode::CENTERED; */
/* } */
/* static void set_target(Camera &camera, math::Vec3 target) */
/* { */
/* camera.target = target; */
camera.forward = math::normalize(camera.target - camera.position);
camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward));
camera.up = math::normalize(math::cross(camera.forward, camera.right));
/* camera.forward = math::normalize(camera.target - camera.position); */
/* camera.right = math::normalize(math::cross(math::Vec3(0, 1, 0), camera.forward)); */
/* camera.up = math::normalize(math::cross(camera.forward, camera.right)); */
camera.yaw = (r32)atan2(camera.forward.x, camera.forward.z) / DEGREE_IN_RADIANS;
camera.pitch = (r32)asin(camera.forward.y) / DEGREE_IN_RADIANS;
/* camera.yaw = (r32)atan2(camera.forward.x, camera.forward.z) / DEGREE_IN_RADIANS; */
/* camera.pitch = (r32)asin(camera.forward.y) / DEGREE_IN_RADIANS; */
camera.view_matrix = math::look_at(camera.forward, camera.position);
}
/* camera.view_matrix = math::look_at(camera.forward, camera.position); */
/* } */
static void free_roam(Camera &camera)
{
camera.mode = CameraMode::FREE_ROAM;
}
/* static void free_roam(Camera &camera) */
/* { */
/* camera.mode = CameraMode::FREE_ROAM; */
/* } */
#endif
This diff is collapsed.
......@@ -16,6 +16,8 @@ namespace editor
BUILT_IN,
CUSTOM
};
typedef void (*OnCustomMainMenu)();
struct EditorState
{
......@@ -27,6 +29,7 @@ namespace editor
b32 show_inspector;
b32 show_resources;
b32 show_scene_settings;
b32 show_stats;
struct
{
......@@ -34,14 +37,21 @@ namespace editor
} scene_settings;
} windows;
struct
{
OnCustomMainMenu on_custom_main_menu_bar;
} callbacks;
};
// Internal functions
static void _init(EditorState *editor_state);
static void _recursive_entity_item(scene::Entity& entity, scene::SceneManager *scene_manager, r64 delta_time);
static void _render_hierarchy(r64 delta_time);
static void _render_inspector(r64 delta_time);
static void _render_resources(project::ProjectState *project_state, scene::SceneManager *scene_manager, r64 delta_time);
static void _render_hierarchy(scene::Scene &scene, EditorState *editor_state, InputController *input_controller, r64 delta_time);
static void _render_inspector(scene::Scene &scene, EditorState *editor_state, InputController *input_controller, r64 delta_time);
static void _render_resources(project::ProjectState *project_state, EditorState *editor_state, scene::SceneManager *scene_manager, r64 delta_time);
static void _render_stats(EditorState *editor_state, scene::SceneManager *scene_manager, InputController *input_controller, sound::SoundSystem *sound_system, r64 delta_time);
static void set_editor_mode(EditorMode mode, EditorState *state);
}
......
......@@ -545,6 +545,11 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
rendering::ShaderHandle blur_shader = renderer->render.blur_shader;
rendering::ShaderHandle bloom_shader = renderer->render.bloom_shader;
// Create opaque and transparent passes
// Set same framebuffer
// If in editor blit into texture and render into scene view
// If in game-mode blit to final framebuffer
// Create the framebuffers
rendering::FramebufferInfo standard_resolve_info = rendering::generate_framebuffer_info();
standard_resolve_info.width = renderer->framebuffer_width;
......@@ -566,6 +571,7 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, standard_info, 8);
rendering::FramebufferHandle standard_framebuffer = rendering::create_framebuffer(standard_info, renderer);
rendering::RenderPassHandle standard = rendering::create_render_pass(STANDARD_PASS, standard_framebuffer, renderer);
renderer->render.standard_pass = standard;
......@@ -595,8 +601,8 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
final_info.width = renderer->framebuffer_width;
final_info.height = renderer->framebuffer_height;
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, final_info, 8);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_TEXTURE | rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, final_info, 8);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, final_info);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_TEXTURE, final_info);
rendering::FramebufferHandle final_framebuffer = rendering::create_framebuffer(final_info, renderer);
rendering::set_final_framebuffer(renderer, final_framebuffer);
......@@ -1050,6 +1056,7 @@ int main(int argc, char **args)
#ifdef EDITOR
editor::EditorState editor_state = {};
editor::_init(&editor_state);
core.editor_state = &editor_state;
#endif
......@@ -1085,34 +1092,41 @@ int main(int argc, char **args)
if(scene_manager->scene_loaded)
{
scene::Scene &current_scene = scene::get_scene(scene_manager->loaded_scene);
#ifdef EDITOR
if(scene_manager->mode == scene::SceneMode::RUNNING)
{
editor::_render_stats(&editor_state, scene_manager, &input_controller, &sound_system, delta_time);
game.update(&game_memory);
}
else
{
game.update_editor(&game_memory);
scene::Scene &current_scene = scene::get_scene(scene_manager->loaded_scene);
editor::_render_main_menu(&editor_state, scene_manager, &input_controller, delta_time);
if(editor_state.mode == editor::EditorMode::BUILT_IN)
{
editor::_render_hierarchy(current_scene, delta_time);
editor::_render_inspector(current_scene, &input_controller, delta_time);
editor::_render_resources(project_state, scene_manager, delta_time);
editor::_render_hierarchy(current_scene, &editor_state, &input_controller, delta_time);
editor::_render_inspector(current_scene, &editor_state, &input_controller, delta_time);
editor::_render_resources(project_state, &editor_state, scene_manager, delta_time);
editor::_render_scene_settings(&editor_state, scene_manager, delta_time);
editor::_render_stats(&editor_state, scene_manager, &input_controller, &sound_system, delta_time);
}
}
#else
game.update(&game_memory);
#endif
if(scene_manager->scene_loaded) // Check again, since there could be a call to unload_current_scene() in game.update()
{
#ifdef EDITOR
#ifdef EDITOR
update_scene_editor(scene_manager->loaded_scene, &input_controller, render_state, delta_time);
#endif
#endif
scene::Scene &scene = scene::get_scene(scene_manager->loaded_scene);
scene::update_animators(scene, renderer, delta_time);
scene::push_scene_for_rendering(scene, renderer);
......@@ -1123,7 +1137,6 @@ int main(int argc, char **args)
update_particle_systems(renderer, delta_time);
//tick_animation_controllers(renderer, &sound_system, &input_controller, timer_controller, delta_time);
tick_timers(timer_controller, delta_time);
if(sound_system.update)
......
......@@ -629,7 +629,7 @@ static void create_framebuffer_color_attachment(RenderState &render_state, Rende
}
else
{
glRenderbufferStorageMultisample(GL_RENDERBUFFER, attachment.samples, GL_RGBA, width, height);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, attachment.samples, GL_RGB, width, height);
}
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_RENDERBUFFER,
......@@ -685,8 +685,7 @@ static void create_framebuffer_color_attachment(RenderState &render_state, Rende
}
else
{
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, attachment.samples, GL_RGBA, width, height, GL_TRUE);
//glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, attachment.samples, GL_RGB, width, height, GL_TRUE);
}
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D_MULTISAMPLE, texture->handle, NULL);
......@@ -1564,12 +1563,12 @@ static void load_texture(Texture* texture, TextureFiltering filtering, TextureWr
glTexStorage2D(GL_TEXTURE_2D, mip, gl_format, width, height);
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->width, texture->height, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, width, height, 0, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, texture->width, texture->height, 0, img_format, GL_UNSIGNED_BYTE, (GLvoid*)image_data);
glGenerateMipmap(GL_TEXTURE_2D);
}
......@@ -1804,7 +1803,6 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 8);
render_state.contrast = contrast;
render_state.brightness = brightness;
......@@ -1849,6 +1847,7 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
//glfwSetInputMode(render_state.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
glfwSetFramebufferSizeCallback(render_state.window, frame_buffer_size_callback);
glfwSetWindowIconifyCallback(render_state.window, window_iconify_callback);
......@@ -1877,7 +1876,9 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
glDebugMessageCallback((GLDEBUGPROC)message_callback, 0);
#endif
glDisable(GL_DITHER);
glDisable(GL_CULL_FACE);
glEnable( GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
......@@ -2362,7 +2363,7 @@ static void set_uniform(rendering::Transform transform, const rendering::RenderP
break;
case rendering::UniformMappingType::CAMERA_POSITION:
{
set_vec3_uniform(gl_shader.program, location, camera.position);
set_vec3_uniform(gl_shader.program, location, camera.pos);
}
break;
case rendering::UniformMappingType::DISSOLVE:
......@@ -2399,15 +2400,15 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
count = renderer->render.instancing.float_buffer_counts[handle];
Buffer *buffer = renderer->render.instancing.internal_float_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
if(renderer->render.instancing.dirty_float_buffers[handle])
{
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(size * count), buf_ptr);
renderer->render.instancing.dirty_float_buffers[handle] = false;
}
glEnableVertexAttribArray(array_num);
glVertexAttribPointer(array_num, num_values, GL_FLOAT, GL_FALSE, (GLsizei)size, (void *)nullptr);
glVertexAttribDivisor(array_num, 1);
......@@ -2421,18 +2422,18 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
count = renderer->render.instancing.float2_buffer_counts[handle];
Buffer *buffer = renderer->render.instancing.internal_float2_buffers[handle];
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
if(renderer->render.instancing.dirty_float2_buffers[handle])
{
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(size * count), buf_ptr);
renderer->render.instancing.dirty_float2_buffers[handle] = false;
}
glEnableVertexAttribArray(array_num);
glVertexAttribPointer(array_num, num_values, GL_FLOAT, GL_FALSE, (GLsizei)size, (void *)nullptr);
glVertexAttribDivisor(array_num, 1);
glEnableVertexAttribArray(array_num);
glVertexAttribPointer(array_num, num_values, GL_FLOAT, GL_FALSE, (GLsizei)size, (void *)nullptr);
glVertexAttribDivisor(array_num, 1);
}
break;
case rendering::ValueType::FLOAT3:
......@@ -2444,17 +2445,17 @@ 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);
if(renderer->render.instancing.dirty_float3_buffers[handle])
{
glBufferSubData(GL_ARRAY_BUFFER, 0, (GLsizeiptr)(size * count), buf_ptr);
renderer->render.instancing.dirty_float3_buffers[handle] = false;
}
glEnableVertexAttribArray(array_num);
glVertexAttribPointer(array_num, num_values, GL_FLOAT, GL_FALSE, (GLsizei)size, (void *)nullptr);
glVertexAttribDivisor(array_num, 1);
glEnableVertexAttribArray(array_num);
glVertexAttribPointer(array_num, num_values, GL_FLOAT, GL_FALSE, (GLsizei)size, (void *)nullptr);
glVertexAttribDivisor(array_num, 1);
}
break;
case rendering::ValueType::FLOAT4:
......@@ -2489,12 +2490,12 @@ 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);
glEnableVertexAttribArray(array_num);
glEnableVertexAttribArray(array_num + 1);
glEnableVertexAttribArray(array_num + 2);
glEnableVertexAttribArray(array_num + 3);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
glBindBuffer(GL_ARRAY_BUFFER, buffer->vbo);
if(renderer->render.instancing.dirty_mat4_buffers[handle])
{
......@@ -2502,15 +2503,15 @@ static void setup_instanced_vertex_attribute_buffers(rendering::VertexAttributeI
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:
......@@ -2619,7 +2620,15 @@ static void render_buffer(rendering::PrimitiveType primitive_type, rendering::Tr
setup_instanced_vertex_attribute_buffers(material.instanced_vertex_attributes, material.instanced_vertex_attribute_count, shader_info, render_state, renderer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.ibo);
glDrawElementsInstanced(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, (void *)nullptr, count);
if(count == 1)
{
glDrawElements(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, nullptr);