#include "ems.h"
std::optional<Shader> ElectricityEffect::shader = std::nullopt;
+int ElectricityEffect::uniform_screen_height = 0;
+int ElectricityEffect::uniform_side_pos_a = 0;
+int ElectricityEffect::uniform_side_dir_a = 0;
+int ElectricityEffect::uniform_side_pos_b = 0;
+int ElectricityEffect::uniform_side_dir_b = 0;
+int ElectricityEffect::uniform_width = 0;
ElectricityEffect::ElectricityEffect(Vector3 center, float radius,
int line_count, float lifetime,
if (!shader.has_value()) {
init_shader();
}
- int uniform_loc = GetShaderLocation(get_shader(), "screen_height");
float height = GetScreenHeight();
- DEBUG_PRINT_FLOAT(height);
- SetShaderValue(get_shader(), uniform_loc, &height, SHADER_UNIFORM_FLOAT);
+ // DEBUG_PRINT_FLOAT(height);
+ SetShaderValue(get_shader(), uniform_screen_height, &height,
+ SHADER_UNIFORM_FLOAT);
}
void ElectricityEffect::update_shader_sides(Vector2 a, Vector2 adir, Vector2 b,
if (!shader.has_value()) {
init_shader();
}
- int uniform_loc = GetShaderLocation(get_shader(), "sidePosA");
- DEBUG_PRINT_VEC2(a);
- SetShaderValue(get_shader(), uniform_loc, &a, SHADER_UNIFORM_VEC2);
- uniform_loc = GetShaderLocation(get_shader(), "sideDirA");
- DEBUG_PRINT_VEC2(adir);
- SetShaderValue(get_shader(), uniform_loc, &adir, SHADER_UNIFORM_VEC2);
- uniform_loc = GetShaderLocation(get_shader(), "sidePosB");
- DEBUG_PRINT_VEC2(b);
- SetShaderValue(get_shader(), uniform_loc, &b, SHADER_UNIFORM_VEC2);
- uniform_loc = GetShaderLocation(get_shader(), "sideDirB");
- DEBUG_PRINT_VEC2(bdir);
- SetShaderValue(get_shader(), uniform_loc, &bdir, SHADER_UNIFORM_VEC2);
- uniform_loc = GetShaderLocation(get_shader(), "width");
- DEBUG_PRINT_FLOAT(width);
- SetShaderValue(get_shader(), uniform_loc, &width, SHADER_UNIFORM_FLOAT);
+ // DEBUG_PRINT_VEC2(a);
+ SetShaderValue(get_shader(), uniform_side_pos_a, &a, SHADER_UNIFORM_VEC2);
+ // DEBUG_PRINT_VEC2(adir);
+ SetShaderValue(get_shader(), uniform_side_dir_a, &adir, SHADER_UNIFORM_VEC2);
+ // DEBUG_PRINT_VEC2(b);
+ SetShaderValue(get_shader(), uniform_side_pos_b, &b, SHADER_UNIFORM_VEC2);
+ // DEBUG_PRINT_VEC2(bdir);
+ SetShaderValue(get_shader(), uniform_side_dir_b, &bdir, SHADER_UNIFORM_VEC2);
+ // DEBUG_PRINT_FLOAT(width);
+ SetShaderValue(get_shader(), uniform_width, &width, SHADER_UNIFORM_FLOAT);
}
void ElectricityEffect::init_shader() {
" gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); \n"
" } \n"
"} \n");
+
+ uniform_screen_height = GetShaderLocation(shader.value(), "screen_height");
+ uniform_side_pos_a = GetShaderLocation(shader.value(), "sidePosA");
+ uniform_side_dir_a = GetShaderLocation(shader.value(), "sideDirA");
+ uniform_side_pos_b = GetShaderLocation(shader.value(), "sidePosB");
+ uniform_side_dir_b = GetShaderLocation(shader.value(), "sideDirB");
+ uniform_width = GetShaderLocation(shader.value(), "width");
}
#include "ems.h"
std::optional<Shader> SparkEffect::shader = std::nullopt;
+int SparkEffect::uniform_screen_height = 0;
+int SparkEffect::uniform_spark_radius = 0;
+int SparkEffect::uniform_spark_pos = 0;
SparkEffect::SparkEffect(int count, float lifetime, Vector3 pos,
float pos_xz_variance, float radius, Color color)
if (!shader.has_value()) {
init_shader();
}
- int uniform_loc = GetShaderLocation(get_shader(), "screen_height");
float height = GetScreenHeight();
- DEBUG_PRINT_FLOAT(height);
- SetShaderValue(get_shader(), uniform_loc, &height, SHADER_UNIFORM_FLOAT);
+ // DEBUG_PRINT_FLOAT(height);
+ SetShaderValue(get_shader(), uniform_screen_height, &height,
+ SHADER_UNIFORM_FLOAT);
}
void SparkEffect::update_shader_uniforms(float radius, Vector2 pos) {
init_shader();
}
- int uniform_loc = GetShaderLocation(get_shader(), "spark_radius");
- DEBUG_PRINT_FLOAT(radius);
- SetShaderValue(get_shader(), uniform_loc, &radius, SHADER_UNIFORM_FLOAT);
- uniform_loc = GetShaderLocation(get_shader(), "spark_pos");
- DEBUG_PRINT_VEC2(pos);
- SetShaderValue(get_shader(), uniform_loc, &pos, SHADER_UNIFORM_VEC2);
+ // DEBUG_PRINT_FLOAT(radius);
+ SetShaderValue(get_shader(), uniform_spark_radius, &radius,
+ SHADER_UNIFORM_FLOAT);
+ // DEBUG_PRINT_VEC2(pos);
+ SetShaderValue(get_shader(), uniform_spark_pos, &pos, SHADER_UNIFORM_VEC2);
}
void SparkEffect::init_shader() {
"(1.0 - lerpVal); \n"
" } \n"
"} \n");
+ uniform_screen_height = GetShaderLocation(shader.value(), "screen_height");
+ uniform_spark_radius = GetShaderLocation(shader.value(), "spark_radius");
+ uniform_spark_pos = GetShaderLocation(shader.value(), "spark_pos");
}