Commit be2f0b5d authored by stonecompass's avatar stonecompass
Browse files

Added recursive entity activation.


Former-commit-id: 48e88cf8
parent 3bc33525
......@@ -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;
......@@ -561,11 +566,12 @@ static void init_renderer(Renderer *renderer, WorkQueue *reload_queue, ThreadInf
standard_info.width = renderer->framebuffer_width;
standard_info.height = renderer->framebuffer_height;
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 2);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 2);
rendering::add_depth_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::DepthAttachmentFlags::DEPTH_MULTISAMPLED, standard_info, 2);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 8);
rendering::add_color_attachment(rendering::AttachmentType::RENDER_BUFFER, rendering::ColorAttachmentFlags::MULTISAMPLED | rendering::ColorAttachmentFlags::CLAMP_TO_EDGE, standard_info, 8);
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;
......
......@@ -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);
......@@ -1803,7 +1802,7 @@ static void initialize_opengl(RenderState &render_state, Renderer *renderer, r32
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_SAMPLES, 16);
glfwWindowHint(GLFW_SAMPLES, 8);
render_state.contrast = contrast;
render_state.brightness = brightness;
......@@ -2624,10 +2623,10 @@ static void render_buffer(rendering::PrimitiveType primitive_type, rendering::Tr
if(count == 1)
{
glDrawElements(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, 0);
glDrawElements(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, nullptr);
}
else
glDrawElementsInstanced(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, 0, count);
glDrawElementsInstanced(GL_TRIANGLES, buffer.index_buffer_count, GL_UNSIGNED_SHORT, nullptr, count);
}
......
#define ENTITY_IS_VALID(handle) handle.handle > 0
namespace scene
{
static void register_type(const RegisteredEntityType &registered, SceneManager *scene_manager)
......@@ -3841,7 +3839,7 @@ static Camera get_standard_camera(SceneManager& manager)
return false;
}
static void _set_active(EntityHandle handle, b32 active, Scene &scene)
static void _set_active(EntityHandle handle, b32 active, Scene &scene, b32 recursive)
{
if(handle.handle > 0)
{
......@@ -3850,13 +3848,23 @@ static Camera get_standard_camera(SceneManager& manager)
{
scene.active_entities[internal_handle] = active;
}
if(recursive)
{
i32 child_count = get_child_count(handle, scene.handle); // @Speed: This is yet another lookup
for(i32 i = 0; i < child_count; i++)
{
_set_active(get_child_handle(handle, i, scene.handle), active, scene, recursive);
}
}
}
}
static void set_active(EntityHandle handle, b32 active, SceneHandle scene_handle)
static void set_active(EntityHandle handle, b32 active, SceneHandle scene_handle, b32 recursive)
{
Scene &scene = get_scene(scene_handle);
_set_active(handle, active, scene);
_set_active(handle, active, scene, recursive);
}
static void set_hide_in_ui(EntityHandle handle, b32 hide, SceneHandle scene_handle)
......
#ifndef SCENE_H
#define SCENE_H
#define ENTITY_IS_VALID(handle) handle.handle > 0
#define SCALE_SENSITIVITY 0.01f
#define EMPTY_ENTITY_HANDLE {0}
......@@ -777,7 +779,7 @@ namespace scene
static void unregister_entity(EntityHandle handle, SceneHandle scene);
static EntityTemplate _load_template(const char *path, EntityTemplateState template_state, SceneHandle scene);
static EntityHandle register_entity_from_template_file(const char *path, SceneHandle scene, b32 savable = false, Tags* tags = nullptr);
static void set_active(EntityHandle handle, b32 active, SceneHandle scene);
static void set_active(EntityHandle handle, b32 active, SceneHandle scene, b32 recursive = true);
static void set_hide_in_ui(EntityHandle handle, b32 hide, SceneHandle scene_handle);
static TransformComponent& get_transform_comp(EntityHandle handle, Scene &scene);
static TransformComponent& get_transform_comp(EntityHandle handle, SceneHandle scene);
......@@ -816,12 +818,15 @@ namespace scene
static EntityTemplate _load_template(const char *path, EntityTemplateState &template_state, Scene &scene);
static EntityHandle _register_entity_from_template_file(const char *path, Scene &scene, b32 savable, Tags* tags);
static b32 is_active(EntityHandle handle, SceneHandle scene_handle);
static void _set_active(EntityHandle handle, b32 active, Scene &scene);
static void _set_active(EntityHandle handle, b32 active, Scene &scene, b32 recursive);
static TransformComponent& _get_transform_comp(EntityHandle handle, Scene &scene);
static RenderComponent& _get_render_comp(EntityHandle handle, Scene &scene);
static CameraComponent& _get_camera_comp(EntityHandle handle, Scene &scene);
static ParticleSystemComponent& _get_particle_system_comp(EntityHandle handle, Scene &scene);
static LightComponent &_get_light_comp(EntityHandle handle, Scene &scene);
static i32 get_child_count(EntityHandle handle, SceneHandle scene);
static EntityHandle get_child_handle(EntityHandle handle, i32 index, SceneHandle scene);
i32 _unused_entity_handle(Scene &scene);
i32 _pack_transform_components(Entity &entity, Scene &scene);
......
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