diff --git a/src/CRE/gl_rend_state.cpp b/src/CRE/gl_rend_state.cpp index 3836f305..a904f6e9 100644 --- a/src/CRE/gl_rend_state.cpp +++ b/src/CRE/gl_rend_state.cpp @@ -129,7 +129,7 @@ struct gl_rend_state { gl_rend_state gl_state_data[GL_REND_STATE_COUNT]; -p_gl_rend_state::p_gl_rend_state(int32_t index) : ptr(gl_state_data[index]) { +p_gl_rend_state::p_gl_rend_state(gl_rend_state_index index) : ptr(gl_state_data[index]) { } diff --git a/src/CRE/gl_rend_state.hpp b/src/CRE/gl_rend_state.hpp index af7e3fcd..94f80617 100644 --- a/src/CRE/gl_rend_state.hpp +++ b/src/CRE/gl_rend_state.hpp @@ -8,7 +8,13 @@ #include "../KKdLib/default.hpp" #include "gl.hpp" -constexpr int32_t GL_REND_STATE_COUNT = 4; +enum gl_rend_state_index { + GL_REND_STATE_PRE_3D = 0, + GL_REND_STATE_3D, + GL_REND_STATE_2D, + GL_REND_STATE_POST_2D, + GL_REND_STATE_COUNT, +}; struct gl_rend_state_rect { GLint x; @@ -20,7 +26,7 @@ struct gl_rend_state_rect { struct p_gl_rend_state { struct gl_rend_state& ptr; - p_gl_rend_state(int32_t index); + p_gl_rend_state(gl_rend_state_index index); void active_bind_texture_2d(int32_t index, GLuint texture, bool force = false); void active_bind_texture_cube_map(int32_t index, GLuint texture, bool force = false); diff --git a/src/CRE/render_context.cpp b/src/CRE/render_context.cpp index f5b06dc8..77310667 100644 --- a/src/CRE/render_context.cpp +++ b/src/CRE/render_context.cpp @@ -583,7 +583,7 @@ void render_data::set_shader(uint32_t index) { enum_or(flags, RENDER_DATA_SHADER_UPDATE); } -render_data_context::render_data_context(int32_t index) : state(index), index(index), +render_data_context::render_data_context(gl_rend_state_index index) : state(index), index(index), data(rctx_ptr->data[index]), shader_flags(rctx_ptr->data[index].shader_flags){ } diff --git a/src/CRE/render_context.hpp b/src/CRE/render_context.hpp index c490e5b0..0aeb39cf 100644 --- a/src/CRE/render_context.hpp +++ b/src/CRE/render_context.hpp @@ -440,11 +440,11 @@ struct render_data_context { }; p_gl_rend_state state; - int32_t index; + gl_rend_state_index index; render_data& data; uniform_value& shader_flags; - render_data_context(int32_t index); + render_data_context(gl_rend_state_index index); void get_scene_fog_params(render_data_context::fog_params& value); void get_scene_light(vec4* light_env_stage_diffuse, diff --git a/src/CRE/render_manager.cpp b/src/CRE/render_manager.cpp index ab3a73a2..9aeac49d 100644 --- a/src/CRE/render_manager.cpp +++ b/src/CRE/render_manager.cpp @@ -292,7 +292,7 @@ namespace rndr { static const vec4 color_clear = 0.0f; { - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); rend_data_ctx.state.get(); rend_data_ctx.state.bind_framebuffer(0); @@ -308,7 +308,7 @@ namespace rndr { } { - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); rend_data_ctx.state.get(); rend_data_ctx.state.begin_event("rndpass_render_all_pass::Caller::execute_pre3d"); for (int32_t i = RND_PASSID_SHADOW; i <= RND_PASSID_CLEAR; i++) @@ -317,7 +317,7 @@ namespace rndr { } { - render_data_context rend_data_ctx(1); + render_data_context rend_data_ctx(GL_REND_STATE_3D); rend_data_ctx.state.get(); rend_data_ctx.state.begin_event("rndpass_render_all_pass::Caller::execute_3d"); for (int32_t i = RND_PASSID_PRE_SPRITE; i <= RND_PASSID_3D; i++) @@ -326,7 +326,7 @@ namespace rndr { } { - render_data_context rend_data_ctx(2); + render_data_context rend_data_ctx(GL_REND_STATE_2D); rend_data_ctx.state.get(); rend_data_ctx.state.begin_event("rndpass_render_all_pass::Caller::execute_2d"); for (int32_t i = RND_PASSID_SHOW_VECTOR; i <= RND_PASSID_12; i++) @@ -337,7 +337,7 @@ namespace rndr { rctx_ptr->disp_manager->check_vertex_arrays(); sprite_manager_post_draw(); - render_data_context rend_data_ctx(3); + render_data_context rend_data_ctx(GL_REND_STATE_POST_2D); rend_data_ctx.state.get(); rend_data_ctx.state.bind_vertex_array(0); rend_data_ctx.state.disable_primitive_restart(); @@ -352,7 +352,7 @@ namespace rndr { } void RenderManager::rndpass_post_proc() { - render_data_context rend_data_ctx(3); + render_data_context rend_data_ctx(GL_REND_STATE_POST_2D); rend_data_ctx.state.begin_event("rndpass_post_proc"); rctx_ptr->post_proc(); render->post_proc(); @@ -361,7 +361,7 @@ namespace rndr { } void RenderManager::rndpass_pre_proc() { - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); rend_data_ctx.state.begin_event("rndpass_pre_proc"); render->pre_proc(rend_data_ctx); Glitter::glt_particle_manager->CalcDisp(); diff --git a/src/ReDIVA/app.cpp b/src/ReDIVA/app.cpp index f38018d6..ac752c1b 100644 --- a/src/ReDIVA/app.cpp +++ b/src/ReDIVA/app.cpp @@ -459,7 +459,7 @@ int32_t app_main(const app_init_struct& ais) { Vulkan::current_command_buffer = cb; } - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); rend_data_ctx.state.set_viewport(0, 0, width, height); rend_data_ctx.state.disable_blend(); rend_data_ctx.state.disable_depth_test(); @@ -765,7 +765,7 @@ static render_context* render_context_load() { rctx_ptr = rctx; gl_state.get(); - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); rend_data_ctx.state.get(); data_struct* aft_data = &data_list[DATA_AFT]; @@ -1546,7 +1546,7 @@ static void render_context_disp(render_context* rctx) { static const GLfloat depth_clear = 1.0f; static const GLint stencil_clear = 0; - render_data_context pre_rend_data_ctx(0); + render_data_context pre_rend_data_ctx(GL_REND_STATE_PRE_3D); pre_rend_data_ctx.state.get(); pre_rend_data_ctx.state.set_depth_mask(GL_TRUE); pre_rend_data_ctx.state.set_stencil_mask(0xFF); @@ -1559,7 +1559,7 @@ static void render_context_disp(render_context* rctx) { rctx->disp(); - render_data_context post_rend_data_ctx(3); + render_data_context post_rend_data_ctx(GL_REND_STATE_POST_2D); #if DISPLAY_IBL if (display_ibl) { diff --git a/src/ReDIVA/graphics/shadow.cpp b/src/ReDIVA/graphics/shadow.cpp index 914ee529..7d7d044a 100644 --- a/src/ReDIVA/graphics/shadow.cpp +++ b/src/ReDIVA/graphics/shadow.cpp @@ -217,7 +217,7 @@ void ShadowDw::ShowTextureCallback(dw::Widget* data) { dw::Button* button = dynamic_cast(data); if (button) { shadow_dw->shadow_ptr->show_texture = button->value; - render_data_context rend_data_ctx(0); + render_data_context rend_data_ctx(GL_REND_STATE_PRE_3D); shadow_dw->shadow_ptr->clear_textures(rend_data_ctx.state); } } diff --git a/src/ReDIVA/x_pv_game.cpp b/src/ReDIVA/x_pv_game.cpp index 3154f314..d663f421 100644 --- a/src/ReDIVA/x_pv_game.cpp +++ b/src/ReDIVA/x_pv_game.cpp @@ -8178,7 +8178,7 @@ void x_pv_game::basic() { #if BAKE_VIDEO d3d_gl_fbo_tex.lock(); - render_data_context rend_data_ctx(3); + render_data_context rend_data_ctx(GL_REND_STATE_POST_2D); rend_data_ctx.state.bind_framebuffer(d3d_gl_fbo_tex.gl_fbo); rend_data_ctx.state.active_bind_texture_2d(0, tex->glid); rend_data_ctx.state.bind_sampler(0, rctx_ptr->render_samplers[1]);