This commit is contained in:
Michael Fabian Dirks 2017-09-18 00:15:57 +02:00
parent 90563e6b31
commit 27744f8b2a
2 changed files with 81 additions and 74 deletions

View file

@ -18,3 +18,77 @@
*/ */
#include "gs-helper.h" #include "gs-helper.h"
gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name) {
gs_effect_param* p = gs_effect_get_param_by_name(effect, name);
if (!p)
P_LOG_ERROR("Failed to find parameter %s in effect.", name);
return p;
}
bool gs_set_param_int(gs_effect_t* effect, const char* name, int value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_int(p, value);
return true;
}
P_LOG_ERROR("Failed to set value %d for parameter %s in"
" effect.", value, name);
return false;
}
bool gs_set_param_float(gs_effect_t* effect, const char* name, float value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_float(p, value);
return true;
}
P_LOG_ERROR("Failed to set value %f for parameter %s in"
" effect.", value, name);
return false;
}
bool gs_set_param_float2(gs_effect_t* effect, const char* name, vec2* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec2(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f} for parameter %s"
" in effect.", value->x, value->y, name);
return false;
}
bool gs_set_param_float3(gs_effect_t* effect, const char* name, vec3* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec3(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f,%f} for parameter"
"%s in effect.", value->x, value->y, value->z, name);
return false;
}
bool gs_set_param_float4(gs_effect_t* effect, const char* name, vec4* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec4(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f,%f,%f} for"
" parameter %s in effect.", value->x, value->y, value->z,
value->w, name);
return false;
}
bool gs_set_param_texture(gs_effect_t* effect, const char* name, gs_texture_t* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_texture(p, value);
return true;
}
P_LOG_ERROR("Failed to set texture for"
" parameter %s in effect.", name);
return false;
}

View file

@ -27,77 +27,10 @@ extern "C" {
#pragma warning (pop) #pragma warning (pop)
} }
gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name);
gs_effect_param* gs_effect_get_param(gs_effect_t* effect, const char* name) { bool gs_set_param_int(gs_effect_t* effect, const char* name, int value);
gs_effect_param* p = gs_effect_get_param_by_name(effect, name); bool gs_set_param_float(gs_effect_t* effect, const char* name, float value);
if (!p) bool gs_set_param_float2(gs_effect_t* effect, const char* name, vec2* value);
P_LOG_ERROR("Failed to find parameter %s in effect.", name); bool gs_set_param_float3(gs_effect_t* effect, const char* name, vec3* value);
return p; bool gs_set_param_float4(gs_effect_t* effect, const char* name, vec4* value);
} bool gs_set_param_texture(gs_effect_t* effect, const char* name, gs_texture_t* value);
bool gs_set_param_int(gs_effect_t* effect, const char* name, int value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_int(p, value);
return true;
}
P_LOG_ERROR("Failed to set value %d for parameter %s in"
" effect.", value, name);
return false;
}
bool gs_set_param_float(gs_effect_t* effect, const char* name, float value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_float(p, value);
return true;
}
P_LOG_ERROR("Failed to set value %f for parameter %s in"
" effect.", value, name);
return false;
}
bool gs_set_param_float2(gs_effect_t* effect, const char* name, vec2* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec2(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f} for parameter %s"
" in effect.", value->x, value->y, name);
return false;
}
bool gs_set_param_float3(gs_effect_t* effect, const char* name, vec3* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec3(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f,%f} for parameter"
"%s in effect.", value->x, value->y, value->z, name);
return false;
}
bool gs_set_param_float4(gs_effect_t* effect, const char* name, vec4* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_vec4(p, value);
return true;
}
P_LOG_ERROR("Failed to set value {%f,%f,%f,%f} for"
" parameter %s in effect.", value->x, value->y, value->z,
value->w, name);
return false;
}
bool gs_set_param_texture(gs_effect_t* effect, const char* name, gs_texture_t* value) {
gs_effect_param* p = nullptr;
if (nullptr != (p = gs_effect_get_param(effect, name))) {
gs_effect_set_texture(p, value);
return true;
}
P_LOG_ERROR("Failed to set texture for"
" parameter %s in effect.", name);
return false;
}