diff --git a/res/ft_shaders.farc b/res/ft_shaders.farc
new file mode 100644
index 0000000..eaf2470
Binary files /dev/null and b/res/ft_shaders.farc differ
diff --git a/src/DivaGL/DivaGL.rc b/src/DivaGL/DivaGL.rc
index caea5e7..2a12ab7 100644
--- a/src/DivaGL/DivaGL.rc
+++ b/src/DivaGL/DivaGL.rc
@@ -1,13 +1,4 @@
-#define IDR_VERSION2 101
-
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
+#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
@@ -44,3 +35,5 @@ BEGIN
VALUE "Translation", 0x9, 1200
END
END
+
+IDR_FT_SHADERS_FARC1 ft_shaders_farc "..\\..\\res\\ft_shaders.farc"
diff --git a/src/DivaGL/DivaGL.vcxproj b/src/DivaGL/DivaGL.vcxproj
index 8d9fbdd..d77eac3 100644
--- a/src/DivaGL/DivaGL.vcxproj
+++ b/src/DivaGL/DivaGL.vcxproj
@@ -274,9 +274,8 @@ del "$(SolutionDir)bin\$(TargetName).lib"
-
-
-
+
+
@@ -318,10 +317,10 @@ del "$(SolutionDir)bin\$(TargetName).lib"
+
-
-
-
+
+
@@ -339,5 +338,8 @@ del "$(SolutionDir)bin\$(TargetName).lib"
{4c9636b9-e5b6-41e5-9afc-5b33cc9633de}
+
+
+
\ No newline at end of file
diff --git a/src/DivaGL/Glitter/render_scene.cpp b/src/DivaGL/Glitter/render_scene.cpp
index 30f0423..a3c7df1 100644
--- a/src/DivaGL/Glitter/render_scene.cpp
+++ b/src/DivaGL/Glitter/render_scene.cpp
@@ -6,7 +6,7 @@
#include "glitter.hpp"
#include "../gl_state.hpp"
#include "../render_context.hpp"
-#include "../shader_glsl_ft.hpp"
+#include "../shader_ft.hpp"
#include "../wrap.hpp"
namespace Glitter {
diff --git a/src/DivaGL/dllmain.cpp b/src/DivaGL/dllmain.cpp
index cb8be0a..a229a9b 100644
--- a/src/DivaGL/dllmain.cpp
+++ b/src/DivaGL/dllmain.cpp
@@ -8,7 +8,6 @@
#include "hook.hpp"
#include "inject.hpp"
#include "print.hpp"
-#include "shader_table.hpp"
#include "wrap.hpp"
#include
#include
@@ -88,6 +87,7 @@ void FASTCALL divagl_main() {
#if defined(DINPUT8_DLL)
load_original_dll();
LoadLibraryW(L"plugins\\DivaSound.dva");
+ LoadLibraryW(L"plugins\\Patches.dva");
LoadLibraryW(L"plugins\\TLAC.dva");
#endif
//Sleep(5000);
diff --git a/src/DivaGL/hook.cpp b/src/DivaGL/hook.cpp
index e9ce94c..2b9f3de 100644
--- a/src/DivaGL/hook.cpp
+++ b/src/DivaGL/hook.cpp
@@ -9,7 +9,8 @@
#include "rob/rob.hpp"
#include "auth_3d.hpp"
#include "camera.hpp"
-#include "shader_glsl_ft.hpp"
+#include "resource.h"
+#include "shader_ft.hpp"
#include "sprite.hpp"
#include "stage.hpp"
#include "task_effect.hpp"
@@ -87,6 +88,25 @@ HOOK(void, FASTCALL, rndr__RenderManager__render_all, 0x0000000140502CA0) {
render_manager->render_all();
}
+HOOK(void, FASTCALL, shader_free, 0x00000001405E4DB0) {
+ shaders_ft.unload();
+}
+
+HOOK(void, FASTCALL, shader_load_all_shaders, 0x00000001405E4FC0) {
+ extern size_t dll_handle;
+ HRSRC res = FindResourceA((HMODULE)dll_handle, MAKEINTRESOURCEA(IDR_FT_SHADERS_FARC1), "ft_shaders_farc");
+ if (res) {
+ DWORD size = SizeofResource((HMODULE)dll_handle, res);
+ HGLOBAL data = LoadResource((HMODULE)dll_handle, res);
+
+ farc f;
+ f.read(data, size);
+ shaders_ft.load(&f, false, "ft", shader_ft_table, shader_ft_table_size,
+ shader_ft_bind_func_table, shader_ft_bind_func_table_size,
+ shader_ft_get_index_by_name);
+ }
+}
+
HOOK(int32_t, FASTCALL, shader_get_index_by_name, 0x00000001405E4ED0, const char* name) {
return shaders_ft.get_index_by_name(name);
}
@@ -117,6 +137,8 @@ void hook_funcs() {
INSTALL_HOOK(rndr__RenderManager__render_ctrl);
INSTALL_HOOK(rndr__RenderManager__render_all);
+ INSTALL_HOOK(shader_free);
+ INSTALL_HOOK(shader_load_all_shaders);
INSTALL_HOOK(shader_get_index_by_name);
INSTALL_HOOK(env_set_blend_color);
diff --git a/src/DivaGL/inject.cpp b/src/DivaGL/inject.cpp
index 8779d7f..d957cc1 100644
--- a/src/DivaGL/inject.cpp
+++ b/src/DivaGL/inject.cpp
@@ -6,8 +6,7 @@
#include "inject.hpp"
#include "gl.hpp"
#include "print.hpp"
-#include "shader_table.hpp"
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include "sprite.hpp"
#include
@@ -54,10 +53,6 @@ void inject_uint64_t(void* address, uint64_t data) {
extern size_t glut_handle;
static patch_struct patch_data[] = {
- { (void*)0x00000001405E4CE0, (uint64_t)&shader_set, },
- { (void*)0x00000001405E4FC0, (uint64_t)&shader_load_all_shaders, },
- { (void*)0x00000001405E4DB0, (uint64_t)&shader_free, },
- { (void*)0x00000001405E4B50, (uint64_t)&shader_bind, },
{ (void*)0x00000001401D3860, (uint64_t)&printf_proxy, },
{ (void*)0x00000001400DE640, (uint64_t)&printf_proxy, },
{ (void*)0x0000000140442FB4, (uint64_t)&gl_state_get, },
@@ -87,13 +82,6 @@ void inject_patches() {
*(uint64_t*)&buf[0x02] = (uint64_t)&glut_create_context;
inject_data((void*)(glut_handle + 0x0000A970), buf, 0x0C);
- inject_uint64_t((void*)&shader_name_bind_func_table[0].bind_func, (uint64_t)&shader_bind_blinn);
- inject_uint64_t((void*)&shader_name_bind_func_table[1].bind_func, (uint64_t)&shader_bind_cloth);
- inject_uint64_t((void*)&shader_name_bind_func_table[2].bind_func, (uint64_t)&shader_bind_hair);
- inject_uint64_t((void*)&shader_name_bind_func_table[3].bind_func, (uint64_t)&shader_bind_membrane);
- inject_uint64_t((void*)&shader_name_bind_func_table[4].bind_func, (uint64_t)&shader_bind_eye_ball);
- inject_uint64_t((void*)&shader_name_bind_func_table[5].bind_func, (uint64_t)&shader_bind_tone_map);
-
// Patch font shader index
inject_uint32_t((void*)0x00000001401982D8, SHADER_FT_FONT);
}
diff --git a/src/DivaGL/mdl/disp_manager.cpp b/src/DivaGL/mdl/disp_manager.cpp
index c9b139f..98565f4 100644
--- a/src/DivaGL/mdl/disp_manager.cpp
+++ b/src/DivaGL/mdl/disp_manager.cpp
@@ -7,7 +7,7 @@
#include "../gl_state.hpp"
#include "../object.hpp"
#include "../render_manager.hpp"
-#include "../shader_glsl_ft.hpp"
+#include "../shader_ft.hpp"
#include "../sprite.hpp"
#include "../stage.hpp"
#include "../uniform.hpp"
@@ -1449,7 +1449,7 @@ namespace mdl {
uniform_value_reset();
gl_state_bind_vertex_array(0);
- shader_glsl::unbind();
+ shader::unbind();
gl_state_set_blend_func(GL_ONE, GL_ZERO);
for (int32_t i = 0; i < 5; i++)
gl_state_bind_sampler(i, 0);
@@ -1533,7 +1533,7 @@ namespace mdl {
}
uniform_value_reset();
- shader_glsl::unbind();
+ shader::unbind();
gl_state_set_blend_func(GL_ONE, GL_ZERO);
}
diff --git a/src/DivaGL/mdl/draw_object.cpp b/src/DivaGL/mdl/draw_object.cpp
index c9101e2..3dafba6 100644
--- a/src/DivaGL/mdl/draw_object.cpp
+++ b/src/DivaGL/mdl/draw_object.cpp
@@ -5,7 +5,7 @@
#include "draw_object.hpp"
#include "../light_param/light.hpp"
-#include "../shader_glsl_ft.hpp"
+#include "../shader_ft.hpp"
#include "../texture.hpp"
static bool draw_object_blend_set(
@@ -146,7 +146,7 @@ namespace mdl {
shaders_ft.draw_arrays(GL_LINES, 0, etc->count);
break;
}
- shader_glsl::unbind();
+ shader::unbind();
uniform_value_reset();
rctx->obj_batch.g_material_state_diffuse = g_material_state_diffuse;
diff --git a/src/DivaGL/render.cpp b/src/DivaGL/render.cpp
index 3366236..261909a 100644
--- a/src/DivaGL/render.cpp
+++ b/src/DivaGL/render.cpp
@@ -8,7 +8,7 @@
#include "gl_state.hpp"
#include "render_context.hpp"
#include "render_context.hpp"
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include "texture.hpp"
extern bool task_stage_is_modern;
@@ -188,7 +188,7 @@ namespace rndr {
render_post_width_scale, render_post_height_scale,
0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
}
- shader_glsl::unbind();
+ shader::unbind();
for (int32_t i = 0; i < 8; i++)
gl_state_bind_sampler(i, 0);
@@ -207,7 +207,7 @@ namespace rndr {
}
void Render::calc_exposure_chara_data() {
- shader_glsl::unbind();
+ shader::unbind();
gl_state_set_color_mask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
gl_state_set_depth_mask(GL_FALSE);
diff --git a/src/DivaGL/render_manager.cpp b/src/DivaGL/render_manager.cpp
index 8746ae8..61d1cea 100644
--- a/src/DivaGL/render_manager.cpp
+++ b/src/DivaGL/render_manager.cpp
@@ -14,7 +14,7 @@
#include "render.hpp"
#include "render_context.hpp"
#include "render_texture.hpp"
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include "sprite.hpp"
#include "stage_param.hpp"
#include "task_effect.hpp"
@@ -343,7 +343,7 @@ namespace rndr {
glClearDLL(GL_COLOR_BUFFER_BIT);
}
}
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -439,7 +439,7 @@ namespace rndr {
}
draw_pass_sss_filter(sss);
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -512,7 +512,7 @@ namespace rndr {
glClearDLL(GL_COLOR_BUFFER_BIT);
glClearColorDLL(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
}
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -559,7 +559,7 @@ namespace rndr {
glClearDLL(GL_COLOR_BUFFER_BIT);
glClearColorDLL(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
}
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -570,7 +570,7 @@ namespace rndr {
for (draw_pre_process& i : pre_process)
if (i.func)
i.func(i.data);
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -645,7 +645,7 @@ namespace rndr {
gl_state_disable_blend();
gl_state_enable_depth_test();
gl_state_set_depth_mask(GL_TRUE);
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_get_error();
gl_state_end_event();
@@ -831,7 +831,7 @@ namespace rndr {
if (shadow)
draw_pass_3d_shadow_reset();
pass_sprite_surf();
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
}
@@ -923,7 +923,7 @@ namespace rndr {
0, 0, rctx->sprite_width, rctx->sprite_height,
rctx->screen_x_offset, rctx->screen_y_offset,
rctx->sprite_width, rctx->sprite_height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
- shader_glsl::unbind();
+ shader::unbind();
gl_state_bind_framebuffer(0);
gl_state_end_event();
}
@@ -1244,7 +1244,7 @@ static void draw_pass_shadow_filter(RenderTexture* a1, RenderTexture* a2,
gl_state_active_bind_texture_2d(0, v9);
gl_state_bind_vertex_array(rctx->common_vao);
shaders_ft.draw_arrays(GL_TRIANGLE_STRIP, 0, 4);
- shader_glsl::unbind();
+ shader::unbind();
texture_params_restore(&tex_params[0], &tex_params[1], 0);
}
diff --git a/src/DivaGL/resource.h b/src/DivaGL/resource.h
new file mode 100644
index 0000000..3c488bf
--- /dev/null
+++ b/src/DivaGL/resource.h
@@ -0,0 +1,11 @@
+#define IDR_VERSION2 101
+#define IDR_FT_SHADERS_FARC1 102
+
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 103
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/src/DivaGL/shader_glsl.cpp b/src/DivaGL/shader.cpp
similarity index 91%
rename from src/DivaGL/shader_glsl.cpp
rename to src/DivaGL/shader.cpp
index 6bbe7aa..86ab8d6 100644
--- a/src/DivaGL/shader_glsl.cpp
+++ b/src/DivaGL/shader.cpp
@@ -3,7 +3,7 @@
GitHub/GitLab: korenkonder
*/
-#include "shader_glsl.hpp"
+#include "shader.hpp"
#include "../KKdLib/io/file_stream.hpp"
#include "../KKdLib/io/path.hpp"
#include "../KKdLib/hash.hpp"
@@ -32,20 +32,20 @@ static GLuint shader_compile(const char* vert, const char* frag, const char* vp,
static GLuint shader_compile_binary(const char* vert, const char* frag, const char* vp, const char* fp,
program_binary* bin, GLsizei* buffer_size, void** binary);
static bool shader_load_binary_shader(program_binary* bin, GLuint* program);
-static void shader_glsl_update_data(shader_glsl_set_data* set);
+static void shader_update_data(shader_set_data* set);
-int32_t shader_glsl::bind(shader_glsl_set_data* set, uint32_t sub_index) {
+int32_t shader::bind(shader_set_data* set, uint32_t sub_index) {
set->curr_shader = 0;
if (num_sub < 1)
return -1;
int32_t sub_shader_index = 0;
- for (shader_glsl_sub* i = sub; i->sub_index != sub_index; i++)
+ for (shader_sub* i = sub; i->sub_index != sub_index; i++)
if (++sub_shader_index >= num_sub)
return -1;
- shader_glsl_sub* sub_shader = &sub[sub_shader_index];
+ shader_sub* sub_shader = &sub[sub_shader_index];
int32_t unival_shad_curr = 1;
int32_t unival_shad = 0;
@@ -67,7 +67,7 @@ int32_t shader_glsl::bind(shader_glsl_set_data* set, uint32_t sub_index) {
}
}
- shader_glsl_sub_shader* shader = &sub_shader->shaders[unival_shad];
+ shader_sub_shader* shader = &sub_shader->shaders[unival_shad];
set->curr_shader = shader;
gl_state_use_program(shader->program);
@@ -78,7 +78,7 @@ int32_t shader_glsl::bind(shader_glsl_set_data* set, uint32_t sub_index) {
return 0;
}
-bool shader_glsl::parse_define(const char* data, char** temp, size_t* temp_size) {
+bool shader::parse_define(const char* data, char** temp, size_t* temp_size) {
if (!data)
return false;
@@ -120,7 +120,7 @@ bool shader_glsl::parse_define(const char* data, char** temp, size_t* temp_size)
return true;
}
-bool shader_glsl::parse_define(const char* data, int32_t num_uniform,
+bool shader::parse_define(const char* data, int32_t num_uniform,
int32_t* uniform_value, char** temp, size_t* temp_size) {
if (!data)
return false;
@@ -179,7 +179,7 @@ bool shader_glsl::parse_define(const char* data, int32_t num_uniform,
return true;
}
-char* shader_glsl::parse_include(char* data, farc* f) {
+char* shader::parse_include(char* data, farc* f) {
if (!data || !f)
return data;
@@ -290,25 +290,25 @@ char* shader_glsl::parse_include(char* data, farc* f) {
return temp_data;
}
-void shader_glsl::unbind() {
+void shader::unbind() {
gl_state_use_program(0);
}
-shader_glsl_set_data::shader_glsl_set_data() : size(), shaders(), curr_shader(),
+shader_set_data::shader_set_data() : size(), shaders(), curr_shader(),
primitive_restart(), primitive_restart_index(), get_index_by_name_func() {
}
-void shader_glsl_set_data::disable_primitive_restart() {
+void shader_set_data::disable_primitive_restart() {
primitive_restart = false;
}
-void shader_glsl_set_data::draw_arrays(GLenum mode, GLint first, GLsizei count) {
- shader_glsl_update_data(this);
+void shader_set_data::draw_arrays(GLenum mode, GLint first, GLsizei count) {
+ shader_update_data(this);
glDrawArraysDLL(mode, first, count);
}
-void shader_glsl_set_data::draw_elements(GLenum mode,
+void shader_set_data::draw_elements(GLenum mode,
GLsizei count, GLenum type, const void* indices) {
switch (mode) {
case GL_TRIANGLE_STRIP:
@@ -333,7 +333,7 @@ void shader_glsl_set_data::draw_elements(GLenum mode,
break;
}
- shader_glsl_update_data(this);
+ shader_update_data(this);
glDrawElementsDLL(mode, count, type, indices);
switch (mode) {
@@ -343,7 +343,7 @@ void shader_glsl_set_data::draw_elements(GLenum mode,
}
}
-void shader_glsl_set_data::draw_range_elements(GLenum mode,
+void shader_set_data::draw_range_elements(GLenum mode,
GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) {
switch (mode) {
case GL_TRIANGLE_STRIP:
@@ -368,7 +368,7 @@ void shader_glsl_set_data::draw_range_elements(GLenum mode,
break;
}
- shader_glsl_update_data(this);
+ shader_update_data(this);
glDrawRangeElements(mode, start, end, count, type, indices);
switch (mode) {
@@ -378,11 +378,11 @@ void shader_glsl_set_data::draw_range_elements(GLenum mode,
}
}
-void shader_glsl_set_data::enable_primitive_restart() {
+void shader_set_data::enable_primitive_restart() {
primitive_restart = true;
}
-int32_t shader_glsl_set_data::get_index_by_name(const char* name) {
+int32_t shader_set_data::get_index_by_name(const char* name) {
if (get_index_by_name_func) {
int32_t index = get_index_by_name_func(name);
if (index != -1)
@@ -395,9 +395,9 @@ int32_t shader_glsl_set_data::get_index_by_name(const char* name) {
return -1;
}
-void shader_glsl_set_data::load(farc* f, bool ignore_cache,
- const char* name, const shader_glsl_table* shaders_table, const size_t size,
- const shader_glsl_bind_func* bind_func_table, const size_t bind_func_table_size,
+void shader_set_data::load(farc* f, bool ignore_cache,
+ const char* name, const shader_table* shaders_table, const size_t size,
+ const shader_bind_func* bind_func_table, const size_t bind_func_table_size,
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name) {
if (!this || !f || !shaders_table || !size)
return;
@@ -433,22 +433,22 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
std::vector vec_vert;
std::vector vec_frag;
std::vector program_data_binary;
- shader_glsl* shaders = force_malloc(size);
+ shader* shaders = force_malloc(size);
this->shaders = shaders;
this->size = size;
for (size_t i = 0; i < size; i++) {
- shader_glsl* shader = &shaders[i];
+ shader* shader = &shaders[i];
shader->name = shaders_table[i].name;
shader->name_index = shaders_table[i].name_index;
shader->num_sub = shaders_table[i].num_sub;
- shader->sub = force_malloc(shader->num_sub);
+ shader->sub = force_malloc(shader->num_sub);
shader->num_uniform = shaders_table[i].num_uniform;
shader->use_uniform = shaders_table[i].use_uniform;
shader->use_permut = shaders_table[i].use_permut;
int32_t num_sub = shader->num_sub;
- const shader_glsl_sub_table* sub_table = shaders_table[i].sub;
- shader_glsl_sub* sub = shader->sub;
+ const shader_sub_table* sub_table = shaders_table[i].sub;
+ shader_sub* sub = shader->sub;
vec_vert.resize(shader->num_uniform);
vec_frag.resize(shader->num_uniform);
int32_t* vec_vert_data = vec_vert.data();
@@ -508,8 +508,8 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
}
strcat_s(shader_cache_file_name, sizeof(shader_cache_file_name), ".bin");
- vert_data = shader_glsl::parse_include(vert_data, f);
- frag_data = shader_glsl::parse_include(frag_data, f);
+ vert_data = shader::parse_include(vert_data, f);
+ frag_data = shader::parse_include(frag_data, f);
uint64_t vert_data_hash = hash_utf8_fnv1a64m(vert_data);
uint64_t frag_data_hash = hash_utf8_fnv1a64m(frag_data);
@@ -541,7 +541,7 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
if (!ignore_cache)
program_data_binary.reserve(unival_shad_count);
- shader_glsl_sub_shader* shaders = force_malloc(unival_shad_count);
+ shader_sub_shader* shaders = force_malloc(unival_shad_count);
sub->shaders = shaders;
if (shaders) {
strcpy_s(vert_buf, sizeof(vert_buf), sub_table->vp);
@@ -578,9 +578,9 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
}
if (!bin || !shader_load_binary_shader(bin, &shaders[k].program)) {
- bool vert_succ = shader_glsl::parse_define(vert_data, num_uniform,
+ bool vert_succ = shader::parse_define(vert_data, num_uniform,
vec_vert_data, &temp_vert, &temp_vert_size);
- bool frag_succ = shader_glsl::parse_define(frag_data, num_uniform,
+ bool frag_succ = shader::parse_define(frag_data, num_uniform,
vec_frag_data, &temp_frag, &temp_frag_size);
if (ignore_cache)
@@ -610,7 +610,7 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
}
else {
program_data_binary.reserve(1);
- shader_glsl_sub_shader* shaders = force_malloc();
+ shader_sub_shader* shaders = force_malloc();
sub->shaders = shaders;
if (shaders) {
strcpy_s(vert_buf, sizeof(vert_buf), sub_table->vp);
@@ -619,8 +619,8 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
strcat_s(frag_buf, sizeof(vert_buf), "..frag");
if (!bin || !shader_load_binary_shader(bin, &shaders[0].program)) {
- bool vert_succ = shader_glsl::parse_define(vert_data, &temp_vert, &temp_vert_size);
- bool frag_succ = shader_glsl::parse_define(frag_data, &temp_frag, &temp_frag_size);
+ bool vert_succ = shader::parse_define(vert_data, &temp_vert, &temp_vert_size);
+ bool frag_succ = shader::parse_define(frag_data, &temp_frag, &temp_frag_size);
if (ignore_cache)
shaders[0].program = shader_compile(vert_succ ? temp_vert : 0,
@@ -704,28 +704,28 @@ void shader_glsl_set_data::load(farc* f, bool ignore_cache,
this->get_index_by_name_func = get_index_by_name;
}
-void shader_glsl_set_data::set(uint32_t index) {
+void shader_set_data::set(uint32_t index) {
if (this && index && index != -1) {
- shader_glsl* shader = &shaders[index];
+ shader* shader = &shaders[index];
if (shader->bind_func)
shader->bind_func(this, shader);
else
shader->bind(this, shader->sub[0].sub_index);
}
else
- shader_glsl::unbind();
+ shader::unbind();
}
-void shader_glsl_set_data::unload() {
+void shader_set_data::unload() {
size_t size = this->size;
- shader_glsl* shaders = this->shaders;
+ shader* shaders = this->shaders;
for (size_t i = 0; i < size; i++) {
- shader_glsl* shader = &shaders[i];
+ shader* shader = &shaders[i];
if (!shader->sub)
continue;
int32_t num_sub = shader->num_sub;
- shader_glsl_sub* sub = shader->sub;
+ shader_sub* sub = shader->sub;
for (size_t j = 0; j < num_sub; j++, sub++) {
int32_t unival_shad_count = 1;
if (shader->num_uniform > 0) {
@@ -742,7 +742,7 @@ void shader_glsl_set_data::unload() {
}
if (sub->shaders) {
- shader_glsl_sub_shader* shaders = sub->shaders;
+ shader_sub_shader* shaders = sub->shaders;
for (size_t k = 0; k < unival_shad_count; k++)
glDeleteProgram(shaders[k].program);
free(shaders);
@@ -973,12 +973,12 @@ static bool shader_load_binary_shader(program_binary* bin, GLuint* program) {
return true;
}
-static void shader_glsl_update_data(shader_glsl_set_data* set) {
+static void shader_update_data(shader_set_data* set) {
if (!set)
return;
if (set->curr_shader) {
- shader_glsl_sub_shader* shader = set->curr_shader;
+ shader_sub_shader* shader = set->curr_shader;
if (shader->uniform_val_update) {
glUniform1iv(0, SHADER_MAX_UNIFORM_VALUES, (GLint*)shader->uniform_val);
shader->uniform_val_update = false;
diff --git a/src/DivaGL/shader_glsl.hpp b/src/DivaGL/shader.hpp
similarity index 76%
rename from src/DivaGL/shader_glsl.hpp
rename to src/DivaGL/shader.hpp
index b8bc9a0..6592e54 100644
--- a/src/DivaGL/shader_glsl.hpp
+++ b/src/DivaGL/shader.hpp
@@ -24,7 +24,7 @@
#define SHADER_MAX_UNIFORM_BLOCK_SIZE 65536
#define SHADER_MAX_UNIFORM_VALUES 16
-struct shader_glsl_sub_table {
+struct shader_sub_table {
uint32_t sub_index;
const int32_t* vp_unival_max;
const int32_t* fp_unival_max;
@@ -32,52 +32,52 @@ struct shader_glsl_sub_table {
const char* fp;
};
-struct shader_glsl_table {
+struct shader_table {
const char* name;
uint32_t name_index;
int32_t num_sub;
- const shader_glsl_sub_table* sub;
+ const shader_sub_table* sub;
int32_t num_uniform;
const uniform_name* use_uniform;
const bool* use_permut;
};
-struct shader_glsl;
-struct shader_glsl_set_data;
+struct shader;
+struct shader_set_data;
typedef int32_t (*PFNSHADERGLSLGETINDEXFUNCPROC)(const char* name);
-typedef void (*PFNSHADERGLSLBINDFUNCPROC)(shader_glsl_set_data* set, shader_glsl* shad);
+typedef void (*PFNSHADERGLSLBINDFUNCPROC)(shader_set_data* set, shader* shad);
-struct shader_glsl_bind_func {
+struct shader_bind_func {
uint32_t name_index;
PFNSHADERGLSLBINDFUNCPROC bind_func;
};
-struct shader_glsl_sub_shader {
+struct shader_sub_shader {
GLuint program;
int32_t uniform_val[SHADER_MAX_UNIFORM_VALUES];
bool uniform_val_update;
};
-struct shader_glsl_sub {
+struct shader_sub {
uint32_t sub_index;
const int32_t* vp_unival_max;
const int32_t* fp_unival_max;
- shader_glsl_sub_shader* shaders;
+ shader_sub_shader* shaders;
};
-struct shader_glsl {
+struct shader {
const char* name;
uint32_t name_index;
int32_t num_sub;
- shader_glsl_sub* sub;
+ shader_sub* sub;
int32_t num_uniform;
const uniform_name* use_uniform;
const bool* use_permut;
PFNSHADERGLSLBINDFUNCPROC bind_func;
- int32_t bind(shader_glsl_set_data* set, uint32_t sub_index);
+ int32_t bind(shader_set_data* set, uint32_t sub_index);
static bool parse_define(const char* data, char** temp, size_t* temp_size);
static bool parse_define(const char* data, int32_t num_uniform,
@@ -86,16 +86,16 @@ struct shader_glsl {
static void unbind();
};
-struct shader_glsl_set_data {
+struct shader_set_data {
size_t size;
- shader_glsl* shaders;
- shader_glsl_sub_shader* curr_shader;
+ shader* shaders;
+ shader_sub_shader* curr_shader;
GLboolean primitive_restart;
GLuint primitive_restart_index;
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name_func;
- shader_glsl_set_data();
+ shader_set_data();
void disable_primitive_restart();
void draw_arrays(GLenum mode, GLint first, GLsizei count);
@@ -106,8 +106,8 @@ struct shader_glsl_set_data {
void enable_primitive_restart();
int32_t get_index_by_name(const char* name);
void load(farc* f, bool ignore_cache, const char* name,
- const shader_glsl_table* shaders_table, const size_t size,
- const shader_glsl_bind_func* bind_func_table, const size_t bind_func_table_size,
+ const shader_table* shaders_table, const size_t size,
+ const shader_bind_func* bind_func_table, const size_t bind_func_table_size,
PFNSHADERGLSLGETINDEXFUNCPROC get_index_by_name);
void set(uint32_t index);
void unload();
diff --git a/src/DivaGL/shader_glsl_ft.cpp b/src/DivaGL/shader_ft.cpp
similarity index 90%
rename from src/DivaGL/shader_glsl_ft.cpp
rename to src/DivaGL/shader_ft.cpp
index 46b7528..60c302b 100644
--- a/src/DivaGL/shader_glsl_ft.cpp
+++ b/src/DivaGL/shader_ft.cpp
@@ -3,7 +3,7 @@
GitHub/GitLab: korenkonder
*/
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include "../KKdLib/str_utils.hpp"
#include "gl_state.hpp"
#include "render_context.hpp"
@@ -1002,7 +1002,7 @@ static const int32_t sprite_fpt_unival_max[] = {
3, 3, 2,
};
-static const shader_glsl_sub_table BLINN_table[] = {
+static const shader_sub_table BLINN_table[] = {
{
SHADER_FT_SUB_BLINN_VERT,
blinn_vert_vpt_unival_max,
@@ -1019,7 +1019,7 @@ static const shader_glsl_sub_table BLINN_table[] = {
},
};
-static const shader_glsl_sub_table ITEM_table[] = {
+static const shader_sub_table ITEM_table[] = {
{
SHADER_FT_SUB_ITEM_BLINN,
item_blinn_vpt_unival_max,
@@ -1029,7 +1029,7 @@ static const shader_glsl_sub_table ITEM_table[] = {
},
};
-static const shader_glsl_sub_table STAGE_table[] = {
+static const shader_sub_table STAGE_table[] = {
{
SHADER_FT_SUB_STAGE_BLINN,
stage_blinn_vpt_unival_max,
@@ -1039,7 +1039,7 @@ static const shader_glsl_sub_table STAGE_table[] = {
},
};
-static const shader_glsl_sub_table SKIN_table[] = {
+static const shader_sub_table SKIN_table[] = {
{
SHADER_FT_SUB_SKIN_DEFAULT,
skin_default_vpt_unival_max,
@@ -1049,7 +1049,7 @@ static const shader_glsl_sub_table SKIN_table[] = {
},
};
-static const shader_glsl_sub_table SSS_SKIN_table[] = {
+static const shader_sub_table SSS_SKIN_table[] = {
{
SHADER_FT_SUB_SSS_SKIN,
sss_skin_vpt_unival_max,
@@ -1059,7 +1059,7 @@ static const shader_glsl_sub_table SSS_SKIN_table[] = {
},
};
-/*static const shader_glsl_sub_table SSS_FILT_table[] = {
+/*static const shader_sub_table SSS_FILT_table[] = {
{
SHADER_FT_SUB_SSS_FILTER,
sss_filter_vpt_unival_max,
@@ -1069,7 +1069,7 @@ static const shader_glsl_sub_table SSS_SKIN_table[] = {
},
};*/
-static const shader_glsl_sub_table SSS_FILT_table[] = {
+static const shader_sub_table SSS_FILT_table[] = {
{
SHADER_FT_SUB_SSS_FILTER_MIN,
sss_filter_min_vpt_unival_max,
@@ -1093,7 +1093,7 @@ static const shader_glsl_sub_table SSS_FILT_table[] = {
},
};
-/*static const shader_glsl_sub_table HAIR_table[] = {
+/*static const shader_sub_table HAIR_table[] = {
{
SHADER_FT_SUB_HAIR_DEFAULT,
hair_default_vpt_unival_max,
@@ -1117,7 +1117,7 @@ static const shader_glsl_sub_table SSS_FILT_table[] = {
},
};*/
-static const shader_glsl_sub_table HAIR_table[] = {
+static const shader_sub_table HAIR_table[] = {
{
SHADER_FT_SUB_HAIR_DEFAULT,
hair_default_vpt_unival_max,
@@ -1134,7 +1134,7 @@ static const shader_glsl_sub_table HAIR_table[] = {
},
};
-static const shader_glsl_sub_table CLOTH_table[] = {
+static const shader_sub_table CLOTH_table[] = {
{
SHADER_FT_SUB_CLOTH_DEFAULT,
cloth_default_vpt_unival_max,
@@ -1158,7 +1158,7 @@ static const shader_glsl_sub_table CLOTH_table[] = {
},
};
-static const shader_glsl_sub_table TIGHTS_table[] = {
+static const shader_sub_table TIGHTS_table[] = {
{
SHADER_FT_SUB_TIGHTS,
tights_vpt_unival_max,
@@ -1168,7 +1168,7 @@ static const shader_glsl_sub_table TIGHTS_table[] = {
},
};
-static const shader_glsl_sub_table SKY_table[] = {
+static const shader_sub_table SKY_table[] = {
{
SHADER_FT_SUB_SKY_DEFAULT,
sky_default_vpt_unival_max,
@@ -1178,7 +1178,7 @@ static const shader_glsl_sub_table SKY_table[] = {
},
};
-/*static const shader_glsl_sub_table EYEBALL_table[] = {
+/*static const shader_sub_table EYEBALL_table[] = {
{
SHADER_FT_SUB_EYE_BALL,
eye_ball_vpt_unival_max,
@@ -1188,7 +1188,7 @@ static const shader_glsl_sub_table SKY_table[] = {
},
};*/
-/*static const shader_glsl_sub_table EYELENS_table[] = {
+/*static const shader_sub_table EYELENS_table[] = {
{
SHADER_FT_SUB_EYE_LENS,
eye_lens_vpt_unival_max,
@@ -1198,7 +1198,7 @@ static const shader_glsl_sub_table SKY_table[] = {
},
};*/
-static const shader_glsl_sub_table GLASEYE_table[] = {
+static const shader_sub_table GLASEYE_table[] = {
{
SHADER_FT_SUB_GLASS_EYE,
glass_eye_vpt_unival_max,
@@ -1208,7 +1208,7 @@ static const shader_glsl_sub_table GLASEYE_table[] = {
},
};
-/*static const shader_glsl_sub_table MEMBRAN_table[] = {
+/*static const shader_sub_table MEMBRAN_table[] = {
{
SHADER_FT_SUB_MEMBRANE,
membrane_vpt_unival_max,
@@ -1218,7 +1218,7 @@ static const shader_glsl_sub_table GLASEYE_table[] = {
},
};*/
-/*static const shader_glsl_sub_table SHDMAP_table[] = {
+/*static const shader_sub_table SHDMAP_table[] = {
{
SHADER_FT_SUB_SHADOWMAP,
shadowmap_vpt_unival_max,
@@ -1228,7 +1228,7 @@ static const shader_glsl_sub_table GLASEYE_table[] = {
},
};*/
-/*static const shader_glsl_sub_table ESM_table[] = {
+/*static const shader_sub_table ESM_table[] = {
{
SHADER_FT_SUB_ESM,
esm_vpt_unival_max,
@@ -1238,7 +1238,7 @@ static const shader_glsl_sub_table GLASEYE_table[] = {
},
};*/
-static const shader_glsl_sub_table ESMGAUSS_table[] = {
+static const shader_sub_table ESMGAUSS_table[] = {
{
SHADER_FT_SUB_ESM_GAUSS,
esm_gauss_vpt_unival_max,
@@ -1248,7 +1248,7 @@ static const shader_glsl_sub_table ESMGAUSS_table[] = {
},
};
-/*static const shader_glsl_sub_table ESMFILT_table[] = {
+/*static const shader_sub_table ESMFILT_table[] = {
{
SHADER_FT_SUB_ESM_FILTER,
esm_filter_vpt_unival_max,
@@ -1258,7 +1258,7 @@ static const shader_glsl_sub_table ESMGAUSS_table[] = {
},
};*/
-static const shader_glsl_sub_table ESMFILT_table[] = {
+static const shader_sub_table ESMFILT_table[] = {
{
SHADER_FT_SUB_ESM_FILTER_MIN,
esm_filter_min_vpt_unival_max,
@@ -1275,7 +1275,7 @@ static const shader_glsl_sub_table ESMFILT_table[] = {
},
};
-static const shader_glsl_sub_table LITPROJ_table[] = {
+static const shader_sub_table LITPROJ_table[] = {
{
SHADER_FT_SUB_LIT_PROJ,
lit_proj_vpt_unival_max,
@@ -1285,7 +1285,7 @@ static const shader_glsl_sub_table LITPROJ_table[] = {
},
};
-static const shader_glsl_sub_table SIMPLE_table[] = {
+static const shader_sub_table SIMPLE_table[] = {
{
SHADER_FT_SUB_SIMPLE,
simple_vpt_unival_max,
@@ -1295,7 +1295,7 @@ static const shader_glsl_sub_table SIMPLE_table[] = {
},
};
-static const shader_glsl_sub_table SIL_table[] = {
+static const shader_sub_table SIL_table[] = {
{
SHADER_FT_SUB_SILHOUETTE,
silhouette_vpt_unival_max,
@@ -1305,7 +1305,7 @@ static const shader_glsl_sub_table SIL_table[] = {
},
};
-static const shader_glsl_sub_table LAMBERT_table[] = {
+static const shader_sub_table LAMBERT_table[] = {
{
SHADER_FT_SUB_LAMBERT,
lambert_vpt_unival_max,
@@ -1315,7 +1315,7 @@ static const shader_glsl_sub_table LAMBERT_table[] = {
},
};
-static const shader_glsl_sub_table CONSTANT_table[] = {
+static const shader_sub_table CONSTANT_table[] = {
{
SHADER_FT_SUB_CONSTANT,
constant_vpt_unival_max,
@@ -1325,7 +1325,7 @@ static const shader_glsl_sub_table CONSTANT_table[] = {
},
};
-/*static const shader_glsl_sub_table PEEL_table[] = {
+/*static const shader_sub_table PEEL_table[] = {
{
SHADER_FT_SUB_PEEL,
peel_vpt_unival_max,
@@ -1335,7 +1335,7 @@ static const shader_glsl_sub_table CONSTANT_table[] = {
},
};*/
-static const shader_glsl_sub_table TONEMAP_table[] = {
+static const shader_sub_table TONEMAP_table[] = {
{
SHADER_FT_SUB_TONEMAP,
tone_map_vpt_unival_max,
@@ -1352,7 +1352,7 @@ static const shader_glsl_sub_table TONEMAP_table[] = {
},
};
-/*static const shader_glsl_sub_table REDUCE_table[] = {
+/*static const shader_sub_table REDUCE_table[] = {
{
SHADER_FT_SUB_REDUCE_TEX,
reduce_tex_vpt_unival_max,
@@ -1362,7 +1362,7 @@ static const shader_glsl_sub_table TONEMAP_table[] = {
},
};*/
-static const shader_glsl_sub_table REDUCE_table[] = {
+static const shader_sub_table REDUCE_table[] = {
{
SHADER_FT_SUB_REDUCE_TEX_REDUCE_2,
reduce_tex_reduce_2_vpt_unival_max,
@@ -1421,7 +1421,7 @@ static const shader_glsl_sub_table REDUCE_table[] = {
},
};
-/*static const shader_glsl_sub_table MAGNIFY_table[] = {
+/*static const shader_sub_table MAGNIFY_table[] = {
{
SHADER_FT_SUB_MAGNIFY,
magnify_vpt_unival_max,
@@ -1431,7 +1431,7 @@ static const shader_glsl_sub_table REDUCE_table[] = {
},
};*/
-static const shader_glsl_sub_table MAGNIFY_table[] = {
+static const shader_sub_table MAGNIFY_table[] = {
{
SHADER_FT_SUB_MAGNIFY_LINEAR,
magnify_linear_vpt_unival_max,
@@ -1469,7 +1469,7 @@ static const shader_glsl_sub_table MAGNIFY_table[] = {
},
};
-/*static const shader_glsl_sub_table MLAA_table[] = {
+/*static const shader_sub_table MLAA_table[] = {
{
SHADER_FT_SUB_MLAA,
mlaa_vpt_unival_max,
@@ -1479,7 +1479,7 @@ static const shader_glsl_sub_table MAGNIFY_table[] = {
},
};*/
-static const shader_glsl_sub_table MLAA_table[] = {
+static const shader_sub_table MLAA_table[] = {
{
SHADER_FT_SUB_MLAA_EDGE,
mlaa_edge_vpt_unival_max,
@@ -1503,7 +1503,7 @@ static const shader_glsl_sub_table MLAA_table[] = {
},
};
-static const shader_glsl_sub_table CONTOUR_table[] = {
+static const shader_sub_table CONTOUR_table[] = {
{
SHADER_FT_SUB_CONTOUR,
contour_vpt_unival_max,
@@ -1513,7 +1513,7 @@ static const shader_glsl_sub_table CONTOUR_table[] = {
},
};
-static const shader_glsl_sub_table CONTOUR_NPR_table[] = {
+static const shader_sub_table CONTOUR_NPR_table[] = {
{
SHADER_FT_SUB_CONTOUR_NPR,
contour_npr_vpt_unival_max,
@@ -1523,7 +1523,7 @@ static const shader_glsl_sub_table CONTOUR_NPR_table[] = {
},
};
-/*static const shader_glsl_sub_table EXPOSURE_table[] = {
+/*static const shader_sub_table EXPOSURE_table[] = {
{
SHADER_FT_SUB_EXPOSURE,
exposure_vpt_unival_max,
@@ -1533,7 +1533,7 @@ static const shader_glsl_sub_table CONTOUR_NPR_table[] = {
},
};*/
-static const shader_glsl_sub_table EXPOSURE_table[] = {
+static const shader_sub_table EXPOSURE_table[] = {
{
SHADER_FT_SUB_EXPOSURE_MINIFY,
exposure_minify_vpt_unival_max,
@@ -1557,7 +1557,7 @@ static const shader_glsl_sub_table EXPOSURE_table[] = {
},
};
-/*static const shader_glsl_sub_table GAUSS_table[] = {
+/*static const shader_sub_table GAUSS_table[] = {
{
SHADER_FT_SUB_PP_GAUSS,
pp_gauss_vpt_unival_max,
@@ -1567,7 +1567,7 @@ static const shader_glsl_sub_table EXPOSURE_table[] = {
},
};*/
-static const shader_glsl_sub_table GAUSS_table[] = {
+static const shader_sub_table GAUSS_table[] = {
{
SHADER_FT_SUB_PP_GAUSS_USUAL,
pp_gauss_usual_vpt_unival_max,
@@ -1584,7 +1584,7 @@ static const shader_glsl_sub_table GAUSS_table[] = {
},
};
-static const shader_glsl_sub_table SUN_table[] = {
+static const shader_sub_table SUN_table[] = {
{
SHADER_FT_SUB_SUN,
sun_vpt_unival_max,
@@ -1594,7 +1594,7 @@ static const shader_glsl_sub_table SUN_table[] = {
},
};
-static const shader_glsl_sub_table SUN_NO_TEXTURED_table[] = {
+static const shader_sub_table SUN_NO_TEXTURED_table[] = {
{
SHADER_FT_SUB_SUN_NO_TEXTURED,
sun_no_textured_vpt_unival_max,
@@ -1604,7 +1604,7 @@ static const shader_glsl_sub_table SUN_NO_TEXTURED_table[] = {
},
};
-/*static const shader_glsl_sub_table FADE_table[] = {
+/*static const shader_sub_table FADE_table[] = {
{
SHADER_FT_SUB_FADE,
fade_vpt_unival_max,
@@ -1614,7 +1614,7 @@ static const shader_glsl_sub_table SUN_NO_TEXTURED_table[] = {
},
};*/
-static const shader_glsl_sub_table WATER01_table[] = {
+static const shader_sub_table WATER01_table[] = {
{
SHADER_FT_SUB_WATER01,
water01_vpt_unival_max,
@@ -1624,7 +1624,7 @@ static const shader_glsl_sub_table WATER01_table[] = {
},
};
-/*static const shader_glsl_sub_table WATER02_table[] = {
+/*static const shader_sub_table WATER02_table[] = {
{
SHADER_FT_SUB_WATER02,
water02_vpt_unival_max,
@@ -1634,7 +1634,7 @@ static const shader_glsl_sub_table WATER01_table[] = {
},
};*/
-/*static const shader_glsl_sub_table WATRING_table[] = {
+/*static const shader_sub_table WATRING_table[] = {
{
SHADER_FT_SUB_WATER_RING,
water_ring_vpt_unival_max,
@@ -1644,7 +1644,7 @@ static const shader_glsl_sub_table WATER01_table[] = {
},
};*/
-static const shader_glsl_sub_table W_PTCL_table[] = {
+static const shader_sub_table W_PTCL_table[] = {
{
SHADER_FT_SUB_WATER_PARTICLE,
water_particle_vpt_unival_max,
@@ -1654,7 +1654,7 @@ static const shader_glsl_sub_table W_PTCL_table[] = {
},
};
-/*static const shader_glsl_sub_table SNOW_PT_table[] = {
+/*static const shader_sub_table SNOW_PT_table[] = {
{
SHADER_FT_SUB_SNOW_PARTICLE,
snow_particle_vpt_unival_max,
@@ -1664,7 +1664,7 @@ static const shader_glsl_sub_table W_PTCL_table[] = {
},
};*/
-static const shader_glsl_sub_table SNOW_PT_table[] = {
+static const shader_sub_table SNOW_PT_table[] = {
{
SHADER_FT_SUB_SNOW_PARTICLE,
snow_particle_vpt_unival_max,
@@ -1681,7 +1681,7 @@ static const shader_glsl_sub_table SNOW_PT_table[] = {
},
};
-static const shader_glsl_sub_table LEAF_PT_table[] = {
+static const shader_sub_table LEAF_PT_table[] = {
{
SHADER_FT_SUB_LEAF_PARTICLE,
leaf_particle_vpt_unival_max,
@@ -1691,7 +1691,7 @@ static const shader_glsl_sub_table LEAF_PT_table[] = {
},
};
-static const shader_glsl_sub_table STAR_table[] = {
+static const shader_sub_table STAR_table[] = {
{
SHADER_FT_SUB_STAR,
star_vpt_unival_max,
@@ -1708,7 +1708,7 @@ static const shader_glsl_sub_table STAR_table[] = {
},
};
-/*static const shader_glsl_sub_table SNORING_table[] = {
+/*static const shader_sub_table SNORING_table[] = {
{
SHADER_FT_SUB_SNOW_RING,
snow_ring_vpt_unival_max,
@@ -1718,7 +1718,7 @@ static const shader_glsl_sub_table STAR_table[] = {
},
};
-static const shader_glsl_sub_table SN_FOOT_table[] = {
+static const shader_sub_table SN_FOOT_table[] = {
{
SHADER_FT_SUB_SNOW_FOOTPRINT,
snow_footprint_vpt_unival_max,
@@ -1728,7 +1728,7 @@ static const shader_glsl_sub_table SN_FOOT_table[] = {
},
};
-static const shader_glsl_sub_table SN_TSL_table[] = {
+static const shader_sub_table SN_TSL_table[] = {
{
SHADER_FT_SUB_SNOW_TEX_SPACE_LIGHT,
snow_tex_space_light_vpt_unival_max,
@@ -1738,7 +1738,7 @@ static const shader_glsl_sub_table SN_TSL_table[] = {
},
};
-static const shader_glsl_sub_table SN_NRM_table[] = {
+static const shader_sub_table SN_NRM_table[] = {
{
SHADER_FT_SUB_SNOW_CALC_NORMAL,
snow_calc_normal_vpt_unival_max,
@@ -1748,7 +1748,7 @@ static const shader_glsl_sub_table SN_NRM_table[] = {
},
};*/
-static const shader_glsl_sub_table FLOOR_table[] = {
+static const shader_sub_table FLOOR_table[] = {
{
SHADER_FT_SUB_FLOOR,
floor_vpt_unival_max,
@@ -1758,7 +1758,7 @@ static const shader_glsl_sub_table FLOOR_table[] = {
},
};
-static const shader_glsl_sub_table PUDDLE_table[] = {
+static const shader_sub_table PUDDLE_table[] = {
{
SHADER_FT_SUB_PUDDLE,
puddle_vpt_unival_max,
@@ -1768,7 +1768,7 @@ static const shader_glsl_sub_table PUDDLE_table[] = {
},
};
-static const shader_glsl_sub_table S_REFL_table[] = {
+static const shader_sub_table S_REFL_table[] = {
{
SHADER_FT_SUB_SIMPLE_REFLECT,
simple_reflect_vpt_unival_max,
@@ -1778,7 +1778,7 @@ static const shader_glsl_sub_table S_REFL_table[] = {
},
};
-static const shader_glsl_sub_table S_REFR_table[] = {
+static const shader_sub_table S_REFR_table[] = {
{
SHADER_FT_SUB_SIMPLE_REFRACT,
simple_refract_vpt_unival_max,
@@ -1788,7 +1788,7 @@ static const shader_glsl_sub_table S_REFR_table[] = {
},
};
-static const shader_glsl_sub_table RIPEMIT_table[] = {
+static const shader_sub_table RIPEMIT_table[] = {
{
SHADER_FT_SUB_RIPPLE_EMIT,
ripple_emit_vpt_unival_max,
@@ -1798,7 +1798,7 @@ static const shader_glsl_sub_table RIPEMIT_table[] = {
},
};
-static const shader_glsl_sub_table RAIN_table[] = {
+static const shader_sub_table RAIN_table[] = {
{
SHADER_FT_SUB_RAIN,
rain_vpt_unival_max,
@@ -1808,7 +1808,7 @@ static const shader_glsl_sub_table RAIN_table[] = {
},
};
-/*static const shader_glsl_sub_table VOLLIT_table[] = {
+/*static const shader_sub_table VOLLIT_table[] = {
{
SHADER_FT_SUB_VOLUME_LIGHT,
volume_light_vpt_unival_max,
@@ -1818,7 +1818,7 @@ static const shader_glsl_sub_table RAIN_table[] = {
},
};*/
-/*static const shader_glsl_sub_table FENCE_table[] = {
+/*static const shader_sub_table FENCE_table[] = {
{
SHADER_FT_SUB_FENCE_ALPHA,
fence_alpha_vpt_unival_max,
@@ -1828,7 +1828,7 @@ static const shader_glsl_sub_table RAIN_table[] = {
},
};*/
-static const shader_glsl_sub_table RIPPLE_table[] = {
+static const shader_sub_table RIPPLE_table[] = {
{
SHADER_FT_SUB_RIPPLE,
ripple_vpt_unival_max,
@@ -1838,7 +1838,7 @@ static const shader_glsl_sub_table RIPPLE_table[] = {
},
};
-static const shader_glsl_sub_table FOGPTCL_table[] = {
+static const shader_sub_table FOGPTCL_table[] = {
{
SHADER_FT_SUB_FOG_PTCL,
fog_ptcl_vpt_unival_max,
@@ -1848,7 +1848,7 @@ static const shader_glsl_sub_table FOGPTCL_table[] = {
},
};
-static const shader_glsl_sub_table PARTICL_table[] = {
+static const shader_sub_table PARTICL_table[] = {
{
SHADER_FT_SUB_PARTICLE,
particle_vpt_unival_max,
@@ -1858,7 +1858,7 @@ static const shader_glsl_sub_table PARTICL_table[] = {
},
};
-static const shader_glsl_sub_table GLITTER_PT_table[] = {
+static const shader_sub_table GLITTER_PT_table[] = {
{
SHADER_FT_SUB_GLITTER_PARTICLE,
glitter_particle_vpt_unival_max,
@@ -1868,7 +1868,7 @@ static const shader_glsl_sub_table GLITTER_PT_table[] = {
},
};
-/*static const shader_glsl_sub_table SHOW_VEC_table[] = {
+/*static const shader_sub_table SHOW_VEC_table[] = {
{
SHADER_FT_SUB_SHOW_VECTOR,
show_vector_vpt_unival_max,
@@ -1878,7 +1878,7 @@ static const shader_glsl_sub_table GLITTER_PT_table[] = {
},
};*/
-static const shader_glsl_sub_table FONT_table[] = {
+static const shader_sub_table FONT_table[] = {
{
SHADER_FT_SUB_FONT,
font_vpt_unival_max,
@@ -1888,7 +1888,7 @@ static const shader_glsl_sub_table FONT_table[] = {
},
};
-static const shader_glsl_sub_table MOVIE_table[] = {
+static const shader_sub_table MOVIE_table[] = {
{
SHADER_FT_SUB_MOVIE,
movie_vpt_unival_max,
@@ -1898,7 +1898,7 @@ static const shader_glsl_sub_table MOVIE_table[] = {
},
};
-/*static const shader_glsl_sub_table IMGFILT_table[] = {
+/*static const shader_sub_table IMGFILT_table[] = {
{
SHADER_FT_SUB_IMGFILTER,
imgfilter_vpt_unival_max,
@@ -1908,7 +1908,7 @@ static const shader_glsl_sub_table MOVIE_table[] = {
},
};*/
-static const shader_glsl_sub_table IMGFILT_table[] = {
+static const shader_sub_table IMGFILT_table[] = {
{
SHADER_FT_SUB_BOX4,
box4_vpt_unival_max,
@@ -1932,7 +1932,7 @@ static const shader_glsl_sub_table IMGFILT_table[] = {
},
};
-static const shader_glsl_sub_table SPRITE_table[] = {
+static const shader_sub_table SPRITE_table[] = {
{
SHADER_FT_SUB_SPRITE,
sprite_vpt_unival_max,
@@ -2883,14 +2883,14 @@ struct glass_eye_struct {
{ \
#n, \
SHADER_FT_##n, \
- sizeof(n##_table) / sizeof(shader_glsl_sub_table), \
+ sizeof(n##_table) / sizeof(shader_sub_table), \
n##_table, \
sizeof(n##_uniform) / sizeof(uniform_name), \
n##_uniform, \
n##_permut, \
}
-const shader_glsl_table shader_ft_table[] = {
+const shader_table shader_ft_table[] = {
{
"SHADER_FFP",
SHADER_FT_FFP,
@@ -2969,27 +2969,27 @@ const shader_glsl_table shader_ft_table[] = {
#undef shader_table_struct
const size_t shader_ft_table_size =
- sizeof(shader_ft_table) / sizeof(shader_glsl_table);
+ sizeof(shader_ft_table) / sizeof(shader_table);
static void glass_eye_calc(glass_eye_struct* glass_eye);
static void glass_eye_set(glass_eye_struct* glass_eye);
-static void shader_bind_blinn(shader_glsl_set_data* set, shader_glsl* shad);
-static void shader_bind_cloth(shader_glsl_set_data* set, shader_glsl* shad);
-static void shader_bind_hair(shader_glsl_set_data* set, shader_glsl* shad);
-static void shader_bind_eye_ball(shader_glsl_set_data* set, shader_glsl* shad);
-static void shader_bind_tone_map(shader_glsl_set_data* set, shader_glsl* shad);
-static void shader_bind_sss_filter(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_esm_filter(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_reduce_tex(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_magnify(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_mlaa(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_exposure(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_gauss(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_snow_particle(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_star(shader_glsl_set_data* set, shader_glsl* shad); // Added
-static void shader_bind_imgfilter(shader_glsl_set_data* set, shader_glsl* shad); // Added
+static void shader_bind_blinn(shader_set_data* set, shader* shad);
+static void shader_bind_cloth(shader_set_data* set, shader* shad);
+static void shader_bind_hair(shader_set_data* set, shader* shad);
+static void shader_bind_eye_ball(shader_set_data* set, shader* shad);
+static void shader_bind_tone_map(shader_set_data* set, shader* shad);
+static void shader_bind_sss_filter(shader_set_data* set, shader* shad); // Added
+static void shader_bind_esm_filter(shader_set_data* set, shader* shad); // Added
+static void shader_bind_reduce_tex(shader_set_data* set, shader* shad); // Added
+static void shader_bind_magnify(shader_set_data* set, shader* shad); // Added
+static void shader_bind_mlaa(shader_set_data* set, shader* shad); // Added
+static void shader_bind_exposure(shader_set_data* set, shader* shad); // Added
+static void shader_bind_gauss(shader_set_data* set, shader* shad); // Added
+static void shader_bind_snow_particle(shader_set_data* set, shader* shad); // Added
+static void shader_bind_star(shader_set_data* set, shader* shad); // Added
+static void shader_bind_imgfilter(shader_set_data* set, shader* shad); // Added
-const shader_glsl_bind_func shader_ft_bind_func_table[] = {
+const shader_bind_func shader_ft_bind_func_table[] = {
{
SHADER_FT_BLINN,
shader_bind_blinn,
@@ -3054,9 +3054,9 @@ const shader_glsl_bind_func shader_ft_bind_func_table[] = {
};
const size_t shader_ft_bind_func_table_size =
- sizeof(shader_ft_bind_func_table) / sizeof(shader_glsl_bind_func);
+ sizeof(shader_ft_bind_func_table) / sizeof(shader_bind_func);
-shader_glsl_set_data shaders_ft;
+shader_set_data shaders_ft;
static glass_eye_struct glass_eye = {
{ 5.0f, 5.0f, 0.5f, 0.5f },
@@ -3184,21 +3184,21 @@ static void glass_eye_set(glass_eye_struct* glass_eye) {
rctx->glass_eye_batch_ubo.Bind(4);
}
-static void shader_bind_blinn(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_blinn(shader_set_data* set, shader* shad) {
shad->bind(set, uniform->arr[U_NORMAL]
? SHADER_FT_SUB_BLINN_FRAG : SHADER_FT_SUB_BLINN_VERT);
}
-static void shader_bind_cloth(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_cloth(shader_set_data* set, shader* shad) {
shad->bind(set, uniform->arr[U_NPR] ? SHADER_FT_SUB_CLOTH_NPR1
: (uniform->arr[U_ANISO] ? SHADER_FT_SUB_CLOTH_ANISO : SHADER_FT_SUB_CLOTH_DEFAULT));
}
-static void shader_bind_hair(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_hair(shader_set_data* set, shader* shad) {
shad->bind(set, uniform->arr[U_NPR] ? SHADER_FT_SUB_HAIR_NPR1 : SHADER_FT_SUB_HAIR_DEFAULT);
}
-static void shader_bind_eye_ball(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_eye_ball(shader_set_data* set, shader* shad) {
uniform->arr[U18] = 0;
if (set->shaders[SHADER_FT_GLASEYE].bind(set, SHADER_FT_SUB_GLASS_EYE) >= 0) {
glass_eye_calc(&glass_eye);
@@ -3206,12 +3206,12 @@ static void shader_bind_eye_ball(shader_glsl_set_data* set, shader_glsl* shad) {
}
}
-static void shader_bind_tone_map(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_tone_map(shader_set_data* set, shader* shad) {
shad->bind(set, uniform->arr[U_NPR] == 1
? SHADER_FT_SUB_TONEMAP_NPR1 : SHADER_FT_SUB_TONEMAP);
}
-static void shader_bind_sss_filter(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_sss_filter(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_SSS_FILTER]) {
case 0:
shad->bind(set, uniform->arr[U_NPR]
@@ -3223,7 +3223,7 @@ static void shader_bind_sss_filter(shader_glsl_set_data* set, shader_glsl* shad)
}
}
-static void shader_bind_esm_filter(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_esm_filter(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_ESM_FILTER]) {
case 0:
shad->bind(set, SHADER_FT_SUB_ESM_FILTER_MIN);
@@ -3234,7 +3234,7 @@ static void shader_bind_esm_filter(shader_glsl_set_data* set, shader_glsl* shad)
}
}
-static void shader_bind_reduce_tex(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_reduce_tex(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_REDUCE]) {
case 0:
switch (uniform->arr[U_ALPHA_MASK]) {
@@ -3291,7 +3291,7 @@ static void shader_bind_reduce_tex(shader_glsl_set_data* set, shader_glsl* shad)
}
}
-static void shader_bind_magnify(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_magnify(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_MAGNIFY]) {
case 0:
shad->bind(set, SHADER_FT_SUB_MAGNIFY_LINEAR);
@@ -3311,7 +3311,7 @@ static void shader_bind_magnify(shader_glsl_set_data* set, shader_glsl* shad) {
}
}
-static void shader_bind_mlaa(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_mlaa(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_MLAA]) {
case 0:
shad->bind(set, SHADER_FT_SUB_MLAA_EDGE);
@@ -3325,7 +3325,7 @@ static void shader_bind_mlaa(shader_glsl_set_data* set, shader_glsl* shad) { //
}
}
-static void shader_bind_exposure(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_exposure(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_EXPOSURE]) {
case 0:
shad->bind(set, SHADER_FT_SUB_EXPOSURE_MINIFY);
@@ -3339,7 +3339,7 @@ static void shader_bind_exposure(shader_glsl_set_data* set, shader_glsl* shad) {
}
}
-static void shader_bind_gauss(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_gauss(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_GAUSS]) {
case 0:
shad->bind(set, SHADER_FT_SUB_PP_GAUSS_USUAL);
@@ -3350,7 +3350,7 @@ static void shader_bind_gauss(shader_glsl_set_data* set, shader_glsl* shad) { //
}
}
-static void shader_bind_snow_particle(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_snow_particle(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_SNOW_PARTICLE]) {
case 0:
shad->bind(set, SHADER_FT_SUB_SNOW_PARTICLE_CPU);
@@ -3361,7 +3361,7 @@ static void shader_bind_snow_particle(shader_glsl_set_data* set, shader_glsl* sh
}
}
-static void shader_bind_star(shader_glsl_set_data* set, shader_glsl* shad) { // Added
+static void shader_bind_star(shader_set_data* set, shader* shad) { // Added
switch (uniform->arr[U_STAR]) {
case 0:
shad->bind(set, SHADER_FT_SUB_STAR);
@@ -3372,7 +3372,7 @@ static void shader_bind_star(shader_glsl_set_data* set, shader_glsl* shad) { //
}
}
-static void shader_bind_imgfilter(shader_glsl_set_data* set, shader_glsl* shad) {
+static void shader_bind_imgfilter(shader_set_data* set, shader* shad) {
switch (uniform->arr[U_IMAGE_FILTER]) {
case 0:
shad->bind(set, SHADER_FT_SUB_BOX4);
diff --git a/src/DivaGL/shader_glsl_ft.hpp b/src/DivaGL/shader_ft.hpp
similarity index 90%
rename from src/DivaGL/shader_glsl_ft.hpp
rename to src/DivaGL/shader_ft.hpp
index b3e24e6..4b4c41e 100644
--- a/src/DivaGL/shader_glsl_ft.hpp
+++ b/src/DivaGL/shader_ft.hpp
@@ -6,7 +6,7 @@
#pragma once
#include "../KKdLib/default.hpp"
-#include "shader_glsl.hpp"
+#include "shader.hpp"
enum shader_ft_enum {
SHADER_FT_FFP = 0,
@@ -77,11 +77,11 @@ enum shader_ft_enum {
SHADER_FT_MAX,
};
-extern const shader_glsl_table shader_ft_table[];
+extern const shader_table shader_ft_table[];
extern const size_t shader_ft_table_size;
-extern const shader_glsl_bind_func shader_ft_bind_func_table[];
+extern const shader_bind_func shader_ft_bind_func_table[];
extern const size_t shader_ft_bind_func_table_size;
-extern shader_glsl_set_data shaders_ft;
+extern shader_set_data shaders_ft;
extern int32_t shader_ft_get_index_by_name(const char* name);
diff --git a/src/DivaGL/shader_table.cpp b/src/DivaGL/shader_table.cpp
deleted file mode 100644
index 41b7bc4..0000000
--- a/src/DivaGL/shader_table.cpp
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- by korenkonder
- GitHub/GitLab: korenkonder
-*/
-
-#include "shader_table.hpp"
-#include "../KKdLib/mat.hpp"
-#include "render_context.hpp"
-#include "render_texture.hpp"
-#include "shader_glsl_ft.hpp"
-#include "types.hpp"
-#include "wrap.hpp"
-
-Shader* shaders = (Shader*)0x000000014CC57C10;
-ShaderTable* shader_table = (ShaderTable*)0x0000000140A41D20;
-ShaderBindFunc* shader_name_bind_func_table = (ShaderBindFunc*)0x0000000140A40F50;
-int32_t* current_vp = (int32_t*)0x000000014CC587B0;
-int32_t* current_fp = (int32_t*)0x000000014CC587B4;
-
-void FASTCALL shader_set(ShaderName name) {
- if (!name) {
- shader_unbind();
- return;
- }
-
- glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 24,
- (float)uniform->arr[U_TEXTURE_BLEND], 0.0, 0.0, 0.0);
-
- Shader* shad = &shaders[name];
- if (shad->bind_func)
- shad->bind_func(shad);
- else
- shader_bind(shad, shad->sub->sub_name);
-}
-
-void FASTCALL shader_bind_blinn(Shader* shad) {
- shader_bind(shad, uniform->arr[U_NORMAL] ? BLINN_FRAG : BLINN_VERT);
-}
-
-void FASTCALL shader_bind_cloth(Shader* shad) {
- shader_bind(shad, uniform->arr[U_NPR] ? CLOTH_NPR1
- : (uniform->arr[U_ANISO] ? CLOTH_ANISO : CLOTH_DEFAULT));
-}
-
-void FASTCALL shader_bind_hair(Shader* shad) {
- shader_bind(shad, uniform->arr[U_NPR] ? HAIR_NPR1
- : (uniform->arr[U_ANISO] ? HAIR_ANISO : HAIR_DEFAULT));
-}
-
-void FASTCALL shader_bind_membrane(Shader* shad) {
- uniform->arr[U_MEMBRANE] = 3;
- if (shader_bind(shad, MEMBRANE) < 0)
- return;
-
- uint32_t(FASTCALL * sub_140192E00)() = (uint32_t(FASTCALL*)())0x0000000140192E00;
- uint32_t v1 = sub_140192E00();
- mat4 mat = mat4_identity;
- mat4_mul_rotate_x(&mat, (float_t)((v1 & 0x1FF) * (M_PI / 256.0)), &mat);
- mat4_mul_rotate_z(&mat, (float_t)((v1 % 0x168) * (M_PI / 180.0)), &mat);
-
- vec4 vec = { 1.0f, 0.0f, 0.0f, 0.0f };
- mat4_transform_vector(&mat, &vec, &vec);
-
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 10, vec.x, vec.y, vec.z, 0.0);
-}
-
-void FASTCALL shader_bind_eye_ball(Shader* shad) {
- uniform->arr[U18] = 0;
- if (shader_bind(&shaders[_GLASEYE], GLASS_EYE) >= 0) {
- float* glass_eye = (float*)0x0000000140CA2D70;
- void (FASTCALL * glass_eye_calc)(float* glass_eye) = (void (FASTCALL*)(float* glass_eye))0x00000001405E53D0;
- void (FASTCALL * glass_eye_set)(float* glass_eye) = (void (FASTCALL*)(float* glass_eye))0x00000001405E4750;
- glass_eye_calc(glass_eye);
- glass_eye_set(glass_eye);
- }
-}
-
-void FASTCALL shader_bind_tone_map(Shader* shad) {
- shader_bind(shad, uniform->arr[U_NPR] == 1 ? TONEMAP_NPR1 : TONEMAP);
-}
-
-int32_t FASTCALL shader_bind(Shader* shad, SubShaderName name) {
- int32_t num_sub = shad->num_sub;
- int32_t subshader_index = 0;
- if (num_sub <= 0)
- return -1;
-
- for (SubShader* i = shad->sub; i->sub_name != name; i++) {
- subshader_index++;
- if (subshader_index >= num_sub)
- return -1;
- }
-
- SubShader* subshader = &shad->sub[subshader_index];
- if (!subshader)
- return -1;
-
- int32_t num_uniform = shad->num_uniform;
- int32_t unival_vp_curr = 1;
- int32_t unival_fp_curr = 1;
- int32_t unival_vp = 0;
- int32_t unival_fp = 0;
- if (num_uniform > 0) {
- int32_t* vp_unival_max = subshader->vp_unival_max;
- int32_t* fp_unival_max = subshader->fp_unival_max;
- for (size_t i = 0; i < num_uniform; i++) {
- int32_t unival = uniform->arr[shad->use_uniform[i]];
- unival_vp += unival_vp_curr * min_def(unival, vp_unival_max[i]);
- unival_fp += unival_fp_curr * min_def(unival, fp_unival_max[i]);
- unival_vp_curr *= vp_unival_max[i] + 1;
- unival_fp_curr *= fp_unival_max[i] + 1;
- }
- }
-
- int32_t vp = subshader->vp[unival_vp];
- int32_t fp = subshader->fp[unival_fp];
- if (*current_vp != vp) {
- glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vp);
- *current_vp = vp;
- }
-
- if (*current_fp != fp) {
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fp);
- *current_fp = fp;
- }
-
- glEnableDLL(GL_VERTEX_PROGRAM_ARB);
- glEnableDLL(GL_FRAGMENT_PROGRAM_ARB);
- return 0;
-}
-
-void FASTCALL shader_unbind() {
- if (current_vp) {
- if (*current_vp)
- glDisableDLL(GL_VERTEX_PROGRAM_ARB);
- *current_vp = 0;
- }
-
- if (current_fp) {
- if (*current_fp)
- glDisableDLL(GL_FRAGMENT_PROGRAM_ARB);
- *current_fp = 0;
- }
-}
-
-void FASTCALL shader_load_all_shaders() {
- {
- farc f;
- f.read("plugins\\divagl_ft_shaders.farc", true, false);
- shaders_ft.load(&f, false, "ft", shader_ft_table, shader_ft_table_size,
- shader_ft_bind_func_table, shader_ft_bind_func_table_size,
- shader_ft_get_index_by_name);
- }
- return;
-
- void (FASTCALL * shader_load_program_file)(GLuint program, const char* file_name, bool vertex_program)
- = (void (FASTCALL*)(GLuint program, const char* file_name, bool vertex_program))0x00000001405E52D0;
-
- ShaderTable* shaders_table = &shader_table[_BLINN];
- Shader* shader = &shaders[_BLINN];
- int32_t curr_shader = SHADER_END - 1;
- do {
- shader->name = shaders_table->name;
- shader->name_index = shaders_table->name_index;
- shader->num_sub = shaders_table->num_sub;
- int32_t num_sub = shaders_table->num_sub;
-
- const SubShaderTable* sub_table = shaders_table->sub;
- SubShader* sub = (SubShader*)_operator_new(sizeof(SubShader) * num_sub);
- memset(sub, 0, sizeof(SubShader) * num_sub);
- shader->sub = sub;
- shader->num_uniform = shaders_table->num_uniform;
- shader->use_uniform = shaders_table->use_uniform;
-
- for (int32_t i = 0; i < num_sub; i++, sub_table++, sub++) {
- sub->sub_name = sub_table->sub_name;
- sub->vp_unival_max = (int32_t*)sub_table->vp_unival_max;
- sub->fp_unival_max = (int32_t*)sub_table->fp_unival_max;
- sub->num_vp = sub_table->num_vp;
- sub->num_fp = sub_table->num_fp;
- sub->vp = (GLuint*)_operator_new(sizeof(GLuint) * sub_table->num_vp);
- sub->fp = (GLuint*)_operator_new(sizeof(GLuint) * sub_table->num_fp);
-
- glGenProgramsARB((GLsizei)sub_table->num_vp, (GLuint*)sub->vp);
- glGenProgramsARB((GLsizei)sub_table->num_fp, (GLuint*)sub->fp);
-
- for (int32_t j = 0; j < sub_table->num_vp; j++)
- shader_load_program_file(sub->vp[j], sub_table->vp[j], true);
-
- for (int32_t j = 0; j < sub_table->num_fp; j++)
- shader_load_program_file(sub->fp[j], sub_table->fp[j], false);
- }
- shader->bind_func = 0;
-
- ShaderBindFunc* bind_func_table = shader_name_bind_func_table;
- ShaderName bind_func_name = _BLINN;
- while (shader->name_index != bind_func_name) {
- bind_func_name = (++bind_func_table)->name_index;
- if (bind_func_table->name_index == SHADER_END)
- break;
- }
- shader->bind_func = bind_func_table->bind_func;
- shader++;
- shaders_table++;
- curr_shader--;
- } while (curr_shader);
-}
-
-void FASTCALL shader_free() {
- shaders_ft.unload();
- return;
- Shader* shader = &shaders[SHADER_FFP];
- for (int32_t i = 0; i < SHADER_END; i++, shader++) {
- if (!shader->sub)
- continue;
-
- for (int32_t j = 0; j < shader->num_sub; j++) {
- SubShader* sub = shader->sub;
- if (sub[j].vp) {
- glDeleteProgramsARB(sub[j].num_vp, sub[j].vp);
- _operator_delete(sub[j].vp);
- sub[j].vp = 0;
- }
-
- if (sub[j].fp) {
- glDeleteProgramsARB(sub[j].num_fp, sub[j].fp);
- _operator_delete(sub[j].fp);
- sub[j].fp = 0;
- }
- }
-
- if (shader->sub) {
- _operator_delete(shader->sub);
- shader->sub = 0;
- }
- }
-}
diff --git a/src/DivaGL/shader_table.hpp b/src/DivaGL/shader_table.hpp
deleted file mode 100644
index 7f27a4f..0000000
--- a/src/DivaGL/shader_table.hpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- by korenkonder
- GitHub/GitLab: korenkonder
-*/
-
-#pragma once
-
-#include "../KKdLib/default.hpp"
-#include "gl.hpp"
-#include "uniform.hpp"
-
-enum SubShaderName {
- SHADER_SUB_FFP = 0,
- BLINN_VERT = 1,
- BLINN_FRAG = 2,
- ITEM_BLINN = 3,
- STAGE_BLINN = 4,
- SKIN_DEFAULT = 5,
- SSS_SKIN = 6,
- SSS_FILTER = 7,
- HAIR_DEFAULT = 8,
- HAIR_ANISO = 9,
- HAIR_NPR1 = 10,
- CLOTH_DEFAULT = 11,
- CLOTH_ANISO = 12,
- CLOTH_NPR1 = 13,
- TIGHTS = 14,
- SKY_DEFAULT = 15,
- EYE_BALL = 16,
- EYE_LENS = 17,
- GLASS_EYE = 18,
- MEMBRANE = 19,
- SHADOWMAP = 20,
- ESM = 21,
- ESM_GAUSS = 22,
- ESM_FILTER = 23,
- LIT_PROJ = 24,
- SIMPLE = 25,
- SILHOUETTE = 26,
- LAMBERT = 27,
- CONSTANT = 28,
- PEEL = 29,
- TONEMAP = 30,
- TONEMAP_NPR1 = 31,
- REDUCE_TEX = 32,
- MAGNIFY = 33,
- MLAA = 34,
- CONTOUR = 35,
- EXPOSURE = 36,
- PP_GAUSS = 37,
- SUN = 38,
- FADE = 39,
- WATER01 = 40,
- WATER02 = 41,
- WATER_RING = 42,
- WATER_PARTICLE = 43,
- SNOW_PARTICLE = 44,
- LEAF_PARTICLE = 45,
- STAR = 46,
- SNOW_RING = 47,
- SNOW_FOOTPRINT = 48,
- SNOW_TEX_SPACE_LIGHT = 49,
- SNOW_CALC_NORMAL = 50,
- FLOOR = 51,
- PUDDLE = 52,
- SIMPLE_REFLECT = 53,
- SIMPLE_REFRACT = 54,
- RIPPLE_EMIT = 55,
- RAIN = 56,
- VOLUME_LIGHT = 57,
- FENCE_ALPHA = 58,
- RIPPLE = 59,
- FOG_PTCL = 60,
- PARTICLE = 61,
- GLITTER_PARTICLE = 62,
- SHOW_VECTOR = 63,
- FONT = 64,
- MOVIE = 65,
- IMGFILTER = 66,
- SPRITE = 67,
-};
-
-enum ShaderName {
- SHADER_FFP = 0,
- _BLINN = 1,
- _ITEM = 2,
- _STAGE = 3,
- _SKIN = 4,
- _SSS_SKIN = 5,
- _SSS_FILT = 6,
- _HAIR = 7,
- _CLOTH = 8,
- _TIGHTS = 9,
- _SKY = 10,
- _EYEBALL = 11,
- _EYELENS = 12,
- _GLASEYE = 13,
- _MEMBRAN = 14,
- _SHDMAP = 15,
- _ESM = 16,
- _ESMGAUSS = 17,
- _ESMFILT = 18,
- _LITPROJ = 19,
- _SIMPLE = 20,
- _SIL = 21,
- _LAMBERT = 22,
- _CONSTANT = 23,
- _PEEL = 24,
- _TONEMAP = 25,
- _REDUCE = 26,
- _MAGNIFY = 27,
- _MLAA = 28,
- _CONTOUR = 29,
- _EXPOSURE = 30,
- _GAUSS = 31,
- _SUN = 32,
- _FADE = 33,
- _WATER01 = 34,
- _WATER02 = 35,
- _WATRING = 36,
- _W_PTCL = 37,
- _SNOW_PT = 38,
- _LEAF_PT = 39,
- _STAR = 40,
- _SNORING = 41,
- _SN_FOOT = 42,
- _SN_TSL = 43,
- _SN_NRM = 44,
- _FLOOR = 45,
- _PUDDLE = 46,
- _S_REFL = 47,
- _S_REFR = 48,
- _RIPEMIT = 49,
- _RAIN = 50,
- _VOLLIT = 51,
- _FENCE = 52,
- _RIPPLE = 53,
- _FOGPTCL = 54,
- _PARTICL = 55,
- _GLITTER_PT = 56,
- _SHOWVEC = 57,
- _FONT = 58,
- _MOVIE = 59,
- _IMGFILT = 60,
- _SPRITE = 61,
- SHADER_END = 62,
-};
-
-struct SubShaderTable {
- SubShaderName sub_name;
- int32_t padding;
- const int32_t* vp_unival_max;
- const int32_t* fp_unival_max;
- int32_t num_vp;
- int32_t num_fp;
- const char** vp;
- const char** fp;
-};
-
-struct ShaderTable {
- const char* name;
- ShaderName name_index;
- int32_t num_sub;
- const SubShaderTable* sub;
- int32_t num_uniform;
- int32_t padding;
- uniform_name* use_uniform;
-};
-
-struct SubShader {
- SubShaderName sub_name;
- int32_t padding;
- int32_t* vp_unival_max;
- int32_t* fp_unival_max;
- int32_t num_vp;
- int32_t num_fp;
- GLuint* vp;
- GLuint* fp;
-};
-
-struct Shader;
-
-typedef void (FASTCALL* PFNSHADERBINDFUNCPROC)(Shader* shad);
-
-struct Shader {
- const char* name;
- ShaderName name_index;
- int32_t num_sub;
- SubShader* sub;
- int32_t num_uniform;
- int32_t padding;
- uniform_name* use_uniform;
- PFNSHADERBINDFUNCPROC bind_func;
-};
-
-struct ShaderBindFunc {
- ShaderName name_index;
- int32_t padding;
- PFNSHADERBINDFUNCPROC bind_func;
-};
-
-extern Shader* shaders;
-extern ShaderTable* shader_table;
-extern ShaderBindFunc* shader_name_bind_func_table;
-extern int32_t* current_vp;
-extern int32_t* current_fp;
-
-extern void FASTCALL shader_set(ShaderName name); // 0x00000001405E4CE0
-extern void FASTCALL shader_bind_blinn(Shader* shad); // 0x00000001405E4320
-extern void FASTCALL shader_bind_cloth(Shader* shad); // 0x00000001405E4340
-extern void FASTCALL shader_bind_hair(Shader* shad); // 0x00000001405E4370
-extern void FASTCALL shader_bind_membrane(Shader* shas); // 0x00000001405E43A0
-extern void FASTCALL shader_bind_eye_ball(Shader* shad); // 0x00000001405E4530
-extern void FASTCALL shader_bind_tone_map(Shader* shad); // 0x00000001405E4580
-extern int32_t FASTCALL shader_bind(Shader* shad, SubShaderName name); // 0x00000001405E4B50
-extern void FASTCALL shader_unbind(); // 0x00000001405E5660
-extern void FASTCALL shader_load_all_shaders(); // 0x00000001405E4FC0
-extern void FASTCALL shader_free(); // 0x00000001405E4DB0
diff --git a/src/DivaGL/sprite.cpp b/src/DivaGL/sprite.cpp
index 9a507d8..a1768ba 100644
--- a/src/DivaGL/sprite.cpp
+++ b/src/DivaGL/sprite.cpp
@@ -5,7 +5,7 @@
#include "sprite.hpp"
#include "render_context.hpp"
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include
struct sprite_draw_vertex {
diff --git a/src/DivaGL/task_effect.cpp b/src/DivaGL/task_effect.cpp
index 59b115d..42c7990 100644
--- a/src/DivaGL/task_effect.cpp
+++ b/src/DivaGL/task_effect.cpp
@@ -12,7 +12,7 @@
#include "gl_element_array_buffer.hpp"
#include "render_context.hpp"
#include "render_manager.hpp"
-#include "shader_glsl_ft.hpp"
+#include "shader_ft.hpp"
#include "stage_param.hpp"
#include "texture.hpp"
#include
diff --git a/src/DivaGL/wrap.cpp b/src/DivaGL/wrap.cpp
index ddd49da..f9ab7ef 100644
--- a/src/DivaGL/wrap.cpp
+++ b/src/DivaGL/wrap.cpp
@@ -9,7 +9,7 @@
#include "../KKdLib/vec.hpp"
#include "inject.hpp"
#include "print.hpp"
-#include "shader_glsl_ft.hpp"
+#include "uniform.hpp"
#include
#include