From c58f1c2db24ce9fa6e8afffa0586004314c56f3e Mon Sep 17 00:00:00 2001 From: korenkonder Date: Thu, 27 Jun 2024 09:10:13 +0300 Subject: [PATCH] Small overhaul --- src/CRE/effect.cpp | 74 +-- src/CRE/object.cpp | 16 +- src/CRE/render.cpp | 2 +- src/CRE/render_context.cpp | 4 +- src/CRE/render_context.hpp | 4 +- src/CRE/renderer/dof.cpp | 25 +- src/CRE/renderer/dof.hpp | 1 - src/CRE/renderer/fbo.hpp | 5 + src/CRE/renderer/transparency.cpp | 12 +- src/CRE/shader.hpp | 2 - src/CRE/shader_dev.cpp | 20 +- src/CRE/shader_ft.cpp | 666 ++++-------------------- src/CRE/static_var.hpp | 5 +- src/DivaGL/bone_data.hpp | 4 +- src/ReDIVA/app.cpp | 81 +-- src/ReDIVA/data_edit/glitter_editor.cpp | 5 +- src/ReDIVA/imgui_helper.hpp | 1 - 17 files changed, 192 insertions(+), 735 deletions(-) diff --git a/src/CRE/effect.cpp b/src/CRE/effect.cpp index d1c26e29..d2fb129e 100644 --- a/src/CRE/effect.cpp +++ b/src/CRE/effect.cpp @@ -4912,23 +4912,6 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal vtx_data[vtx].texcoord.x = 1.0f; vtx_data[vtx].texcoord.y = (latitude_offset_degs_10 - (1.0f / uv_rec_scale_v) * 90.0f) * rec_latitude_degs_10; - if (!vao) - glGenVertexArrays(1, &vao); - - vbo.Create(sizeof(star_catalog_vertex) * vtx_count, vtx_data); - vbo.Bind(); - free_def(vtx_data); - - static const GLsizei buffer_size = sizeof(star_catalog_vertex); - - gl_state_bind_vertex_array(vao); - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size, - (void*)offsetof(star_catalog_vertex, position)); - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size, - (void*)offsetof(star_catalog_vertex, texcoord)); - const uint16_t first_vertex = 0; const uint16_t last_vertex = (uint16_t)(vtx_count - 1); uint16_t restart_index = this->restart_index; @@ -4960,8 +4943,29 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal ebo_data[idx + 3] = restart_index; } + static const GLsizei buffer_size = sizeof(star_catalog_vertex); + + if (!vao) + glGenVertexArrays(1, &vao); + + vbo.Create((size_t)buffer_size * vtx_count, vtx_data); + vbo.Bind(); + + gl_state_bind_vertex_array(vao); + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(star_catalog_vertex, position)); + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, buffer_size, + (void*)offsetof(star_catalog_vertex, texcoord)); + ebo.Create(sizeof(uint16_t) * ebo_count, ebo_data); ebo.Bind(); + + gl_state_bind_vertex_array(0); + gl_state_bind_array_buffer(0); + gl_state_bind_element_array_buffer(0); + free_def(vtx_data); free_def(ebo_data); if (!sampler) @@ -4970,10 +4974,6 @@ void star_catalog_milky_way::create_buffers(int32_t subdivs, float_t uv_rec_scal glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_REPEAT); glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - gl_state_bind_vertex_array(0); - gl_state_bind_array_buffer(0); - gl_state_bind_element_array_buffer(0); } void star_catalog_milky_way::create_default_sphere() { @@ -5681,11 +5681,22 @@ static void leaf_particle_init(bool change_stage) { for (; i < leaf_ptcl_count; i++, data++) data->type = 0; - if (!leaf_ptcl_vao) - glGenVertexArrays(1, &leaf_ptcl_vao); + size_t ebo_count = leaf_ptcl_vtx_count / 4 * 6; + uint32_t* ebo_data = force_malloc(ebo_count); + for (size_t i = 0, j = 0; i < ebo_count; i += 6, j += 4) { + ebo_data[i + 0] = (uint32_t)(j + 0); + ebo_data[i + 1] = (uint32_t)(j + 1); + ebo_data[i + 2] = (uint32_t)(j + 2); + ebo_data[i + 3] = (uint32_t)(j + 0); + ebo_data[i + 4] = (uint32_t)(j + 2); + ebo_data[i + 5] = (uint32_t)(j + 3); + } static const GLsizei buffer_size = sizeof(leaf_particle_vertex_data); + if (!leaf_ptcl_vao) + glGenVertexArrays(1, &leaf_ptcl_vao); + leaf_ptcl_vbo.Create(buffer_size * leaf_ptcl_vtx_count); leaf_ptcl_vbo.Bind(); @@ -5700,24 +5711,13 @@ static void leaf_particle_init(bool change_stage) { glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, buffer_size, (void*)offsetof(leaf_particle_vertex_data, normal)); - size_t ebo_count = leaf_ptcl_vtx_count / 4 * 6; - uint32_t* ebo_data = force_malloc(ebo_count); - for (size_t i = 0, j = 0; i < ebo_count; i += 6, j += 4) { - ebo_data[i + 0] = (uint32_t)(j + 0); - ebo_data[i + 1] = (uint32_t)(j + 1); - ebo_data[i + 2] = (uint32_t)(j + 2); - ebo_data[i + 3] = (uint32_t)(j + 0); - ebo_data[i + 4] = (uint32_t)(j + 2); - ebo_data[i + 5] = (uint32_t)(j + 3); - } - leaf_ptcl_ebo.Create(sizeof(uint32_t) * ebo_count, ebo_data); leaf_ptcl_ebo.Bind(); - free_def(ebo_data); gl_state_bind_vertex_array(0); gl_state_bind_array_buffer(0); gl_state_bind_element_array_buffer(0); + free_def(ebo_data); leaf_particle_scene_ubo.Create(sizeof(leaf_particle_scene_shader_data)); } @@ -5925,11 +5925,11 @@ static void particle_init(vec3* offset) { else particle_wind = 0.0f; + static const GLsizei buffer_size = sizeof(particle_vertex_data); + if (!ptcl_vao) glGenVertexArrays(1, &ptcl_vao); - static const GLsizei buffer_size = sizeof(particle_vertex_data); - ptcl_vbo.Create(buffer_size * ptcl_vtx_count); ptcl_vbo.Bind(); diff --git a/src/CRE/object.cpp b/src/CRE/object.cpp index ce96072e..b68b4639 100644 --- a/src/CRE/object.cpp +++ b/src/CRE/object.cpp @@ -3,15 +3,7 @@ GitHub/GitLab: korenkonder */ -#include -#include -#include -#include #include "object.hpp" -#include "data.hpp" -#include "gl_state.hpp" -#include "render_context.hpp" -#include "shader_ft.hpp" #include "../KKdLib/io/file_stream.hpp" #include "../KKdLib/io/json.hpp" #include "../KKdLib/io/path.hpp" @@ -19,6 +11,14 @@ #include "../KKdLib/hash.hpp" #include "../KKdLib/msgpack.hpp" #include "../KKdLib/str_utils.hpp" +#include "data.hpp" +#include "gl_state.hpp" +#include "render_context.hpp" +#include "shader_ft.hpp" +#include +#include +#include +#include static GLuint create_index_buffer(size_t size, const void* data); static GLuint create_vertex_buffer(size_t size, const void* data, bool dynamic = false); diff --git a/src/CRE/render.cpp b/src/CRE/render.cpp index 9a9dfa58..527ae96f 100644 --- a/src/CRE/render.cpp +++ b/src/CRE/render.cpp @@ -198,7 +198,7 @@ namespace rndr { taa_texture = 2; taa_buffer[2].Bind(); - glViewport(0, 0, render_width[0], render_height[0]); + gl_state_set_viewport(0, 0, render_width[0], render_height[0]); gl_state_active_bind_texture_2d(0, taa_tex[taa_texture_selector]->glid); gl_state_bind_sampler(0, sampler); diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index 3c5e5bc3..988e3a6d 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -266,8 +266,6 @@ void obj_shader_shader_data::set_shader_flags(int32_t* shader_flags) { g_shader_flags.w.m.specular = shader_flags[U_SPECULAR]; g_shader_flags.w.m.tone_map = shader_flags[U_TONE_MAP]; g_shader_flags.w.m.u45 = shader_flags[U45]; - g_shader_flags.w.m.dof = shader_flags[U_DOF]; // Added - g_shader_flags.w.m.dof_stage = shader_flags[U_DOF_STAGE]; // Added } void obj_scene_shader_data::set_g_irradiance_r_transforms(const mat4& mat) { @@ -605,8 +603,8 @@ render_context::~render_context() { obj_scene_ubo.Destroy(); obj_shader_ubo.Destroy(); - tone_map_ubo.Destroy(); transparency_batch_ubo.Destroy(); + tone_map_ubo.Destroy(); sun_quad_ubo.Destroy(); sss_filter_gaussian_coef_ubo.Destroy(); sprite_scene_ubo.Destroy(); diff --git a/src/CRE/render_context.hpp b/src/CRE/render_context.hpp index 6dcc68ec..bf33dc91 100644 --- a/src/CRE/render_context.hpp +++ b/src/CRE/render_context.hpp @@ -244,8 +244,6 @@ struct obj_shader_shader_data { uint32_t specular : 1; // bit 96+14 uint32_t tone_map : 2; // bit 96+15 uint32_t u45 : 1; // bit 96+16 - uint32_t dof : 1; // bit 96+17 // Added - uint32_t dof_stage : 3; // bit 96+18 // Added } m; uint32_t w; } w; @@ -437,8 +435,8 @@ struct render_context { GL::UniformBuffer sprite_scene_ubo; GL::UniformBuffer sss_filter_gaussian_coef_ubo; GL::UniformBuffer sun_quad_ubo; - GL::UniformBuffer transparency_batch_ubo; GL::UniformBuffer tone_map_ubo; + GL::UniformBuffer transparency_batch_ubo; obj_shader_shader_data obj_shader; obj_scene_shader_data obj_scene; diff --git a/src/CRE/renderer/dof.cpp b/src/CRE/renderer/dof.cpp index 5429ee22..db7ba8dc 100644 --- a/src/CRE/renderer/dof.cpp +++ b/src/CRE/renderer/dof.cpp @@ -124,11 +124,6 @@ namespace renderer { this->width = width; this->height = height; - int32_t w20 = max_def(width / 20, 1); - int32_t h20 = max_def(height / 20, 1); - int32_t w2 = max_def(width / 2, 1); - int32_t h2 = max_def(height / 2, 1); - init_textures(width, height); } @@ -138,14 +133,14 @@ namespace renderer { vao = 0; } + texcoords_ubo.Destroy(); + common_ubo.Destroy(); + if (samplers[0]) { glDeleteSamplers(2, samplers); samplers[0] = 0; } - texcoords_ubo.Destroy(); - common_ubo.Destroy(); - if (textures[0]) { glDeleteTextures(6, textures); textures[0] = 0; @@ -232,7 +227,7 @@ namespace renderer { void DOF3::render_tiles(GLuint depth_texture, bool f2) { gl_state_begin_event("renderer::DOF3::render_tiles"); - gl_state_bind_framebuffer(fbo[0].buffer); + fbo[0].bind_buffer(); gl_state_set_viewport(0, 0, fbo[0].width, fbo[0].height); uniform_value[U_DOF_STAGE] = 0; shaders_ft.set(SHADER_FT_DOF); @@ -241,7 +236,7 @@ namespace renderer { gl_state_bind_sampler(0, samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - gl_state_bind_framebuffer(fbo[1].buffer); + fbo[1].bind_buffer(); gl_state_set_viewport(0, 0, fbo[1].width, fbo[1].height); uniform_value[U_DOF_STAGE] = 1; shaders_ft.set(SHADER_FT_DOF); @@ -254,7 +249,7 @@ namespace renderer { void DOF3::downsample(GLuint color_texture, GLuint depth_texture, bool f2) { gl_state_begin_event("renderer::DOF3::downsample"); - gl_state_bind_framebuffer(fbo[2].buffer); + fbo[2].bind_buffer(); gl_state_set_viewport(0, 0, fbo[2].width, fbo[2].height); uniform_value[U_DOF_STAGE] = 2; shaders_ft.set(SHADER_FT_DOF); @@ -271,7 +266,7 @@ namespace renderer { void DOF3::apply_main_filter(bool f2) { gl_state_begin_event("renderer::DOF3::apply_main_filter"); - gl_state_bind_framebuffer(fbo[3].buffer); + fbo[3].bind_buffer(); gl_state_set_viewport(0, 0, fbo[3].width, fbo[3].height); uniform_value[U_DOF_STAGE] = 3; shaders_ft.set(SHADER_FT_DOF); @@ -306,9 +301,9 @@ namespace renderer { gl_state_bind_sampler(4, samplers[1]); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glCopyImageSubData(rctx_ptr->render_buffer.GetColorTex(), - GL_TEXTURE_2D, 0, 0, 0, 0, rt->GetColorTex(), - GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1); + glCopyImageSubData( + rctx_ptr->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, + rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, width, height, 1); gl_state_end_event(); } diff --git a/src/CRE/renderer/dof.hpp b/src/CRE/renderer/dof.hpp index 7b9a1933..a5bddc3c 100644 --- a/src/CRE/renderer/dof.hpp +++ b/src/CRE/renderer/dof.hpp @@ -7,7 +7,6 @@ #include "../../KKdLib/default.hpp" #include "../GL/uniform_buffer.hpp" -#include "../camera.hpp" #include "../render_texture.hpp" #include "fbo.hpp" diff --git a/src/CRE/renderer/fbo.hpp b/src/CRE/renderer/fbo.hpp index c2cf19dd..807b806f 100644 --- a/src/CRE/renderer/fbo.hpp +++ b/src/CRE/renderer/fbo.hpp @@ -5,6 +5,7 @@ #pragma once +#include "../gl_state.hpp" #include "../shared.hpp" namespace renderer { @@ -26,5 +27,9 @@ namespace renderer { void init(int32_t width, int32_t height, GLuint* color_textures, int32_t count, GLuint depth_texture); void free(); + + inline void bind_buffer() { + gl_state_bind_framebuffer(buffer); + } }; } diff --git a/src/CRE/renderer/transparency.cpp b/src/CRE/renderer/transparency.cpp index c286edba..27e8609d 100644 --- a/src/CRE/renderer/transparency.cpp +++ b/src/CRE/renderer/transparency.cpp @@ -55,16 +55,14 @@ namespace renderer { shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4); gl_state_enable_depth_test(); - glCopyImageSubData(rctx_ptr->render_buffer.GetColorTex(), - GL_TEXTURE_2D, 0, 0, 0, 0, rt->GetColorTex(), - GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1); + glCopyImageSubData(rctx_ptr->render_buffer.GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, + rt->GetColorTex(), GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1); } void Transparency::copy(GLuint texture) { - glCopyImageSubData(texture, - GL_TEXTURE_2D, 0, 0, 0, 0, fbo.textures[0], - GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1); - gl_state_bind_framebuffer(fbo.buffer); + glCopyImageSubData(texture, GL_TEXTURE_2D, 0, 0, 0, 0, + fbo.textures[0], GL_TEXTURE_2D, 0, 0, 0, 0, fbo.width, fbo.height, 1); + fbo.bind_buffer(); gl_state_set_viewport(0, 0, fbo.width, fbo.height); } diff --git a/src/CRE/shader.hpp b/src/CRE/shader.hpp index f224b4df..26b5f55e 100644 --- a/src/CRE/shader.hpp +++ b/src/CRE/shader.hpp @@ -13,8 +13,6 @@ #include "../KKdLib/vec.hpp" #include "static_var.hpp" -#define SHADER_MAX_UNIFORM_VALUES 16 - struct shader_sub_table { uint32_t sub_index; const int32_t* vp_unival_max; diff --git a/src/CRE/shader_dev.cpp b/src/CRE/shader_dev.cpp index fe160f75..3c663202 100644 --- a/src/CRE/shader_dev.cpp +++ b/src/CRE/shader_dev.cpp @@ -27,16 +27,22 @@ static const uniform_name GLITTER_PT_WIREFRAME_uniform[] = { U_INVALID, }; +#define shader_sub_table_struct(sub_index, vp, fp) \ +{ \ + SHADER_DEV_SUB_##sub_index, \ + vp##_vpt_unival_max, \ + fp##_fpt_unival_max, \ + #vp, \ + #fp, \ +} + static const shader_sub_table GLITTER_PT_WIREFRAME_table[] = { - { - SHADER_DEV_SUB_GLITTER_PT_WIREFRAME, - glitter_particle_wireframe_vpt_unival_max, - glitter_particle_wireframe_fpt_unival_max, - "glitter_particle_wireframe", - "glitter_particle_wireframe", - }, + shader_sub_table_struct(GLITTER_PT_WIREFRAME, + glitter_particle_wireframe, glitter_particle_wireframe), }; +#undef shader_sub_table_struct + #define shader_table_struct(n) \ { \ #n, \ diff --git a/src/CRE/shader_ft.cpp b/src/CRE/shader_ft.cpp index 1761a5c6..cb4e7347 100644 --- a/src/CRE/shader_ft.cpp +++ b/src/CRE/shader_ft.cpp @@ -94,19 +94,19 @@ enum shader_ft_sub_enum { SHADER_FT_SUB_SHADER_END, }; -static const int32_t blinn_vert_vpt_unival_max[] = { +static const int32_t blinn_per_vert_vpt_unival_max[] = { 1, 1, 0, }; -static const int32_t blinn_vert_fpt_unival_max[] = { +static const int32_t blinn_per_vert_fpt_unival_max[] = { 0, 0, 1, }; -static const int32_t blinn_frag_vpt_unival_max[] = { +static const int32_t blinn_per_frag_vpt_unival_max[] = { 1, 1, 0, }; -static const int32_t blinn_frag_fpt_unival_max[] = { +static const int32_t blinn_per_frag_fpt_unival_max[] = { 0, 0, 1, }; @@ -702,710 +702,248 @@ static const int32_t transparency_fpt_unival_max[] = { -1, }; +#define shader_sub_table_struct(sub_index, vp, fp) \ +{ \ + SHADER_FT_SUB_##sub_index, \ + vp##_vpt_unival_max, \ + fp##_fpt_unival_max, \ + #vp, \ + #fp, \ +} + static const shader_sub_table BLINN_table[] = { - { - SHADER_FT_SUB_BLINN_VERT, - blinn_vert_vpt_unival_max, - blinn_vert_fpt_unival_max, - "blinn_per_vert", - "blinn_per_vert", - }, - { - SHADER_FT_SUB_BLINN_FRAG, - blinn_frag_vpt_unival_max, - blinn_frag_fpt_unival_max, - "blinn_per_frag", - "blinn_per_frag", - }, + shader_sub_table_struct(BLINN_VERT, blinn_per_vert, blinn_per_vert), + shader_sub_table_struct(BLINN_FRAG, blinn_per_frag, blinn_per_frag), }; static const shader_sub_table ITEM_table[] = { - { - SHADER_FT_SUB_ITEM_BLINN, - item_blinn_vpt_unival_max, - item_blinn_fpt_unival_max, - "item_blinn", - "item_blinn", - }, + shader_sub_table_struct(BLINN_VERT, item_blinn, item_blinn), }; static const shader_sub_table STAGE_table[] = { - { - SHADER_FT_SUB_STAGE_BLINN, - stage_blinn_vpt_unival_max, - stage_blinn_fpt_unival_max, - "stage_blinn", - "stage_blinn", - }, + shader_sub_table_struct(STAGE_BLINN, stage_blinn, stage_blinn), }; static const shader_sub_table SKIN_table[] = { - { - SHADER_FT_SUB_SKIN_DEFAULT, - skin_default_vpt_unival_max, - skin_default_fpt_unival_max, - "skin_default", - "skin_default", - }, + shader_sub_table_struct(SKIN_DEFAULT, skin_default, skin_default), }; static const shader_sub_table SSS_SKIN_table[] = { - { - SHADER_FT_SUB_SSS_SKIN, - sss_skin_vpt_unival_max, - sss_skin_fpt_unival_max, - "sss_skin", - "sss_skin", - }, + shader_sub_table_struct(SSS_SKIN, sss_skin, sss_skin), }; static const shader_sub_table SSS_FILT_table[] = { - { - SHADER_FT_SUB_SSS_FILTER_MIN, - sss_filter_min_vpt_unival_max, - sss_filter_min_fpt_unival_max, - "sss_filter_min", - "sss_filter_min", - }, - { - SHADER_FT_SUB_SSS_FILTER_MIN_NPR, - sss_filter_min_vpt_unival_max, - sss_filter_min_npr_fpt_unival_max, - "sss_filter_min", - "sss_filter_min_npr", - }, - { - SHADER_FT_SUB_SSS_FILTER_GAUSS_2D, - sss_filter_gauss_2d_vpt_unival_max, - sss_filter_gauss_2d_fpt_unival_max, - "sss_filter_gauss_2d", - "sss_filter_gauss_2d", - }, + shader_sub_table_struct(SSS_FILTER_MIN, sss_filter_min, sss_filter_min), + shader_sub_table_struct(SSS_FILTER_MIN_NPR, sss_filter_min, sss_filter_min_npr), + shader_sub_table_struct(SSS_FILTER_GAUSS_2D, sss_filter_gauss_2d, sss_filter_gauss_2d), }; static const shader_sub_table HAIR_table[] = { - { - SHADER_FT_SUB_HAIR_DEFAULT, - hair_default_vpt_unival_max, - hair_default_fpt_unival_max, - "hair_default", - "hair_default", - }, - { - SHADER_FT_SUB_HAIR_NPR1, - hair_default_vpt_unival_max, - hair_npr1_fpt_unival_max, - "hair_default", - "hair_npr1", - }, + shader_sub_table_struct(HAIR_DEFAULT, hair_default, hair_default), + shader_sub_table_struct(HAIR_NPR1, hair_default, hair_npr1), }; static const shader_sub_table CLOTH_table[] = { - { - SHADER_FT_SUB_CLOTH_DEFAULT, - cloth_default_vpt_unival_max, - cloth_default_fpt_unival_max, - "cloth_default", - "cloth_default", - }, - { - SHADER_FT_SUB_CLOTH_ANISO, - cloth_default_vpt_unival_max, - cloth_aniso_fpt_unival_max, - "cloth_default", - "cloth_aniso", - }, - { - SHADER_FT_SUB_CLOTH_NPR1, - cloth_default_vpt_unival_max, - cloth_npr1_fpt_unival_max, - "cloth_default", - "cloth_npr1", - }, + shader_sub_table_struct(CLOTH_DEFAULT, cloth_default, cloth_default), + shader_sub_table_struct(CLOTH_ANISO, cloth_default, cloth_aniso), + shader_sub_table_struct(CLOTH_NPR1, cloth_default, cloth_npr1), }; static const shader_sub_table TIGHTS_table[] = { - { - SHADER_FT_SUB_TIGHTS, - tights_vpt_unival_max, - tights_fpt_unival_max, - "tights", - "tights", - }, + shader_sub_table_struct(TIGHTS, tights, tights), }; static const shader_sub_table SKY_table[] = { - { - SHADER_FT_SUB_SKY_DEFAULT, - sky_default_vpt_unival_max, - sky_default_fpt_unival_max, - "sky_default", - "sky_default", - }, + shader_sub_table_struct(SKY_DEFAULT, sky_default, sky_default), }; static const shader_sub_table GLASEYE_table[] = { - { - SHADER_FT_SUB_GLASS_EYE, - glass_eye_vpt_unival_max, - glass_eye_fpt_unival_max, - "glass_eye", - "glass_eye", - }, + shader_sub_table_struct(GLASS_EYE, glass_eye, glass_eye), }; static const shader_sub_table ESMGAUSS_table[] = { - { - SHADER_FT_SUB_ESM_GAUSS, - esm_gauss_vpt_unival_max, - esm_gauss_fpt_unival_max, - "esm_gauss", - "esm_gauss", - }, + shader_sub_table_struct(ESM_GAUSS, esm_gauss, esm_gauss), }; static const shader_sub_table ESMFILT_table[] = { - { - SHADER_FT_SUB_ESM_FILTER_MIN, - esm_filter_min_vpt_unival_max, - esm_filter_min_fpt_unival_max, - "esm_filter_min", - "esm_filter_min", - }, - { - SHADER_FT_SUB_ESM_FILTER_EROSION, - esm_filter_erosion_vpt_unival_max, - esm_filter_erosion_fpt_unival_max, - "esm_filter_erosion", - "esm_filter_erosion", - }, + shader_sub_table_struct(ESM_FILTER_MIN, esm_filter_min, esm_filter_min), + shader_sub_table_struct(ESM_FILTER_EROSION, esm_filter_erosion, esm_filter_erosion), }; static const shader_sub_table LITPROJ_table[] = { - { - SHADER_FT_SUB_LIT_PROJ, - lit_proj_vpt_unival_max, - lit_proj_fpt_unival_max, - "lit_proj", - "lit_proj", - }, + shader_sub_table_struct(LIT_PROJ, lit_proj, lit_proj), }; static const shader_sub_table SIMPLE_table[] = { - { - SHADER_FT_SUB_SIMPLE, - simple_vpt_unival_max, - simple_fpt_unival_max, - "simple", - "simple", - }, + shader_sub_table_struct(SIMPLE, simple, simple), }; static const shader_sub_table SIL_table[] = { - { - SHADER_FT_SUB_SILHOUETTE, - silhouette_vpt_unival_max, - silhouette_fpt_unival_max, - "silhouette", - "silhouette", - }, + shader_sub_table_struct(SILHOUETTE, silhouette, silhouette), }; static const shader_sub_table LAMBERT_table[] = { - { - SHADER_FT_SUB_LAMBERT, - lambert_vpt_unival_max, - lambert_fpt_unival_max, - "lambert", - "lambert", - }, + shader_sub_table_struct(LAMBERT, lambert, lambert), }; static const shader_sub_table CONSTANT_table[] = { - { - SHADER_FT_SUB_CONSTANT, - constant_vpt_unival_max, - constant_fpt_unival_max, - "constant", - "constant", - }, + shader_sub_table_struct(CONSTANT, constant, constant), }; static const shader_sub_table TONEMAP_table[] = { - { - SHADER_FT_SUB_TONEMAP, - tone_map_vpt_unival_max, - tone_map_fpt_unival_max, - "tone_map", - "tone_map", - }, - { - SHADER_FT_SUB_TONEMAP_NPR1, - tone_map_npr1_vpt_unival_max, - tone_map_npr1_fpt_unival_max, - "tone_map_npr1", - "tone_map_npr1", - }, + shader_sub_table_struct(TONEMAP, tone_map, tone_map), + shader_sub_table_struct(TONEMAP_NPR1, tone_map_npr1, tone_map_npr1), }; static const shader_sub_table REDUCE_table[] = { - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_2, - reduce_tex_reduce_2_vpt_unival_max, - reduce_tex_reduce_2_fpt_unival_max, - "reduce_tex_reduce_2", - "reduce_tex_reduce_2", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_2_ALPHAMASK, - reduce_tex_reduce_2_alphamask_vpt_unival_max, - reduce_tex_reduce_2_alphamask_fpt_unival_max, - "reduce_tex_reduce_2_alphamask", - "reduce_tex_reduce_2_alphamask", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_4, - reduce_tex_reduce_4_vpt_unival_max, - reduce_tex_reduce_4_fpt_unival_max, - "reduce_tex_reduce_4", - "reduce_tex_reduce_4", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_4_EXTRACT, - reduce_tex_reduce_4_extract_vpt_unival_max, - reduce_tex_reduce_4_extract_fpt_unival_max, - "reduce_tex_reduce_4_extract", - "reduce_tex_reduce_4_extract", - }, - { - SHADER_FT_SUB_GHOST, - ghost_vpt_unival_max, - ghost_fpt_unival_max, - "ghost", - "ghost", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_2, - reduce_tex_reduce_composite_2_vpt_unival_max, - reduce_tex_reduce_composite_2_fpt_unival_max, - "reduce_tex_reduce_composite_2", - "reduce_tex_reduce_composite_2", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_BLUR, - reduce_tex_reduce_composite_blur_vpt_unival_max, - reduce_tex_reduce_composite_blur_fpt_unival_max, - "reduce_tex_reduce_composite_blur", - "reduce_tex_reduce_composite_blur", - }, - { - SHADER_FT_SUB_REDUCE_TEX_REDUCE_COMPOSITE_4, - reduce_tex_reduce_composite_4_vpt_unival_max, - reduce_tex_reduce_composite_4_fpt_unival_max, - "reduce_tex_reduce_composite_4", - "reduce_tex_reduce_composite_4", - }, + shader_sub_table_struct(REDUCE_TEX_REDUCE_2, + reduce_tex_reduce_2, reduce_tex_reduce_2), + shader_sub_table_struct(REDUCE_TEX_REDUCE_2_ALPHAMASK, + reduce_tex_reduce_2_alphamask, reduce_tex_reduce_2_alphamask), + shader_sub_table_struct(REDUCE_TEX_REDUCE_4, + reduce_tex_reduce_4, reduce_tex_reduce_4), + shader_sub_table_struct(REDUCE_TEX_REDUCE_4_EXTRACT, + reduce_tex_reduce_4_extract, reduce_tex_reduce_4_extract), + shader_sub_table_struct(GHOST, ghost, ghost), + shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_2, + reduce_tex_reduce_composite_2, reduce_tex_reduce_composite_2), + shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_BLUR, + reduce_tex_reduce_composite_blur, reduce_tex_reduce_composite_blur), + shader_sub_table_struct(REDUCE_TEX_REDUCE_COMPOSITE_4, + reduce_tex_reduce_composite_4, reduce_tex_reduce_composite_4), }; static const shader_sub_table MAGNIFY_table[] = { - { - SHADER_FT_SUB_MAGNIFY_LINEAR, - magnify_linear_vpt_unival_max, - magnify_linear_fpt_unival_max, - "magnify_linear", - "magnify_linear", - }, - { - SHADER_FT_SUB_MAGNIFY_DIFF, - magnify_diff_vpt_unival_max, - magnify_diff_fpt_unival_max, - "magnify_diff", - "magnify_diff", - }, - { - SHADER_FT_SUB_MAGNIFY_DIFF2, - magnify_diff2_vpt_unival_max, - magnify_diff2_fpt_unival_max, - "magnify_diff2", - "magnify_diff2", - }, - { - SHADER_FT_SUB_MAGNIFY_CONE, - magnify_cone_vpt_unival_max, - magnify_cone_fpt_unival_max, - "magnify_cone", - "magnify_cone", - }, - { - SHADER_FT_SUB_MAGNIFY_CONE2, - magnify_cone2_vpt_unival_max, - magnify_cone2_fpt_unival_max, - "magnify_cone2", - "magnify_cone2", - }, + shader_sub_table_struct(MAGNIFY_LINEAR, magnify_linear, magnify_linear), + shader_sub_table_struct(MAGNIFY_DIFF, magnify_diff, magnify_diff), + shader_sub_table_struct(MAGNIFY_DIFF2, magnify_diff2, magnify_diff2), + shader_sub_table_struct(MAGNIFY_CONE, magnify_cone, magnify_cone), + shader_sub_table_struct(MAGNIFY_CONE2, magnify_cone2, magnify_cone2), }; static const shader_sub_table MLAA_table[] = { - { - SHADER_FT_SUB_MLAA_EDGE, - mlaa_edge_vpt_unival_max, - mlaa_edge_fpt_unival_max, - "mlaa_edge", - "mlaa_edge", - }, - { - SHADER_FT_SUB_MLAA_AREA, - mlaa_area_vpt_unival_max, - mlaa_area_fpt_unival_max, - "mlaa_area", - "mlaa_area", - }, - { - SHADER_FT_SUB_MLAA_BLEND, - mlaa_blend_vpt_unival_max, - mlaa_blend_fpt_unival_max, - "mlaa_blend", - "mlaa_blend", - }, + shader_sub_table_struct(MLAA_EDGE, mlaa_edge, mlaa_edge), + shader_sub_table_struct(MLAA_AREA, mlaa_area, mlaa_area), + shader_sub_table_struct(MLAA_BLEND, mlaa_blend, mlaa_blend), }; static const shader_sub_table CONTOUR_table[] = { - { - SHADER_FT_SUB_CONTOUR, - contour_vpt_unival_max, - contour_fpt_unival_max, - "contour", - "contour", - }, + shader_sub_table_struct(CONTOUR, contour, contour), }; static const shader_sub_table CONTOUR_NPR_table[] = { - { - SHADER_FT_SUB_CONTOUR_NPR, - contour_npr_vpt_unival_max, - contour_npr_fpt_unival_max, - "contour_npr", - "contour_npr", - }, + shader_sub_table_struct(CONTOUR_NPR, contour_npr, contour_npr), }; static const shader_sub_table EXPOSURE_table[] = { - { - SHADER_FT_SUB_EXPOSURE_MINIFY, - exposure_minify_vpt_unival_max, - exposure_minify_fpt_unival_max, - "exposure_minify", - "exposure_minify", - }, - { - SHADER_FT_SUB_EXPOSURE_MEASURE, - exposure_measure_vpt_unival_max, - exposure_measure_fpt_unival_max, - "exposure_measure", - "exposure_measure", - }, - { - SHADER_FT_SUB_EXPOSURE_AVERAGE, - exposure_average_vpt_unival_max, - exposure_average_fpt_unival_max, - "exposure_average", - "exposure_average", - }, + shader_sub_table_struct(EXPOSURE_MINIFY, exposure_minify, exposure_minify), + shader_sub_table_struct(EXPOSURE_MEASURE, exposure_measure, exposure_measure), + shader_sub_table_struct(EXPOSURE_AVERAGE, exposure_average, exposure_average), }; static const shader_sub_table GAUSS_table[] = { - { - SHADER_FT_SUB_PP_GAUSS_USUAL, - pp_gauss_usual_vpt_unival_max, - pp_gauss_usual_fpt_unival_max, - "pp_gauss_usual", - "pp_gauss_usual", - }, - { - SHADER_FT_SUB_PP_GAUSS_CONE, - pp_gauss_cone_vpt_unival_max, - pp_gauss_cone_fpt_unival_max, - "pp_gauss_cone", - "pp_gauss_cone", - }, + shader_sub_table_struct(PP_GAUSS_USUAL, pp_gauss_usual, pp_gauss_usual), + shader_sub_table_struct(PP_GAUSS_CONE, pp_gauss_cone, pp_gauss_cone), }; static const shader_sub_table SUN_table[] = { - { - SHADER_FT_SUB_SUN, - sun_vpt_unival_max, - sun_fpt_unival_max, - "sun", - "sun", - }, + shader_sub_table_struct(SUN, sun, sun), }; static const shader_sub_table SUN_NO_TEXTURED_table[] = { - { - SHADER_FT_SUB_SUN_NO_TEXTURED, - sun_no_textured_vpt_unival_max, - sun_no_textured_fpt_unival_max, - "sun_no_textured", - "sun_no_textured", - }, + shader_sub_table_struct(SUN_NO_TEXTURED, sun_no_textured, sun_no_textured), }; static const shader_sub_table WATER01_table[] = { - { - SHADER_FT_SUB_WATER01, - water01_vpt_unival_max, - water01_fpt_unival_max, - "water01", - "water01", - }, + shader_sub_table_struct(WATER01, water01, water01), }; static const shader_sub_table W_PTCL_table[] = { - { - SHADER_FT_SUB_WATER_PARTICLE, - water_particle_vpt_unival_max, - water_particle_fpt_unival_max, - "water_particle", - "water_particle", - }, + shader_sub_table_struct(WATER_PARTICLE, water_particle, water_particle), }; static const shader_sub_table SNOW_PT_table[] = { - { - SHADER_FT_SUB_SNOW_PARTICLE, - snow_particle_vpt_unival_max, - snow_particle_fpt_unival_max, - "snow_particle", - "snow_particle", - }, - { - SHADER_FT_SUB_SNOW_PARTICLE_CPU, - snow_particle_cpu_vpt_unival_max, - snow_particle_cpu_fpt_unival_max, - "snow_particle_cpu", - "snow_particle_cpu", - }, + shader_sub_table_struct(SNOW_PARTICLE, snow_particle, snow_particle), + shader_sub_table_struct(SNOW_PARTICLE_CPU, snow_particle_cpu, snow_particle_cpu), }; static const shader_sub_table LEAF_PT_table[] = { - { - SHADER_FT_SUB_LEAF_PARTICLE, - leaf_particle_vpt_unival_max, - leaf_particle_fpt_unival_max, - "leaf_particle", - "leaf_particle", - }, + shader_sub_table_struct(LEAF_PARTICLE, leaf_particle, leaf_particle), }; static const shader_sub_table STAR_table[] = { - { - SHADER_FT_SUB_STAR, - star_vpt_unival_max, - star_fpt_unival_max, - "star", - "star", - }, - { - SHADER_FT_SUB_STAR_MILKY_WAY, - star_milky_way_vpt_unival_max, - star_milky_way_fpt_unival_max, - "star_milky_way", - "star_milky_way", - }, + shader_sub_table_struct(STAR, star, star), + shader_sub_table_struct(STAR_MILKY_WAY, star_milky_way, star_milky_way), }; static const shader_sub_table FLOOR_table[] = { - { - SHADER_FT_SUB_FLOOR, - floor_vpt_unival_max, - floor_fpt_unival_max, - "floor", - "floor", - }, + shader_sub_table_struct(FLOOR, floor, floor), }; static const shader_sub_table PUDDLE_table[] = { - { - SHADER_FT_SUB_PUDDLE, - puddle_vpt_unival_max, - puddle_fpt_unival_max, - "puddle", - "puddle", - }, + shader_sub_table_struct(PUDDLE, puddle, puddle), }; static const shader_sub_table S_REFL_table[] = { - { - SHADER_FT_SUB_SIMPLE_REFLECT, - simple_reflect_vpt_unival_max, - simple_reflect_fpt_unival_max, - "simple_reflect", - "simple_reflect", - }, + shader_sub_table_struct(SIMPLE_REFLECT, simple_reflect, simple_reflect), }; static const shader_sub_table S_REFR_table[] = { - { - SHADER_FT_SUB_SIMPLE_REFRACT, - simple_refract_vpt_unival_max, - simple_refract_fpt_unival_max, - "simple_refract", - "simple_refract", - }, + shader_sub_table_struct(SIMPLE_REFRACT, simple_refract, simple_refract), }; static const shader_sub_table RIPEMIT_table[] = { - { - SHADER_FT_SUB_RIPPLE_EMIT, - ripple_emit_vpt_unival_max, - ripple_emit_fpt_unival_max, - "ripple_emit", - "ripple_emit", - }, + shader_sub_table_struct(RIPPLE_EMIT, ripple_emit, ripple_emit), }; static const shader_sub_table RAIN_table[] = { - { - SHADER_FT_SUB_RAIN, - rain_vpt_unival_max, - rain_fpt_unival_max, - "rain", - "rain", - }, + shader_sub_table_struct(RAIN, rain, rain), }; static const shader_sub_table RIPPLE_table[] = { - { - SHADER_FT_SUB_RIPPLE, - ripple_vpt_unival_max, - ripple_fpt_unival_max, - "ripple", - "ripple", - }, + shader_sub_table_struct(RIPPLE, ripple, ripple), }; static const shader_sub_table FOGPTCL_table[] = { - { - SHADER_FT_SUB_FOG_PTCL, - fog_ptcl_vpt_unival_max, - fog_ptcl_fpt_unival_max, - "fog_ptcl", - "fog_ptcl", - }, + shader_sub_table_struct(FOG_PTCL, fog_ptcl, fog_ptcl), }; static const shader_sub_table PARTICL_table[] = { - { - SHADER_FT_SUB_PARTICLE, - particle_vpt_unival_max, - particle_fpt_unival_max, - "particle", - "particle", - }, + shader_sub_table_struct(PARTICLE, particle, particle), }; static const shader_sub_table GLITTER_PT_table[] = { - { - SHADER_FT_SUB_GLITTER_PARTICLE, - glitter_particle_vpt_unival_max, - glitter_particle_fpt_unival_max, - "glitter_particle", - "glitter_particle", - }, + shader_sub_table_struct(GLITTER_PARTICLE, glitter_particle, glitter_particle), }; static const shader_sub_table FONT_table[] = { - { - SHADER_FT_SUB_FONT, - font_vpt_unival_max, - font_fpt_unival_max, - "font", - "font", - }, + shader_sub_table_struct(FONT, font, font), }; static const shader_sub_table IMGFILT_table[] = { - { - SHADER_FT_SUB_BOX4, - box4_vpt_unival_max, - box4_fpt_unival_max, - "box4", - "box4", - }, - { - SHADER_FT_SUB_BOX8, - box8_vpt_unival_max, - box8_fpt_unival_max, - "box8", - "box8", - }, - { - SHADER_FT_SUB_COPY, - copy_vpt_unival_max, - copy_fpt_unival_max, - "copy", - "copy", - }, + shader_sub_table_struct(BOX4, box4, box4), + shader_sub_table_struct(BOX8, box8, box8), + shader_sub_table_struct(COPY, copy, copy), }; static const shader_sub_table SPRITE_table[] = { - { - SHADER_FT_SUB_SPRITE, - sprite_vpt_unival_max, - sprite_fpt_unival_max, - "sprite", - "sprite", - }, + shader_sub_table_struct(SPRITE, sprite, sprite), }; static const shader_sub_table DOF_table[] = { - { - SHADER_FT_SUB_DOF_RENDER_TILE, - dof_common_vpt_unival_max, - dof_render_tile_fpt_unival_max, - "dof_common", - "dof_render_tile", - }, - { - SHADER_FT_SUB_DOF_GATHER_TILE, - dof_common_vpt_unival_max, - dof_gather_tile_fpt_unival_max, - "dof_common", - "dof_gather_tile", - }, - { - SHADER_FT_SUB_DOF_DOWNSAMPLE, - dof_common_vpt_unival_max, - dof_downsample_fpt_unival_max, - "dof_common", - "dof_downsample", - }, - { - SHADER_FT_SUB_DOF_MAIN_FILTER, - dof_common_vpt_unival_max, - dof_main_filter_fpt_unival_max, - "dof_common", - "dof_main_filter", - }, - { - SHADER_FT_SUB_DOF_UPSAMPLE, - dof_common_vpt_unival_max, - dof_upsample_fpt_unival_max, - "dof_common", - "dof_upsample", - }, + shader_sub_table_struct(DOF_RENDER_TILE, dof_common, dof_render_tile), + shader_sub_table_struct(DOF_GATHER_TILE, dof_common, dof_gather_tile), + shader_sub_table_struct(DOF_DOWNSAMPLE, dof_common, dof_downsample), + shader_sub_table_struct(DOF_MAIN_FILTER, dof_common, dof_main_filter), + shader_sub_table_struct(DOF_UPSAMPLE, dof_common, dof_upsample), }; static const shader_sub_table TRANSPARENCY_table[] = { - { - SHADER_FT_SUB_TRANSPARENCY, - transparency_vpt_unival_max, - transparency_fpt_unival_max, - "transparency", - "transparency", - }, + shader_sub_table_struct(TRANSPARENCY, transparency, transparency), }; +#undef shader_sub_table_struct + static const uniform_name BLINN_uniform[] = { U_SKINNING, U_MORPH, diff --git a/src/CRE/static_var.hpp b/src/CRE/static_var.hpp index f6ee6107..646b8b82 100644 --- a/src/CRE/static_var.hpp +++ b/src/CRE/static_var.hpp @@ -98,10 +98,11 @@ enum uniform_name { U_SPECULAR, U_TONE_MAP, U45, - U_DOF, // Added - U_DOF_STAGE, // Added U_MAX, U_INVALID = -1, + + U_DOF = U_TEX_0_TYPE, + U_DOF_STAGE = U_TEX_1_TYPE, }; extern int32_t sv_max_texture_buffer_size; diff --git a/src/DivaGL/bone_data.hpp b/src/DivaGL/bone_data.hpp index 66357d45..ab83d87d 100644 --- a/src/DivaGL/bone_data.hpp +++ b/src/DivaGL/bone_data.hpp @@ -9,7 +9,6 @@ #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" #include "types.hpp" -#include enum bone_database_bone_type { BONE_DATABASE_BONE_ROTATION = 0x00, @@ -3719,6 +3718,9 @@ struct obj { uint32_t reserved[10]; }; +typedef uint32_t GLuint; +typedef uint32_t GLenum; + struct obj_mesh_vertex_buffer { int32_t count; GLuint buffers[3]; diff --git a/src/ReDIVA/app.cpp b/src/ReDIVA/app.cpp index 174ff4a1..4a1659d5 100644 --- a/src/ReDIVA/app.cpp +++ b/src/ReDIVA/app.cpp @@ -69,7 +69,6 @@ #include "shared.hpp" #include "task_window.hpp" #include "x_pv_game.hpp" -#include #if BAKE_VIDEO #include #include @@ -105,18 +104,11 @@ struct common_data_struct { }; struct render_data { - GLuint grid_vao; - GL::ArrayBuffer grid_vbo; - GL::UniformBuffer grid_ubo; - render_data(); ~render_data(); bool load(); void unload(); - - void load_common_data(); - void unload_common_data(); }; common_data_struct common_data; @@ -347,7 +339,7 @@ void app_set_render_scale_index(int32_t index) { float_t rob_frame = 0.0f; -render_data::render_data() : grid_vao() { +render_data::render_data() { } @@ -389,73 +381,6 @@ void render_data::unload() { #endif } -void render_data::load_common_data() { - float_t* grid_verts = force_malloc(3 * grid_vertex_count); - - size_t v = 0; - for (float_t x = -grid_size; x <= grid_size; x += grid_spacing) { - int32_t x_color_index; - int32_t z_color_index; - if (x == 0) { - x_color_index = 0; - z_color_index = 1; - } - else { - x_color_index = 2; - z_color_index = 2; - } - - grid_verts[v++] = x; - grid_verts[v++] = -grid_size; - *(int32_t*)&grid_verts[v++] = x_color_index; - - grid_verts[v++] = x; - grid_verts[v++] = grid_size; - *(int32_t*)&grid_verts[v++] = x_color_index; - - grid_verts[v++] = -grid_size; - grid_verts[v++] = x; - *(int32_t*)&grid_verts[v++] = z_color_index; - - grid_verts[v++] = grid_size; - grid_verts[v++] = x; - *(int32_t*)&grid_verts[v++] = z_color_index; - } - - glGenVertexArrays(1, &grid_vao); - gl_state_bind_vertex_array(grid_vao); - - grid_vbo.Create(sizeof(float_t) * 3 * grid_vertex_count, grid_verts); - grid_vbo.Bind(); - - glVertexAttrib4f(0, 0.0f, 0.0f, 0.0f, 1.0f); - glVertexAttribI1i(1, 2); - - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, - sizeof(float_t) * 3, (void*)0); - glEnableVertexAttribArray(1); - glVertexAttribIPointer(1, 1, GL_INT, - sizeof(float_t) * 3, (void*)(sizeof(float_t) * 2)); - - gl_state_bind_array_buffer(0); - gl_state_bind_vertex_array(0); - - grid_ubo.Create(sizeof(mat4)); - - free(grid_verts); -} - -void render_data::unload_common_data() { - grid_ubo.Destroy(); - grid_vbo.Destroy(); - - if (grid_vao) { - glDeleteVertexArrays(1, &grid_vao); - grid_vao = 0; - } -} - static bool app_init(const app_init_struct& ais) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); @@ -991,8 +916,6 @@ static render_context* render_context_load() { cam->set_view_point({ 0.0f, 1.4f, 1.0f }); cam->set_interest({ 0.0f, 1.4f, 0.0f }); - render->load_common_data(); - uniform_value[U16] = 1; imgui_context_lock = new lock_cs; @@ -1214,8 +1137,6 @@ static void render_context_dispose(render_context* rctx) { delete imgui_context_lock; imgui_context_lock = 0; - render->unload_common_data(); - Glitter::glt_particle_manager_del_task(); rctx->free(); diff --git a/src/ReDIVA/data_edit/glitter_editor.cpp b/src/ReDIVA/data_edit/glitter_editor.cpp index 0e7f2858..d70e3a87 100644 --- a/src/ReDIVA/data_edit/glitter_editor.cpp +++ b/src/ReDIVA/data_edit/glitter_editor.cpp @@ -27,7 +27,6 @@ #include #include #include -#include static const float_t curve_base_values[] = { 0.0f, @@ -2223,13 +2222,13 @@ static void glitter_editor_disp_wireframe(GlitterEditor* glt_edt) { if (Glitter::glt_particle_manager->flags & Glitter::PARTICLE_MANAGER_NOT_DISP) return; - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + gl_state_set_polygon_mode(GL_FRONT_AND_BACK, GL_LINE); gl_state_disable_cull_face(); for (Glitter::Scene*& i : Glitter::glt_particle_manager->scenes) if (i) glitter_editor_disp_wireframe_scene(glt_edt, i); gl_state_enable_cull_face(); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + gl_state_set_polygon_mode(GL_FRONT_AND_BACK, GL_FILL); } static void glitter_editor_disp_wireframe_effect_inst( diff --git a/src/ReDIVA/imgui_helper.hpp b/src/ReDIVA/imgui_helper.hpp index dee3943d..af4efd64 100644 --- a/src/ReDIVA/imgui_helper.hpp +++ b/src/ReDIVA/imgui_helper.hpp @@ -11,7 +11,6 @@ #define CIMGUI_DEFINE_ENUMS_AND_STRUCTS #include #include -#include #include namespace ImGui {