mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-10 22:05:06 +00:00
gs: Rename to snake_case instead of PascalCase
This should prevent mishaps with upper/lowercase typos and fits in better with the C++ standard code, which is also in snake_case.
This commit is contained in:
parent
9f518764b6
commit
2adfa5765c
27 changed files with 428 additions and 428 deletions
|
@ -50,8 +50,8 @@ enum ColorFormat : uint64_t {
|
|||
|
||||
// Global Data
|
||||
const size_t MaxKernelSize = 25;
|
||||
std::map<std::string, std::shared_ptr<GS::Effect>> g_effects;
|
||||
std::vector<std::shared_ptr<GS::Texture>> g_gaussianKernels;
|
||||
std::map<std::string, std::shared_ptr<gs::effect>> g_effects;
|
||||
std::vector<std::shared_ptr<gs::texture>> g_gaussianKernels;
|
||||
|
||||
double_t bilateral(double_t x, double_t o) {
|
||||
return 0.39894 * exp(-0.5 * (x * x) / (o * o)) / o;
|
||||
|
@ -85,7 +85,7 @@ static void GenerateGaussianKernelTextures() {
|
|||
const uint8_t** pdata = const_cast<const uint8_t**>(&data);
|
||||
|
||||
try {
|
||||
std::shared_ptr<GS::Texture> tex = std::make_shared<GS::Texture>((uint32_t)textureBufferSize, 1,
|
||||
std::shared_ptr<gs::texture> tex = std::make_shared<gs::texture>((uint32_t)textureBufferSize, 1,
|
||||
gs_color_format::GS_R32F, 1, pdata, 0);
|
||||
g_gaussianKernels[n] = tex;
|
||||
} catch (std::runtime_error ex) {
|
||||
|
@ -121,7 +121,7 @@ Filter::Blur::Blur() {
|
|||
};
|
||||
for (auto& kv : effects) {
|
||||
try {
|
||||
std::shared_ptr<GS::Effect> effect = std::make_shared<GS::Effect>(kv.second);
|
||||
std::shared_ptr<gs::effect> effect = std::make_shared<gs::effect>(kv.second);
|
||||
g_effects.insert(std::make_pair(kv.first, effect));
|
||||
} catch (std::runtime_error ex) {
|
||||
P_LOG_ERROR("<filter-blur> Loading effect '%s' (path: '%s') failed with error(s): %s",
|
||||
|
@ -623,7 +623,7 @@ bool Filter::Blur::Instance::apply_gaussian_param() {
|
|||
if (m_type != Type::Gaussian)
|
||||
return false;
|
||||
|
||||
std::shared_ptr<GS::Texture> tex;
|
||||
std::shared_ptr<gs::texture> tex;
|
||||
if ((m_size - 1) < MaxKernelSize) {
|
||||
tex = g_gaussianKernels[size_t(m_size - 1)];
|
||||
result = result && gs_set_param_texture(m_effect->GetObject(), "kernel", tex->GetObject());
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Filter {
|
|||
obs_source_t *m_source;
|
||||
gs_texrender_t *m_primaryRT, *m_secondaryRT;
|
||||
gs_texrender_t *m_rtHorizontal, *m_rtVertical;
|
||||
std::shared_ptr<GS::Effect> m_effect;
|
||||
std::shared_ptr<gs::effect> m_effect;
|
||||
|
||||
// Blur
|
||||
Type m_type;
|
||||
|
|
|
@ -147,7 +147,7 @@ bool Filter::CustomShader::modified_properties(obs_properties_t *pr, obs_propert
|
|||
Instance* ptr = static_cast<Instance*>(obs_properties_get_param(pr));
|
||||
for (Instance::Parameter& prm : ptr->m_effectParameters) {
|
||||
switch (prm.type) {
|
||||
case GS::EffectParameter::Type::Texture:
|
||||
case gs::effect_parameter::type::Texture:
|
||||
bool isSource = obs_data_get_int(data, prm.uiNames[0].c_str()) == 1;
|
||||
obs_property_set_visible(obs_properties_get(pr, prm.uiNames[1].c_str()), isSource);
|
||||
obs_property_set_visible(obs_properties_get(pr, prm.uiNames[2].c_str()), !isSource);
|
||||
|
@ -205,7 +205,7 @@ Filter::CustomShader::Instance::Instance(obs_data_t *data, obs_source_t *source)
|
|||
m_effect.lastCheck = 0;
|
||||
m_effect.effect = nullptr;
|
||||
|
||||
m_renderTarget = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||
m_renderTarget = std::make_unique<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||
|
||||
m_activeTime = 0.0f;
|
||||
m_renderTime = 0.0f;
|
||||
|
@ -220,7 +220,7 @@ void Filter::CustomShader::Instance::update(obs_data_t *data) {
|
|||
if (shaderType == ShaderType::Text) {
|
||||
const char* shaderText = obs_data_get_string(data, S_CONTENT_TEXT);
|
||||
try {
|
||||
m_effect.effect = std::make_unique<GS::Effect>(shaderText, "Text Shader");
|
||||
m_effect.effect = std::make_unique<gs::effect>(shaderText, "Text Shader");
|
||||
} catch (std::runtime_error& ex) {
|
||||
const char* filterName = obs_source_get_name(m_source);
|
||||
P_LOG_ERROR("[%s] Shader loading failed with error(s): %s", filterName, ex.what());
|
||||
|
@ -230,81 +230,81 @@ void Filter::CustomShader::Instance::update(obs_data_t *data) {
|
|||
}
|
||||
|
||||
m_effectParameters.clear();
|
||||
if (m_effect.effect && m_effect.effect->CountParameters() > 0) {
|
||||
for (auto p : m_effect.effect->GetParameters()) {
|
||||
std::string p_name = p.GetName();
|
||||
if (m_effect.effect && m_effect.effect->count_parameters() > 0) {
|
||||
for (auto p : m_effect.effect->get_parameters()) {
|
||||
std::string p_name = p.get_name();
|
||||
std::string p_desc = p_name;
|
||||
|
||||
if (IsSpecialParameter(p_name, p.GetType()))
|
||||
if (IsSpecialParameter(p_name, p.get_type()))
|
||||
continue;
|
||||
|
||||
Parameter prm;
|
||||
prm.name = p_name;
|
||||
prm.type = p.GetType();
|
||||
prm.type = p.get_type();
|
||||
|
||||
switch (p.GetType()) {
|
||||
case GS::EffectParameter::Type::Boolean:
|
||||
switch (p.get_type()) {
|
||||
case gs::effect_parameter::type::Boolean:
|
||||
{
|
||||
prm.uiNames.push_back(p_name);
|
||||
prm.uiDescriptions.push_back(p_desc);
|
||||
prm.value.b = obs_data_get_bool(data, p_name.c_str());
|
||||
break;
|
||||
}
|
||||
case GS::EffectParameter::Type::Float:
|
||||
case GS::EffectParameter::Type::Float2:
|
||||
case GS::EffectParameter::Type::Float3:
|
||||
case GS::EffectParameter::Type::Float4:
|
||||
case gs::effect_parameter::type::Float:
|
||||
case gs::effect_parameter::type::Float2:
|
||||
case gs::effect_parameter::type::Float3:
|
||||
case gs::effect_parameter::type::Float4:
|
||||
{
|
||||
{
|
||||
prm.uiNames.push_back(p_name + "0");
|
||||
prm.uiDescriptions.push_back(p_desc + "[0]");
|
||||
prm.value.f[0] = (float_t)obs_data_get_double(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Float2) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Float2) {
|
||||
prm.uiNames.push_back(p_name + "1");
|
||||
prm.uiDescriptions.push_back(p_desc + "[1]");
|
||||
prm.value.f[1] = (float_t)obs_data_get_double(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Float3) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Float3) {
|
||||
prm.uiNames.push_back(p_name + "2");
|
||||
prm.uiDescriptions.push_back(p_desc + "[2]");
|
||||
prm.value.f[2] = (float_t)obs_data_get_double(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Float4) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Float4) {
|
||||
prm.uiNames.push_back(p_name + "3");
|
||||
prm.uiDescriptions.push_back(p_desc + "[3]");
|
||||
prm.value.f[3] = (float_t)obs_data_get_double(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GS::EffectParameter::Type::Integer:
|
||||
case GS::EffectParameter::Type::Integer2:
|
||||
case GS::EffectParameter::Type::Integer3:
|
||||
case GS::EffectParameter::Type::Integer4:
|
||||
case gs::effect_parameter::type::Integer:
|
||||
case gs::effect_parameter::type::Integer2:
|
||||
case gs::effect_parameter::type::Integer3:
|
||||
case gs::effect_parameter::type::Integer4:
|
||||
{
|
||||
{
|
||||
prm.uiNames.push_back(p_name + "0");
|
||||
prm.uiDescriptions.push_back(p_desc + "[0]");
|
||||
prm.value.i[0] = (int32_t)obs_data_get_int(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Integer2) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Integer2) {
|
||||
prm.uiNames.push_back(p_name + "1");
|
||||
prm.uiDescriptions.push_back(p_desc + "[1]");
|
||||
prm.value.i[1] = (int32_t)obs_data_get_int(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Integer3) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Integer3) {
|
||||
prm.uiNames.push_back(p_name + "2");
|
||||
prm.uiDescriptions.push_back(p_desc + "[2]");
|
||||
prm.value.i[2] = (int32_t)obs_data_get_int(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
if (p.GetType() >= GS::EffectParameter::Type::Integer4) {
|
||||
if (p.get_type() >= gs::effect_parameter::type::Integer4) {
|
||||
prm.uiNames.push_back(p_name + "3");
|
||||
prm.uiDescriptions.push_back(p_desc + "[3]");
|
||||
prm.value.i[3] = (int32_t)obs_data_get_int(data, prm.uiNames.back().c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GS::EffectParameter::Type::Texture:
|
||||
case gs::effect_parameter::type::Texture:
|
||||
{
|
||||
prm.uiNames.push_back(p_name + "_type");
|
||||
prm.uiDescriptions.push_back(p_desc + " Type");
|
||||
|
@ -328,28 +328,28 @@ void Filter::CustomShader::Instance::update(obs_data_t *data) {
|
|||
|
||||
for (Parameter& prm : m_effectParameters) {
|
||||
switch (prm.type) {
|
||||
case GS::EffectParameter::Type::Boolean:
|
||||
case gs::effect_parameter::type::Boolean:
|
||||
prm.value.b = obs_data_get_bool(data, prm.uiNames[0].c_str());
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float4:
|
||||
case gs::effect_parameter::type::Float4:
|
||||
prm.value.f[3] = (float_t)obs_data_get_double(data, prm.uiNames[3].c_str());
|
||||
case GS::EffectParameter::Type::Float3:
|
||||
case gs::effect_parameter::type::Float3:
|
||||
prm.value.f[2] = (float_t)obs_data_get_double(data, prm.uiNames[2].c_str());
|
||||
case GS::EffectParameter::Type::Float2:
|
||||
case gs::effect_parameter::type::Float2:
|
||||
prm.value.f[1] = (float_t)obs_data_get_double(data, prm.uiNames[1].c_str());
|
||||
case GS::EffectParameter::Type::Float:
|
||||
case gs::effect_parameter::type::Float:
|
||||
prm.value.f[0] = (float_t)obs_data_get_double(data, prm.uiNames[0].c_str());
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer4:
|
||||
case gs::effect_parameter::type::Integer4:
|
||||
prm.value.i[3] = (int32_t)obs_data_get_int(data, prm.uiNames[3].c_str());
|
||||
case GS::EffectParameter::Type::Integer3:
|
||||
case gs::effect_parameter::type::Integer3:
|
||||
prm.value.i[2] = (int32_t)obs_data_get_int(data, prm.uiNames[2].c_str());
|
||||
case GS::EffectParameter::Type::Integer2:
|
||||
case gs::effect_parameter::type::Integer2:
|
||||
prm.value.i[1] = (int32_t)obs_data_get_int(data, prm.uiNames[1].c_str());
|
||||
case GS::EffectParameter::Type::Integer:
|
||||
case gs::effect_parameter::type::Integer:
|
||||
prm.value.i[0] = (int32_t)obs_data_get_int(data, prm.uiNames[0].c_str());
|
||||
break;
|
||||
case GS::EffectParameter::Type::Texture:
|
||||
case gs::effect_parameter::type::Texture:
|
||||
prm.value.textureIsSource = obs_data_get_int(data, prm.uiNames[0].c_str()) == 1;
|
||||
std::string nName = obs_data_get_string(data, prm.uiNames[1].c_str());
|
||||
if (nName != prm.value.source.name) {
|
||||
|
@ -413,7 +413,7 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
|
|||
|
||||
// Render original source to texture.
|
||||
{
|
||||
auto op = m_renderTarget->Render(baseW, baseH);
|
||||
auto op = m_renderTarget->render(baseW, baseH);
|
||||
vec4 black; vec4_zero(&black);
|
||||
gs_ortho(0, (float_t)baseW, 0, (float_t)baseH, 0, 1);
|
||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||
|
@ -422,7 +422,7 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
|
|||
effect ? effect : obs_get_base_effect(OBS_EFFECT_DEFAULT), baseW, baseH);
|
||||
}
|
||||
}
|
||||
gs_texture_t* sourceTexture = m_renderTarget->GetTextureObject();
|
||||
gs_texture_t* sourceTexture = m_renderTarget->get_object();
|
||||
if (!sourceTexture) {
|
||||
obs_source_skip_video_filter(m_source);
|
||||
return;
|
||||
|
@ -430,54 +430,54 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
|
|||
|
||||
// Apply Parameters
|
||||
try {
|
||||
if (m_effect.effect->HasParameter("ViewSize", GS::EffectParameter::Type::Float2))
|
||||
m_effect.effect->GetParameter("ViewSize").SetFloat2(float_t(baseW), float_t(baseH));
|
||||
if (m_effect.effect->HasParameter("ViewSizeI", GS::EffectParameter::Type::Integer2))
|
||||
m_effect.effect->GetParameter("ViewSizeI").SetInteger2(baseW, baseH);
|
||||
if (m_effect.effect->HasParameter("Time", GS::EffectParameter::Type::Float))
|
||||
m_effect.effect->GetParameter("Time").SetFloat(m_renderTime);
|
||||
if (m_effect.effect->HasParameter("TimeActive", GS::EffectParameter::Type::Float))
|
||||
m_effect.effect->GetParameter("TimeActive").SetFloat(m_activeTime);
|
||||
if (m_effect.effect->has_parameter("ViewSize", gs::effect_parameter::type::Float2))
|
||||
m_effect.effect->get_parameter("ViewSize").set_float2(float_t(baseW), float_t(baseH));
|
||||
if (m_effect.effect->has_parameter("ViewSizeI", gs::effect_parameter::type::Integer2))
|
||||
m_effect.effect->get_parameter("ViewSizeI").set_int2(baseW, baseH);
|
||||
if (m_effect.effect->has_parameter("Time", gs::effect_parameter::type::Float))
|
||||
m_effect.effect->get_parameter("Time").set_float(m_renderTime);
|
||||
if (m_effect.effect->has_parameter("TimeActive", gs::effect_parameter::type::Float))
|
||||
m_effect.effect->get_parameter("TimeActive").set_float(m_activeTime);
|
||||
|
||||
/// "image" Specials
|
||||
if (m_effect.effect->HasParameter("image_Size", GS::EffectParameter::Type::Float2))
|
||||
m_effect.effect->GetParameter("image_Size").SetFloat2(float_t(baseW), float_t(baseH));
|
||||
if (m_effect.effect->HasParameter("image_SizeI", GS::EffectParameter::Type::Float2))
|
||||
m_effect.effect->GetParameter("image_SizeI").SetInteger2(baseW, baseH);
|
||||
if (m_effect.effect->HasParameter("image_Texel", GS::EffectParameter::Type::Float2))
|
||||
m_effect.effect->GetParameter("image_Texel").SetFloat2(1.0f / float_t(baseW), 1.0f / float_t(baseH));
|
||||
if (m_effect.effect->has_parameter("image_Size", gs::effect_parameter::type::Float2))
|
||||
m_effect.effect->get_parameter("image_Size").set_float2(float_t(baseW), float_t(baseH));
|
||||
if (m_effect.effect->has_parameter("image_SizeI", gs::effect_parameter::type::Float2))
|
||||
m_effect.effect->get_parameter("image_SizeI").set_int2(baseW, baseH);
|
||||
if (m_effect.effect->has_parameter("image_Texel", gs::effect_parameter::type::Float2))
|
||||
m_effect.effect->get_parameter("image_Texel").set_float2(1.0f / float_t(baseW), 1.0f / float_t(baseH));
|
||||
|
||||
for (Parameter& prm : m_effectParameters) {
|
||||
GS::EffectParameter eprm = m_effect.effect->GetParameter(prm.name);
|
||||
gs::effect_parameter eprm = m_effect.effect->get_parameter(prm.name);
|
||||
switch (prm.type) {
|
||||
case GS::EffectParameter::Type::Boolean:
|
||||
eprm.SetBoolean(prm.value.b);
|
||||
case gs::effect_parameter::type::Boolean:
|
||||
eprm.set_bool(prm.value.b);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer:
|
||||
eprm.SetInteger(prm.value.i[0]);
|
||||
case gs::effect_parameter::type::Integer:
|
||||
eprm.set_int(prm.value.i[0]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer2:
|
||||
eprm.SetInteger2(prm.value.i[0], prm.value.i[1]);
|
||||
case gs::effect_parameter::type::Integer2:
|
||||
eprm.set_int2(prm.value.i[0], prm.value.i[1]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer3:
|
||||
eprm.SetInteger3(prm.value.i[0], prm.value.i[1], prm.value.i[2]);
|
||||
case gs::effect_parameter::type::Integer3:
|
||||
eprm.set_int3(prm.value.i[0], prm.value.i[1], prm.value.i[2]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer4:
|
||||
eprm.SetInteger4(prm.value.i[0], prm.value.i[1], prm.value.i[2], prm.value.i[3]);
|
||||
case gs::effect_parameter::type::Integer4:
|
||||
eprm.set_int4(prm.value.i[0], prm.value.i[1], prm.value.i[2], prm.value.i[3]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float:
|
||||
eprm.SetFloat(prm.value.f[0]);
|
||||
case gs::effect_parameter::type::Float:
|
||||
eprm.set_float(prm.value.f[0]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float2:
|
||||
eprm.SetFloat2(prm.value.f[0], prm.value.f[1]);
|
||||
case gs::effect_parameter::type::Float2:
|
||||
eprm.set_float2(prm.value.f[0], prm.value.f[1]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float3:
|
||||
eprm.SetFloat3(prm.value.f[0], prm.value.f[1], prm.value.f[2]);
|
||||
case gs::effect_parameter::type::Float3:
|
||||
eprm.set_float3(prm.value.f[0], prm.value.f[1], prm.value.f[2]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float4:
|
||||
eprm.SetFloat4(prm.value.f[0], prm.value.f[1], prm.value.f[2], prm.value.f[3]);
|
||||
case gs::effect_parameter::type::Float4:
|
||||
eprm.set_float4(prm.value.f[0], prm.value.f[1], prm.value.f[2], prm.value.f[3]);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Texture:
|
||||
case gs::effect_parameter::type::Texture:
|
||||
if (prm.value.textureIsSource) {
|
||||
if (prm.value.source.rendertarget && prm.value.source.source) {
|
||||
uint32_t w, h;
|
||||
|
@ -490,11 +490,11 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
|
|||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||
obs_source_video_render(prm.value.source.source);
|
||||
}
|
||||
eprm.SetTexture(prm.value.source.rendertarget->GetTextureObject());
|
||||
eprm.set_texture(prm.value.source.rendertarget->GetTextureObject());
|
||||
}
|
||||
} else {
|
||||
if (prm.value.file.texture) {
|
||||
eprm.SetTexture(prm.value.file.texture);
|
||||
eprm.set_texture(prm.value.file.texture);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -508,7 +508,7 @@ void Filter::CustomShader::Instance::video_render(gs_effect_t *effect) {
|
|||
|
||||
gs_reset_blend_state();
|
||||
gs_enable_depth_test(false);
|
||||
while (gs_effect_loop(m_effect.effect->GetObject(), "Draw")) {
|
||||
while (gs_effect_loop(m_effect.effect->get_object(), "Draw")) {
|
||||
obs_source_draw(sourceTexture, 0, 0, baseW, baseH, false);
|
||||
}
|
||||
}
|
||||
|
@ -530,34 +530,34 @@ void Filter::CustomShader::Instance::get_properties(obs_properties_t *pr) {
|
|||
|
||||
for (Parameter& prm : m_effectParameters) {
|
||||
switch (prm.type) {
|
||||
case GS::EffectParameter::Type::Boolean:
|
||||
case gs::effect_parameter::type::Boolean:
|
||||
obs_properties_add_bool(pr, prm.uiNames[0].c_str(), prm.uiDescriptions[0].c_str());
|
||||
break;
|
||||
case GS::EffectParameter::Type::Float:
|
||||
case GS::EffectParameter::Type::Float2:
|
||||
case GS::EffectParameter::Type::Float3:
|
||||
case GS::EffectParameter::Type::Float4:
|
||||
case gs::effect_parameter::type::Float:
|
||||
case gs::effect_parameter::type::Float2:
|
||||
case gs::effect_parameter::type::Float3:
|
||||
case gs::effect_parameter::type::Float4:
|
||||
obs_properties_add_float(pr, prm.uiNames[0].c_str(), prm.uiDescriptions[0].c_str(), FLT_MIN, FLT_MAX, FLT_EPSILON);
|
||||
if (prm.type >= GS::EffectParameter::Type::Float2)
|
||||
if (prm.type >= gs::effect_parameter::type::Float2)
|
||||
obs_properties_add_float(pr, prm.uiNames[1].c_str(), prm.uiDescriptions[1].c_str(), FLT_MIN, FLT_MAX, FLT_EPSILON);
|
||||
if (prm.type >= GS::EffectParameter::Type::Float3)
|
||||
if (prm.type >= gs::effect_parameter::type::Float3)
|
||||
obs_properties_add_float(pr, prm.uiNames[2].c_str(), prm.uiDescriptions[2].c_str(), FLT_MIN, FLT_MAX, FLT_EPSILON);
|
||||
if (prm.type >= GS::EffectParameter::Type::Float4)
|
||||
if (prm.type >= gs::effect_parameter::type::Float4)
|
||||
obs_properties_add_float(pr, prm.uiNames[3].c_str(), prm.uiDescriptions[3].c_str(), FLT_MIN, FLT_MAX, FLT_EPSILON);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Integer:
|
||||
case GS::EffectParameter::Type::Integer2:
|
||||
case GS::EffectParameter::Type::Integer3:
|
||||
case GS::EffectParameter::Type::Integer4:
|
||||
case gs::effect_parameter::type::Integer:
|
||||
case gs::effect_parameter::type::Integer2:
|
||||
case gs::effect_parameter::type::Integer3:
|
||||
case gs::effect_parameter::type::Integer4:
|
||||
obs_properties_add_int(pr, prm.uiNames[0].c_str(), prm.uiDescriptions[0].c_str(), INT_MIN, INT_MAX, 1);
|
||||
if (prm.type >= GS::EffectParameter::Type::Integer2)
|
||||
if (prm.type >= gs::effect_parameter::type::Integer2)
|
||||
obs_properties_add_int(pr, prm.uiNames[1].c_str(), prm.uiDescriptions[1].c_str(), INT_MIN, INT_MAX, 1);
|
||||
if (prm.type >= GS::EffectParameter::Type::Integer3)
|
||||
if (prm.type >= gs::effect_parameter::type::Integer3)
|
||||
obs_properties_add_int(pr, prm.uiNames[2].c_str(), prm.uiDescriptions[2].c_str(), INT_MIN, INT_MAX, 1);
|
||||
if (prm.type >= GS::EffectParameter::Type::Integer4)
|
||||
if (prm.type >= gs::effect_parameter::type::Integer4)
|
||||
obs_properties_add_int(pr, prm.uiNames[3].c_str(), prm.uiDescriptions[3].c_str(), INT_MIN, INT_MAX, 1);
|
||||
break;
|
||||
case GS::EffectParameter::Type::Texture:
|
||||
case gs::effect_parameter::type::Texture:
|
||||
obs_property * pt = obs_properties_add_list(pr,
|
||||
prm.uiNames[0].c_str(),
|
||||
prm.uiDescriptions[0].c_str(),
|
||||
|
@ -635,7 +635,7 @@ void Filter::CustomShader::Instance::CheckShaderFile(std::string file, float_t t
|
|||
shaderContent[sz] = '\0';
|
||||
}
|
||||
|
||||
m_effect.effect = std::make_unique<GS::Effect>(shaderContent.data(), m_effect.path);
|
||||
m_effect.effect = std::make_unique<gs::effect>(shaderContent.data(), m_effect.path);
|
||||
} catch (std::runtime_error& ex) {
|
||||
const char* filterName = obs_source_get_name(m_source);
|
||||
P_LOG_ERROR("[%s] Shader loading failed with error(s): %s", filterName, ex.what());
|
||||
|
@ -650,7 +650,7 @@ std::string Filter::CustomShader::Instance::GetShaderFile() {
|
|||
void Filter::CustomShader::Instance::CheckTextures(float_t time) {
|
||||
|
||||
for (Parameter& prm : m_effectParameters) {
|
||||
if (prm.type != GS::EffectParameter::Type::Texture)
|
||||
if (prm.type != gs::effect_parameter::type::Texture)
|
||||
continue;
|
||||
|
||||
if (prm.value.textureIsSource) {
|
||||
|
@ -664,7 +664,7 @@ void Filter::CustomShader::Instance::CheckTextures(float_t time) {
|
|||
|
||||
// Ensure that a render target exists.
|
||||
if (!prm.value.source.rendertarget)
|
||||
prm.value.source.rendertarget = std::make_shared<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||
prm.value.source.rendertarget = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||
|
||||
// Finally check if the source property was modified or is empty.
|
||||
if (prm.value.source.dirty || !prm.value.source.source) {
|
||||
|
@ -711,7 +711,7 @@ void Filter::CustomShader::Instance::CheckTextures(float_t time) {
|
|||
if (doRefresh) {
|
||||
prm.value.file.dirty = false;
|
||||
try {
|
||||
prm.value.file.texture = std::make_shared<GS::Texture>(prm.value.file.path);
|
||||
prm.value.file.texture = std::make_shared<gs::texture>(prm.value.file.path);
|
||||
} catch (std::runtime_error& ex) {
|
||||
const char* filterName = obs_source_get_name(m_source);
|
||||
P_LOG_ERROR("[%s] Loading texture file '%s' failed with error(s): %s",
|
||||
|
@ -722,19 +722,19 @@ void Filter::CustomShader::Instance::CheckTextures(float_t time) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Filter::CustomShader::Instance::IsSpecialParameter(std::string name, GS::EffectParameter::Type type) {
|
||||
std::pair<std::string, GS::EffectParameter::Type> reservedParameters[] = {
|
||||
{ "ViewProj", GS::EffectParameter::Type::Matrix },
|
||||
{ "ViewSize", GS::EffectParameter::Type::Float2 },
|
||||
{ "ViewSizeI", GS::EffectParameter::Type::Integer2 },
|
||||
{ "Time", GS::EffectParameter::Type::Float },
|
||||
{ "TimeActive", GS::EffectParameter::Type::Float },
|
||||
{ "image", GS::EffectParameter::Type::Texture }
|
||||
bool Filter::CustomShader::Instance::IsSpecialParameter(std::string name, gs::effect_parameter::type type) {
|
||||
std::pair<std::string, gs::effect_parameter::type> reservedParameters[] = {
|
||||
{ "ViewProj", gs::effect_parameter::type::Matrix },
|
||||
{ "ViewSize", gs::effect_parameter::type::Float2 },
|
||||
{ "ViewSizeI", gs::effect_parameter::type::Integer2 },
|
||||
{ "Time", gs::effect_parameter::type::Float },
|
||||
{ "TimeActive", gs::effect_parameter::type::Float },
|
||||
{ "image", gs::effect_parameter::type::Texture }
|
||||
};
|
||||
std::pair<std::string, GS::EffectParameter::Type> textureParameters[] = {
|
||||
{ "Size", GS::EffectParameter::Type::Float2 },
|
||||
{ "SizeI", GS::EffectParameter::Type::Integer2 },
|
||||
{ "Texel", GS::EffectParameter::Type::Float2 }
|
||||
std::pair<std::string, gs::effect_parameter::type> textureParameters[] = {
|
||||
{ "Size", gs::effect_parameter::type::Float2 },
|
||||
{ "SizeI", gs::effect_parameter::type::Integer2 },
|
||||
{ "Texel", gs::effect_parameter::type::Float2 }
|
||||
};
|
||||
|
||||
for (auto& kv : reservedParameters) {
|
||||
|
@ -750,8 +750,8 @@ bool Filter::CustomShader::Instance::IsSpecialParameter(std::string name, GS::Ef
|
|||
secondPart = name.substr(posUnderscore + 1);
|
||||
|
||||
try {
|
||||
GS::EffectParameter prm = m_effect.effect->GetParameter(firstPart);
|
||||
if (prm.GetType() == GS::EffectParameter::Type::Texture) {
|
||||
gs::effect_parameter prm = m_effect.effect->get_parameter(firstPart);
|
||||
if (prm.get_type() == gs::effect_parameter::type::Texture) {
|
||||
for (auto& kv : reservedParameters) {
|
||||
if ((secondPart == kv.first) && (type == kv.second))
|
||||
return true;
|
||||
|
|
|
@ -70,12 +70,12 @@ namespace Filter {
|
|||
std::string GetShaderFile();
|
||||
void CheckTextures(float_t time);
|
||||
|
||||
bool IsSpecialParameter(std::string name, GS::EffectParameter::Type type);
|
||||
bool IsSpecialParameter(std::string name, gs::effect_parameter::type type);
|
||||
|
||||
private:
|
||||
obs_source_t * m_source;
|
||||
bool m_isActive = true;
|
||||
std::unique_ptr<GS::RenderTarget> m_renderTarget;
|
||||
std::unique_ptr<gs::rendertarget> m_renderTarget;
|
||||
|
||||
float_t m_activeTime, m_renderTime;
|
||||
|
||||
|
@ -85,12 +85,12 @@ namespace Filter {
|
|||
time_t createTime, modifiedTime;
|
||||
size_t size;
|
||||
float_t lastCheck;
|
||||
std::unique_ptr<GS::Effect> effect;
|
||||
std::unique_ptr<gs::effect> effect;
|
||||
} m_effect;
|
||||
|
||||
struct Parameter {
|
||||
std::string name;
|
||||
GS::EffectParameter::Type type;
|
||||
gs::effect_parameter::type type;
|
||||
|
||||
std::vector<std::string> uiNames;
|
||||
std::vector<std::string> uiDescriptions;
|
||||
|
@ -106,7 +106,7 @@ namespace Filter {
|
|||
bool dirty = false;
|
||||
std::string name;
|
||||
obs_source_t* source = nullptr;
|
||||
std::shared_ptr<GS::RenderTarget> rendertarget;
|
||||
std::shared_ptr<gs::rendertarget> rendertarget;
|
||||
} source;
|
||||
struct File {
|
||||
bool dirty = false;
|
||||
|
@ -114,7 +114,7 @@ namespace Filter {
|
|||
time_t createTime, modifiedTime;
|
||||
size_t fileSize;
|
||||
float_t lastCheck;
|
||||
std::shared_ptr<GS::Texture> texture;
|
||||
std::shared_ptr<gs::texture> texture;
|
||||
} file;
|
||||
} value;
|
||||
};
|
||||
|
|
|
@ -255,8 +255,8 @@ void Filter::Shape::video_render(void *ptr, gs_effect_t *effect) {
|
|||
Filter::Shape::Instance::Instance(obs_data_t *data, obs_source_t *context)
|
||||
: context(context) {
|
||||
obs_enter_graphics();
|
||||
m_vertexHelper = new GS::VertexBuffer(maximumPoints);
|
||||
m_vertexHelper->SetUVLayers(1);
|
||||
m_vertexHelper = new gs::vertex_buffer(maximumPoints);
|
||||
m_vertexHelper->set_uv_layers(1);
|
||||
m_texRender = gs_texrender_create(GS_RGBA, GS_Z32F);
|
||||
obs_leave_graphics();
|
||||
|
||||
|
@ -271,9 +271,9 @@ Filter::Shape::Instance::~Instance() {
|
|||
|
||||
void Filter::Shape::Instance::update(obs_data_t *data) {
|
||||
uint32_t points = (uint32_t)obs_data_get_int(data, P_SHAPE_POINTS);
|
||||
m_vertexHelper->Resize(points);
|
||||
m_vertexHelper->resize(points);
|
||||
for (uint32_t point = 0; point < points; point++) {
|
||||
GS::Vertex v = m_vertexHelper->At(point);
|
||||
gs::vertex v = m_vertexHelper->at(point);
|
||||
{
|
||||
auto strings = cache.find(std::make_pair(point,
|
||||
P_SHAPE_POINT_X));
|
||||
|
@ -311,7 +311,7 @@ void Filter::Shape::Instance::update(obs_data_t *data) {
|
|||
}
|
||||
drawmode = (gs_draw_mode)obs_data_get_int(data, P_SHAPE_MODE);
|
||||
obs_enter_graphics();
|
||||
m_vertexBuffer = m_vertexHelper->Update();
|
||||
m_vertexBuffer = m_vertexHelper->update();
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
|
@ -386,7 +386,7 @@ void Filter::Shape::Instance::video_render(gs_effect_t *effect) {
|
|||
tex);
|
||||
gs_load_vertexbuffer(m_vertexBuffer);
|
||||
gs_load_indexbuffer(nullptr);
|
||||
gs_draw(drawmode, 0, (uint32_t)m_vertexHelper->Size());
|
||||
gs_draw(drawmode, 0, (uint32_t)m_vertexHelper->size());
|
||||
}
|
||||
|
||||
gs_matrix_pop();
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace Filter {
|
|||
private:
|
||||
obs_source_t *context;
|
||||
gs_effect_t *customEffect;
|
||||
GS::VertexBuffer *m_vertexHelper;
|
||||
gs::vertex_buffer *m_vertexHelper;
|
||||
gs_vertbuffer_t *m_vertexBuffer;
|
||||
gs_draw_mode drawmode;
|
||||
gs_texrender_t *m_texRender;
|
||||
|
|
|
@ -304,9 +304,9 @@ Filter::Transform::Instance::Instance(obs_data_t *data, obs_source_t *context) :
|
|||
obs_enter_graphics();
|
||||
m_texRender = gs_texrender_create(GS_RGBA, GS_ZS_NONE);
|
||||
m_shapeRender = gs_texrender_create(GS_RGBA, GS_ZS_NONE);
|
||||
m_vertexHelper = new GS::VertexBuffer(4);
|
||||
m_vertexHelper->SetUVLayers(1);
|
||||
m_vertexHelper->Resize(4);
|
||||
m_vertexHelper = new gs::vertex_buffer(4);
|
||||
m_vertexHelper->set_uv_layers(1);
|
||||
m_vertexHelper->resize(4);
|
||||
obs_leave_graphics();
|
||||
|
||||
update(data);
|
||||
|
@ -465,7 +465,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
|
|||
|
||||
/// Generate mesh
|
||||
{
|
||||
GS::Vertex vtx = m_vertexHelper->At(0);
|
||||
gs::vertex vtx = m_vertexHelper->at(0);
|
||||
*vtx.color = 0xFFFFFFFF;
|
||||
vec4_set(vtx.uv[0], 0, 0, 0, 0);
|
||||
vec3_set(vtx.position,
|
||||
|
@ -474,7 +474,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
|
|||
vec3_transform(vtx.position, vtx.position, &ident);
|
||||
}
|
||||
{
|
||||
GS::Vertex vtx = m_vertexHelper->At(1);
|
||||
gs::vertex vtx = m_vertexHelper->at(1);
|
||||
*vtx.color = 0xFFFFFFFF;
|
||||
vec4_set(vtx.uv[0], 1, 0, 0, 0);
|
||||
vec3_set(vtx.position,
|
||||
|
@ -483,7 +483,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
|
|||
vec3_transform(vtx.position, vtx.position, &ident);
|
||||
}
|
||||
{
|
||||
GS::Vertex vtx = m_vertexHelper->At(2);
|
||||
gs::vertex vtx = m_vertexHelper->at(2);
|
||||
*vtx.color = 0xFFFFFFFF;
|
||||
vec4_set(vtx.uv[0], 0, 1, 0, 0);
|
||||
vec3_set(vtx.position,
|
||||
|
@ -492,7 +492,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
|
|||
vec3_transform(vtx.position, vtx.position, &ident);
|
||||
}
|
||||
{
|
||||
GS::Vertex vtx = m_vertexHelper->At(3);
|
||||
gs::vertex vtx = m_vertexHelper->at(3);
|
||||
*vtx.color = 0xFFFFFFFF;
|
||||
vec4_set(vtx.uv[0], 1, 1, 0, 0);
|
||||
vec3_set(vtx.position,
|
||||
|
@ -501,7 +501,7 @@ void Filter::Transform::Instance::video_render(gs_effect_t *paramEffect) {
|
|||
vec3_transform(vtx.position, vtx.position, &ident);
|
||||
}
|
||||
|
||||
m_vertexBuffer = m_vertexHelper->Update();
|
||||
m_vertexBuffer = m_vertexHelper->update();
|
||||
if (!m_vertexBuffer) {
|
||||
obs_source_skip_video_filter(m_sourceContext);
|
||||
return;
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Filter {
|
|||
|
||||
private:
|
||||
obs_source_t *m_sourceContext;
|
||||
GS::VertexBuffer *m_vertexHelper;
|
||||
gs::vertex_buffer *m_vertexHelper;
|
||||
gs_vertbuffer_t *m_vertexBuffer;
|
||||
gs_texrender_t *m_texRender, *m_shapeRender;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ gfx::SourceTexture::~SourceTexture() {
|
|||
}
|
||||
|
||||
gfx::SourceTexture::SourceTexture() {
|
||||
m_rt = std::make_shared<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||
m_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||
}
|
||||
|
||||
obs_source_t* gfx::SourceTexture::GetObject() {
|
||||
|
@ -49,7 +49,7 @@ gfx::SourceTexture::SourceTexture(obs_source_t* src) : SourceTexture() {
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<GS::Texture> gfx::SourceTexture::Render(size_t width, size_t height) {
|
||||
std::shared_ptr<gs::texture> gfx::SourceTexture::Render(size_t width, size_t height) {
|
||||
if (!m_source) {
|
||||
throw std::invalid_argument("Missing source to render.");
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ std::shared_ptr<GS::Texture> gfx::SourceTexture::Render(size_t width, size_t hei
|
|||
obs_source_video_render(m_source);
|
||||
}
|
||||
|
||||
std::shared_ptr<GS::Texture> tex;
|
||||
std::shared_ptr<gs::texture> tex;
|
||||
m_rt->GetTexture(tex);
|
||||
return tex;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
namespace gfx {
|
||||
class SourceTexture {
|
||||
obs_source_t* m_source;
|
||||
std::shared_ptr<GS::RenderTarget> m_rt;
|
||||
std::shared_ptr<gs::rendertarget> m_rt;
|
||||
|
||||
SourceTexture();
|
||||
public:
|
||||
|
@ -36,6 +36,6 @@ namespace gfx {
|
|||
|
||||
obs_source_t* GetObject();
|
||||
|
||||
std::shared_ptr<GS::Texture> Render(size_t width, size_t height);
|
||||
std::shared_ptr<gs::texture> Render(size_t width, size_t height);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::Effect::Effect() {
|
||||
gs::effect::effect() {
|
||||
m_effect = nullptr;
|
||||
}
|
||||
|
||||
GS::Effect::Effect(std::string file) {
|
||||
gs::effect::effect(std::string file) {
|
||||
obs_enter_graphics();
|
||||
char* errorMessage = nullptr;
|
||||
m_effect = gs_effect_create_from_file(file.c_str(), &errorMessage);
|
||||
|
@ -46,7 +46,7 @@ GS::Effect::Effect(std::string file) {
|
|||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::Effect::Effect(std::string code, std::string name) {
|
||||
gs::effect::effect(std::string code, std::string name) {
|
||||
obs_enter_graphics();
|
||||
char* errorMessage = nullptr;
|
||||
m_effect = gs_effect_create(code.c_str(), name.c_str(), &errorMessage);
|
||||
|
@ -62,57 +62,57 @@ GS::Effect::Effect(std::string code, std::string name) {
|
|||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::Effect::~Effect() {
|
||||
gs::effect::~effect() {
|
||||
obs_enter_graphics();
|
||||
gs_effect_destroy(m_effect);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
gs_effect_t* GS::Effect::GetObject() {
|
||||
gs_effect_t* gs::effect::get_object() {
|
||||
return m_effect;
|
||||
}
|
||||
|
||||
size_t GS::Effect::CountParameters() {
|
||||
size_t gs::effect::count_parameters() {
|
||||
return (size_t)gs_effect_get_num_params(m_effect);
|
||||
}
|
||||
|
||||
std::list<GS::EffectParameter> GS::Effect::GetParameters() {
|
||||
std::list<gs::effect_parameter> gs::effect::get_parameters() {
|
||||
size_t num = gs_effect_get_num_params(m_effect);
|
||||
std::list<GS::EffectParameter> ps;
|
||||
std::list<gs::effect_parameter> ps;
|
||||
for (size_t idx = 0; idx < num; idx++) {
|
||||
ps.emplace_back(GetParameter(idx));
|
||||
ps.emplace_back(get_parameter(idx));
|
||||
}
|
||||
return ps;
|
||||
}
|
||||
|
||||
GS::EffectParameter GS::Effect::GetParameter(size_t idx) {
|
||||
gs::effect_parameter gs::effect::get_parameter(size_t idx) {
|
||||
gs_eparam_t* param = gs_effect_get_param_by_idx(m_effect, idx);
|
||||
if (!param)
|
||||
throw std::invalid_argument("parameter with index not found");
|
||||
return EffectParameter(param);
|
||||
return effect_parameter(param);
|
||||
}
|
||||
|
||||
bool GS::Effect::HasParameter(std::string name) {
|
||||
bool gs::effect::has_parameter(std::string name) {
|
||||
gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str());
|
||||
return (param != nullptr);
|
||||
}
|
||||
|
||||
bool GS::Effect::HasParameter(std::string name, EffectParameter::Type type) {
|
||||
bool gs::effect::has_parameter(std::string name, effect_parameter::type type) {
|
||||
gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str());
|
||||
if (param == nullptr)
|
||||
return false;
|
||||
GS::EffectParameter eprm(param);
|
||||
return eprm.GetType() == type;
|
||||
gs::effect_parameter eprm(param);
|
||||
return eprm.get_type() == type;
|
||||
}
|
||||
|
||||
GS::EffectParameter GS::Effect::GetParameter(std::string name) {
|
||||
gs::effect_parameter gs::effect::get_parameter(std::string name) {
|
||||
gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str());
|
||||
if (!param)
|
||||
throw std::invalid_argument("parameter with name not found");
|
||||
return EffectParameter(param);
|
||||
return effect_parameter(param);
|
||||
}
|
||||
|
||||
GS::EffectParameter::EffectParameter(gs_eparam_t* param) {
|
||||
gs::effect_parameter::effect_parameter(gs_eparam_t* param) {
|
||||
if (!param)
|
||||
throw std::invalid_argument("param is null");
|
||||
|
||||
|
@ -120,164 +120,164 @@ GS::EffectParameter::EffectParameter(gs_eparam_t* param) {
|
|||
gs_effect_get_param_info(m_param, &m_paramInfo);
|
||||
}
|
||||
|
||||
std::string GS::EffectParameter::GetName() {
|
||||
std::string gs::effect_parameter::get_name() {
|
||||
return m_paramInfo.name;
|
||||
}
|
||||
|
||||
GS::EffectParameter::Type GS::EffectParameter::GetType() {
|
||||
gs::effect_parameter::type gs::effect_parameter::get_type() {
|
||||
switch (m_paramInfo.type) {
|
||||
case GS_SHADER_PARAM_BOOL:
|
||||
return Type::Boolean;
|
||||
return type::Boolean;
|
||||
case GS_SHADER_PARAM_FLOAT:
|
||||
return Type::Float;
|
||||
return type::Float;
|
||||
case GS_SHADER_PARAM_VEC2:
|
||||
return Type::Float2;
|
||||
return type::Float2;
|
||||
case GS_SHADER_PARAM_VEC3:
|
||||
return Type::Float3;
|
||||
return type::Float3;
|
||||
case GS_SHADER_PARAM_VEC4:
|
||||
return Type::Float4;
|
||||
return type::Float4;
|
||||
case GS_SHADER_PARAM_INT:
|
||||
return Type::Integer;
|
||||
return type::Integer;
|
||||
case GS_SHADER_PARAM_INT2:
|
||||
return Type::Integer2;
|
||||
return type::Integer2;
|
||||
case GS_SHADER_PARAM_INT3:
|
||||
return Type::Integer3;
|
||||
return type::Integer3;
|
||||
case GS_SHADER_PARAM_INT4:
|
||||
return Type::Integer4;
|
||||
return type::Integer4;
|
||||
case GS_SHADER_PARAM_MATRIX4X4:
|
||||
return Type::Matrix;
|
||||
return type::Matrix;
|
||||
case GS_SHADER_PARAM_TEXTURE:
|
||||
return Type::Texture;
|
||||
return type::Texture;
|
||||
//case GS_SHADER_PARAM_STRING:
|
||||
// return Type::String;
|
||||
default:
|
||||
case GS_SHADER_PARAM_UNKNOWN:
|
||||
return Type::Unknown;
|
||||
return type::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetBoolean(bool v) {
|
||||
if (GetType() != Type::Boolean)
|
||||
void gs::effect_parameter::set_bool(bool v) {
|
||||
if (get_type() != type::Boolean)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_bool(m_param, v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetBooleanArray(bool v[], size_t sz) {
|
||||
if (GetType() != Type::Boolean)
|
||||
void gs::effect_parameter::set_bool_array(bool v[], size_t sz) {
|
||||
if (get_type() != type::Boolean)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_val(m_param, v, sz);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat(float_t x) {
|
||||
if (GetType() != Type::Float)
|
||||
void gs::effect_parameter::set_float(float_t x) {
|
||||
if (get_type() != type::Float)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_float(m_param, x);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat2(vec2& v) {
|
||||
if (GetType() != Type::Float2)
|
||||
void gs::effect_parameter::set_float2(vec2& v) {
|
||||
if (get_type() != type::Float2)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_vec2(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat2(float_t x, float_t y) {
|
||||
if (GetType() != Type::Float2)
|
||||
void gs::effect_parameter::set_float2(float_t x, float_t y) {
|
||||
if (get_type() != type::Float2)
|
||||
throw std::bad_cast();
|
||||
vec2 v = { x, y };
|
||||
gs_effect_set_vec2(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat3(vec3& v) {
|
||||
if (GetType() != Type::Float3)
|
||||
void gs::effect_parameter::set_float3(vec3& v) {
|
||||
if (get_type() != type::Float3)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_vec3(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat3(float_t x, float_t y, float_t z) {
|
||||
if (GetType() != Type::Float3)
|
||||
void gs::effect_parameter::set_float3(float_t x, float_t y, float_t z) {
|
||||
if (get_type() != type::Float3)
|
||||
throw std::bad_cast();
|
||||
vec3 v = { x, y, z };
|
||||
gs_effect_set_vec3(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat4(vec4& v) {
|
||||
if (GetType() != Type::Float4)
|
||||
void gs::effect_parameter::set_float4(vec4& v) {
|
||||
if (get_type() != type::Float4)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_vec4(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloat4(float_t x, float_t y, float_t z, float_t w) {
|
||||
if (GetType() != Type::Float4)
|
||||
void gs::effect_parameter::set_float4(float_t x, float_t y, float_t z, float_t w) {
|
||||
if (get_type() != type::Float4)
|
||||
throw std::bad_cast();
|
||||
vec4 v = { x, y, z, w };
|
||||
gs_effect_set_vec4(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetFloatArray(float_t v[], size_t sz) {
|
||||
if ((GetType() != Type::Float) && (GetType() != Type::Float2) && (GetType() != Type::Float3) && (GetType() != Type::Float4))
|
||||
void gs::effect_parameter::set_float_array(float_t v[], size_t sz) {
|
||||
if ((get_type() != type::Float) && (get_type() != type::Float2) && (get_type() != type::Float3) && (get_type() != type::Float4))
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_val(m_param, v, sizeof(float_t) * sz);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetInteger(int32_t x) {
|
||||
if (GetType() != Type::Integer)
|
||||
void gs::effect_parameter::set_int(int32_t x) {
|
||||
if (get_type() != type::Integer)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_int(m_param, x);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetInteger2(int32_t x, int32_t y) {
|
||||
if (GetType() != Type::Integer2)
|
||||
void gs::effect_parameter::set_int2(int32_t x, int32_t y) {
|
||||
if (get_type() != type::Integer2)
|
||||
throw std::bad_cast();
|
||||
int32_t v[] = { x, y };
|
||||
gs_effect_set_val(m_param, v, sizeof(int) * 2);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetInteger3(int32_t x, int32_t y, int32_t z) {
|
||||
if (GetType() != Type::Integer3)
|
||||
void gs::effect_parameter::set_int3(int32_t x, int32_t y, int32_t z) {
|
||||
if (get_type() != type::Integer3)
|
||||
throw std::bad_cast();
|
||||
int32_t v[] = { x, y, z };
|
||||
gs_effect_set_val(m_param, v, sizeof(int) * 3);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetInteger4(int32_t x, int32_t y, int32_t z, int32_t w) {
|
||||
if (GetType() != Type::Integer4)
|
||||
void gs::effect_parameter::set_int4(int32_t x, int32_t y, int32_t z, int32_t w) {
|
||||
if (get_type() != type::Integer4)
|
||||
throw std::bad_cast();
|
||||
int32_t v[] = { x, y, z, w };
|
||||
gs_effect_set_val(m_param, v, sizeof(int) * 4);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetIntegerArray(int32_t v[], size_t sz) {
|
||||
if ((GetType() != Type::Integer) && (GetType() != Type::Integer2) && (GetType() != Type::Integer3) && (GetType() != Type::Integer4))
|
||||
void gs::effect_parameter::set_int_array(int32_t v[], size_t sz) {
|
||||
if ((get_type() != type::Integer) && (get_type() != type::Integer2) && (get_type() != type::Integer3) && (get_type() != type::Integer4))
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_val(m_param, v, sizeof(int) * sz);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetMatrix(matrix4& v) {
|
||||
if (GetType() != Type::Matrix)
|
||||
void gs::effect_parameter::set_matrix(matrix4& v) {
|
||||
if (get_type() != type::Matrix)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_matrix4(m_param, &v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetTexture(std::shared_ptr<GS::Texture> v) {
|
||||
if (GetType() != Type::Texture)
|
||||
void gs::effect_parameter::set_texture(std::shared_ptr<gs::texture> v) {
|
||||
if (get_type() != type::Texture)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_texture(m_param, v->GetObject());
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetTexture(gs_texture_t* v) {
|
||||
if (GetType() != Type::Texture)
|
||||
void gs::effect_parameter::set_texture(gs_texture_t* v) {
|
||||
if (get_type() != type::Texture)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_texture(m_param, v);
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetSampler(std::shared_ptr<GS::Sampler> v) {
|
||||
if (GetType() != Type::Texture)
|
||||
void gs::effect_parameter::set_sampler(std::shared_ptr<gs::sampler> v) {
|
||||
if (get_type() != type::Texture)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_next_sampler(m_param, v->GetObject());
|
||||
}
|
||||
|
||||
void GS::EffectParameter::SetSampler(gs_sampler_state* v) {
|
||||
if (GetType() != Type::Texture)
|
||||
void gs::effect_parameter::set_sampler(gs_sampler_state* v) {
|
||||
if (get_type() != type::Texture)
|
||||
throw std::bad_cast();
|
||||
gs_effect_set_next_sampler(m_param, v);
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class EffectParameter {
|
||||
namespace gs {
|
||||
class effect_parameter {
|
||||
public:
|
||||
enum class Type : uint8_t {
|
||||
enum class type : uint8_t {
|
||||
Unknown,
|
||||
Boolean,
|
||||
Float,
|
||||
|
@ -55,52 +55,52 @@ namespace GS {
|
|||
};
|
||||
|
||||
public:
|
||||
EffectParameter(gs_eparam_t* param);
|
||||
effect_parameter(gs_eparam_t* param);
|
||||
|
||||
std::string GetName();
|
||||
Type GetType();
|
||||
std::string get_name();
|
||||
type get_type();
|
||||
|
||||
void SetBoolean(bool v);
|
||||
void SetBooleanArray(bool v[], size_t sz);
|
||||
void SetFloat(float_t x);
|
||||
void SetFloat2(vec2& v);
|
||||
void SetFloat2(float_t x, float_t y);
|
||||
void SetFloat3(vec3& v);
|
||||
void SetFloat3(float_t x, float_t y, float_t z);
|
||||
void SetFloat4(vec4& v);
|
||||
void SetFloat4(float_t x, float_t y, float_t z, float_t w);
|
||||
void SetFloatArray(float_t v[], size_t sz);
|
||||
void SetInteger(int32_t x);
|
||||
void SetInteger2(int32_t x, int32_t y);
|
||||
void SetInteger3(int32_t x, int32_t y, int32_t z);
|
||||
void SetInteger4(int32_t x, int32_t y, int32_t z, int32_t w);
|
||||
void SetIntegerArray(int32_t v[], size_t sz);
|
||||
void SetMatrix(matrix4& v);
|
||||
void SetTexture(std::shared_ptr<GS::Texture> v);
|
||||
void SetTexture(gs_texture_t* v);
|
||||
void SetSampler(std::shared_ptr<GS::Sampler> v);
|
||||
void SetSampler(gs_sampler_state* v);
|
||||
void set_bool(bool v);
|
||||
void set_bool_array(bool v[], size_t sz);
|
||||
void set_float(float_t x);
|
||||
void set_float2(vec2& v);
|
||||
void set_float2(float_t x, float_t y);
|
||||
void set_float3(vec3& v);
|
||||
void set_float3(float_t x, float_t y, float_t z);
|
||||
void set_float4(vec4& v);
|
||||
void set_float4(float_t x, float_t y, float_t z, float_t w);
|
||||
void set_float_array(float_t v[], size_t sz);
|
||||
void set_int(int32_t x);
|
||||
void set_int2(int32_t x, int32_t y);
|
||||
void set_int3(int32_t x, int32_t y, int32_t z);
|
||||
void set_int4(int32_t x, int32_t y, int32_t z, int32_t w);
|
||||
void set_int_array(int32_t v[], size_t sz);
|
||||
void set_matrix(matrix4& v);
|
||||
void set_texture(std::shared_ptr<gs::texture> v);
|
||||
void set_texture(gs_texture_t* v);
|
||||
void set_sampler(std::shared_ptr<gs::sampler> v);
|
||||
void set_sampler(gs_sampler_state* v);
|
||||
|
||||
private:
|
||||
gs_eparam_t* m_param;
|
||||
gs_effect_param_info m_paramInfo;
|
||||
};
|
||||
|
||||
class Effect {
|
||||
class effect {
|
||||
public:
|
||||
Effect();
|
||||
Effect(std::string file);
|
||||
Effect(std::string code, std::string name);
|
||||
virtual ~Effect();
|
||||
effect();
|
||||
effect(std::string file);
|
||||
effect(std::string code, std::string name);
|
||||
virtual ~effect();
|
||||
|
||||
gs_effect_t* GetObject();
|
||||
gs_effect_t* get_object();
|
||||
|
||||
size_t CountParameters();
|
||||
std::list<EffectParameter> GetParameters();
|
||||
EffectParameter GetParameter(size_t idx);
|
||||
EffectParameter GetParameter(std::string name);
|
||||
bool HasParameter(std::string name);
|
||||
bool HasParameter(std::string name, EffectParameter::Type type);
|
||||
size_t count_parameters();
|
||||
std::list<effect_parameter> get_parameters();
|
||||
effect_parameter get_parameter(size_t idx);
|
||||
effect_parameter get_parameter(std::string name);
|
||||
bool has_parameter(std::string name);
|
||||
bool has_parameter(std::string name, effect_parameter::type type);
|
||||
|
||||
protected:
|
||||
gs_effect_t* m_effect;
|
||||
|
|
|
@ -26,7 +26,7 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::IndexBuffer::IndexBuffer(uint32_t maximumVertices) {
|
||||
gs::index_buffer::index_buffer(uint32_t maximumVertices) {
|
||||
this->reserve(maximumVertices);
|
||||
|
||||
obs_enter_graphics();
|
||||
|
@ -34,27 +34,27 @@ GS::IndexBuffer::IndexBuffer(uint32_t maximumVertices) {
|
|||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::IndexBuffer::IndexBuffer() : IndexBuffer(MAXIMUM_VERTICES) {}
|
||||
gs::index_buffer::index_buffer() : index_buffer(MAXIMUM_VERTICES) {}
|
||||
|
||||
GS::IndexBuffer::IndexBuffer(IndexBuffer& other) : IndexBuffer((uint32_t)other.size()) {
|
||||
gs::index_buffer::index_buffer(index_buffer& other) : index_buffer((uint32_t)other.size()) {
|
||||
std::copy(other.begin(), other.end(), this->end());
|
||||
}
|
||||
|
||||
GS::IndexBuffer::IndexBuffer(std::vector<uint32_t>& other) : IndexBuffer((uint32_t)other.size()) {
|
||||
gs::index_buffer::index_buffer(std::vector<uint32_t>& other) : index_buffer((uint32_t)other.size()) {
|
||||
std::copy(other.begin(), other.end(), this->end());
|
||||
}
|
||||
|
||||
GS::IndexBuffer::~IndexBuffer() {
|
||||
gs::index_buffer::~index_buffer() {
|
||||
obs_enter_graphics();
|
||||
gs_indexbuffer_destroy(m_indexBuffer);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
gs_indexbuffer_t* GS::IndexBuffer::get() {
|
||||
gs_indexbuffer_t* gs::index_buffer::get() {
|
||||
return get(true);
|
||||
}
|
||||
|
||||
gs_indexbuffer_t* GS::IndexBuffer::get(bool refreshGPU) {
|
||||
gs_indexbuffer_t* gs::index_buffer::get(bool refreshGPU) {
|
||||
if (refreshGPU) {
|
||||
obs_enter_graphics();
|
||||
gs_indexbuffer_flush(m_indexBuffer);
|
||||
|
|
|
@ -27,14 +27,14 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class IndexBuffer : public std::vector<uint32_t> {
|
||||
namespace gs {
|
||||
class index_buffer : public std::vector<uint32_t> {
|
||||
public:
|
||||
IndexBuffer(uint32_t maximumVertices);
|
||||
IndexBuffer();
|
||||
IndexBuffer(IndexBuffer& other);
|
||||
IndexBuffer(std::vector<uint32_t>& other);
|
||||
virtual ~IndexBuffer();
|
||||
index_buffer(uint32_t maximumVertices);
|
||||
index_buffer();
|
||||
index_buffer(index_buffer& other);
|
||||
index_buffer(std::vector<uint32_t>& other);
|
||||
virtual ~index_buffer();
|
||||
|
||||
gs_indexbuffer_t* get();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#pragma once
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace GS {
|
||||
namespace gs {
|
||||
static const uint32_t MAXIMUM_VERTICES = 0xFFFFFFu;
|
||||
static const uint32_t MAXIMUM_UVW_LAYERS = 8u;
|
||||
}
|
|
@ -26,43 +26,43 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::RenderTarget::RenderTarget(gs_color_format colorFormat, gs_zstencil_format zsFormat) {
|
||||
gs::rendertarget::rendertarget(gs_color_format colorFormat, gs_zstencil_format zsFormat) {
|
||||
m_isBeingRendered = false;
|
||||
obs_enter_graphics();
|
||||
m_renderTarget = gs_texrender_create(colorFormat, zsFormat);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::RenderTarget::~RenderTarget() {
|
||||
gs::rendertarget::~rendertarget() {
|
||||
obs_enter_graphics();
|
||||
gs_texrender_destroy(m_renderTarget);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::RenderTargetOp GS::RenderTarget::Render(uint32_t width, uint32_t height) {
|
||||
gs::rendertarget_op gs::rendertarget::render(uint32_t width, uint32_t height) {
|
||||
return { this, width, height };
|
||||
}
|
||||
|
||||
gs_texture_t* GS::RenderTarget::GetTextureObject() {
|
||||
gs_texture_t* gs::rendertarget::get_object() {
|
||||
obs_enter_graphics();
|
||||
gs_texture_t* tex = gs_texrender_get_texture(m_renderTarget);
|
||||
obs_leave_graphics();
|
||||
return tex;
|
||||
}
|
||||
|
||||
void GS::RenderTarget::GetTexture(GS::Texture& tex) {
|
||||
tex = GS::Texture(GetTextureObject(), false);
|
||||
void gs::rendertarget::get_texture(gs::texture& tex) {
|
||||
tex = gs::texture(get_object(), false);
|
||||
}
|
||||
|
||||
void GS::RenderTarget::GetTexture(std::shared_ptr<GS::Texture>& tex) {
|
||||
tex = std::make_shared<GS::Texture>(GetTextureObject(), false);
|
||||
void gs::rendertarget::get_texture(std::shared_ptr<gs::texture>& tex) {
|
||||
tex = std::make_shared<gs::texture>(get_object(), false);
|
||||
}
|
||||
|
||||
void GS::RenderTarget::GetTexture(std::unique_ptr<GS::Texture>& tex) {
|
||||
tex = std::make_unique<GS::Texture>(GetTextureObject(), false);
|
||||
void gs::rendertarget::get_texture(std::unique_ptr<gs::texture>& tex) {
|
||||
tex = std::make_unique<gs::texture>(get_object(), false);
|
||||
}
|
||||
|
||||
GS::RenderTargetOp::RenderTargetOp(GS::RenderTarget* rt, uint32_t width, uint32_t height) : m_renderTarget(rt) {
|
||||
gs::rendertarget_op::rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height) : m_renderTarget(rt) {
|
||||
if (m_renderTarget == nullptr)
|
||||
throw std::invalid_argument("rt");
|
||||
if (m_renderTarget->m_isBeingRendered)
|
||||
|
@ -77,12 +77,12 @@ GS::RenderTargetOp::RenderTargetOp(GS::RenderTarget* rt, uint32_t width, uint32_
|
|||
m_renderTarget->m_isBeingRendered = true;
|
||||
}
|
||||
|
||||
GS::RenderTargetOp::RenderTargetOp(GS::RenderTargetOp&& r) {
|
||||
gs::rendertarget_op::rendertarget_op(gs::rendertarget_op&& r) {
|
||||
this->m_renderTarget = r.m_renderTarget;
|
||||
r.m_renderTarget = nullptr;
|
||||
}
|
||||
|
||||
GS::RenderTargetOp::~RenderTargetOp() {
|
||||
gs::rendertarget_op::~rendertarget_op() {
|
||||
if (m_renderTarget == nullptr)
|
||||
return;
|
||||
obs_enter_graphics();
|
||||
|
|
|
@ -28,38 +28,38 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class RenderTarget {
|
||||
friend class RenderTargetOp;
|
||||
namespace gs {
|
||||
class rendertarget {
|
||||
friend class rendertarget_op;
|
||||
|
||||
public:
|
||||
RenderTarget(gs_color_format colorFormat, gs_zstencil_format zsFormat);
|
||||
virtual ~RenderTarget();
|
||||
rendertarget(gs_color_format colorFormat, gs_zstencil_format zsFormat);
|
||||
virtual ~rendertarget();
|
||||
|
||||
gs_texture_t* GetTextureObject();
|
||||
void GetTexture(GS::Texture& tex);
|
||||
void GetTexture(std::shared_ptr<GS::Texture>& tex);
|
||||
void GetTexture(std::unique_ptr<GS::Texture>& tex);
|
||||
GS::RenderTargetOp Render(uint32_t width, uint32_t height);
|
||||
gs_texture_t* get_object();
|
||||
void get_texture(gs::texture& tex);
|
||||
void get_texture(std::shared_ptr<gs::texture>& tex);
|
||||
void get_texture(std::unique_ptr<gs::texture>& tex);
|
||||
gs::rendertarget_op render(uint32_t width, uint32_t height);
|
||||
|
||||
protected:
|
||||
gs_texrender_t* m_renderTarget;
|
||||
bool m_isBeingRendered;
|
||||
};
|
||||
|
||||
class RenderTargetOp {
|
||||
class rendertarget_op {
|
||||
public:
|
||||
RenderTargetOp(GS::RenderTarget* rt, uint32_t width, uint32_t height);
|
||||
virtual ~RenderTargetOp();
|
||||
rendertarget_op(gs::rendertarget* rt, uint32_t width, uint32_t height);
|
||||
virtual ~rendertarget_op();
|
||||
|
||||
// Move Constructor
|
||||
RenderTargetOp(GS::RenderTargetOp&&);
|
||||
rendertarget_op(gs::rendertarget_op&&);
|
||||
|
||||
// Copy Constructor
|
||||
RenderTargetOp(const GS::RenderTargetOp&) = delete;
|
||||
RenderTargetOp& operator=(const GS::RenderTargetOp& r) = delete;
|
||||
rendertarget_op(const gs::rendertarget_op&) = delete;
|
||||
rendertarget_op& operator=(const gs::rendertarget_op& r) = delete;
|
||||
|
||||
protected:
|
||||
GS::RenderTarget* m_renderTarget;
|
||||
gs::rendertarget* m_renderTarget;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,77 +19,77 @@
|
|||
|
||||
#include "gs-sampler.h"
|
||||
|
||||
GS::Sampler::Sampler() {
|
||||
gs::sampler::sampler() {
|
||||
m_dirty = true;
|
||||
m_samplerInfo = { GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0 };
|
||||
m_samplerState = nullptr;
|
||||
}
|
||||
|
||||
GS::Sampler::~Sampler() {
|
||||
gs::sampler::~sampler() {
|
||||
if (m_samplerState)
|
||||
gs_samplerstate_destroy(m_samplerState);
|
||||
}
|
||||
|
||||
void GS::Sampler::SetSampleFilter(gs_sample_filter v) {
|
||||
void gs::sampler::set_filter(gs_sample_filter v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.filter = v;
|
||||
}
|
||||
|
||||
gs_sample_filter GS::Sampler::GetSampleFilter() {
|
||||
gs_sample_filter gs::sampler::get_filter() {
|
||||
return m_samplerInfo.filter;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetAddressModeU(gs_address_mode v) {
|
||||
void gs::sampler::set_address_mode_u(gs_address_mode v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.address_u = v;
|
||||
}
|
||||
|
||||
gs_address_mode GS::Sampler::GetAddressModeU() {
|
||||
gs_address_mode gs::sampler::get_address_mode_u() {
|
||||
return m_samplerInfo.address_u;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetAddressModeV(gs_address_mode v) {
|
||||
void gs::sampler::set_address_mode_v(gs_address_mode v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.address_v = v;
|
||||
}
|
||||
|
||||
gs_address_mode GS::Sampler::GetAddressModeV() {
|
||||
gs_address_mode gs::sampler::get_address_mode_v() {
|
||||
return m_samplerInfo.address_v;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetAddressModeW(gs_address_mode v) {
|
||||
void gs::sampler::set_address_mode_w(gs_address_mode v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.address_w = v;
|
||||
}
|
||||
|
||||
gs_address_mode GS::Sampler::GetAddressModeW() {
|
||||
gs_address_mode gs::sampler::get_address_mode_w() {
|
||||
return m_samplerInfo.address_w;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetMaxAnisotropy(int v) {
|
||||
void gs::sampler::set_max_anisotropy(int v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.max_anisotropy = v;
|
||||
}
|
||||
|
||||
int GS::Sampler::GetMaxAnisotropy() {
|
||||
int gs::sampler::get_max_anisotropy() {
|
||||
return m_samplerInfo.max_anisotropy;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetBorderColor(uint32_t v) {
|
||||
void gs::sampler::set_border_color(uint32_t v) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.border_color = v;
|
||||
}
|
||||
|
||||
void GS::Sampler::SetBorderColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
|
||||
m_dirty = true;
|
||||
m_samplerInfo.border_color = a << 24 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
uint32_t GS::Sampler::GetBorderColor() {
|
||||
uint32_t gs::sampler::get_border_color() {
|
||||
return m_samplerInfo.border_color;
|
||||
}
|
||||
|
||||
uint8_t GS::Sampler::GetBorderColor(bool r, bool g, bool b, bool a) {
|
||||
uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a) {
|
||||
if (a)
|
||||
return (m_samplerInfo.border_color >> 24) & 0xFF;
|
||||
if (r)
|
||||
|
@ -101,15 +101,15 @@ uint8_t GS::Sampler::GetBorderColor(bool r, bool g, bool b, bool a) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
gs_sampler_state* GS::Sampler::Refresh() {
|
||||
gs_sampler_state* gs::sampler::refresh() {
|
||||
gs_samplerstate_destroy(m_samplerState);
|
||||
m_samplerState = gs_samplerstate_create(&m_samplerInfo);
|
||||
m_dirty = false;
|
||||
return m_samplerState;
|
||||
}
|
||||
|
||||
gs_sampler_state* GS::Sampler::GetObject() {
|
||||
gs_sampler_state* gs::sampler::get_object() {
|
||||
if (m_dirty)
|
||||
return Refresh();
|
||||
return refresh();
|
||||
return m_samplerState;
|
||||
}
|
||||
|
|
|
@ -26,35 +26,35 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class Sampler {
|
||||
namespace gs {
|
||||
class sampler {
|
||||
public:
|
||||
Sampler();
|
||||
~Sampler();
|
||||
sampler();
|
||||
~sampler();
|
||||
|
||||
void SetSampleFilter(gs_sample_filter v);
|
||||
gs_sample_filter GetSampleFilter();
|
||||
void set_filter(gs_sample_filter v);
|
||||
gs_sample_filter get_filter();
|
||||
|
||||
void SetAddressModeU(gs_address_mode v);
|
||||
gs_address_mode GetAddressModeU();
|
||||
void set_address_mode_u(gs_address_mode v);
|
||||
gs_address_mode get_address_mode_u();
|
||||
|
||||
void SetAddressModeV(gs_address_mode v);
|
||||
gs_address_mode GetAddressModeV();
|
||||
void set_address_mode_v(gs_address_mode v);
|
||||
gs_address_mode get_address_mode_v();
|
||||
|
||||
void SetAddressModeW(gs_address_mode v);
|
||||
gs_address_mode GetAddressModeW();
|
||||
void set_address_mode_w(gs_address_mode v);
|
||||
gs_address_mode get_address_mode_w();
|
||||
|
||||
void SetMaxAnisotropy(int v);
|
||||
int GetMaxAnisotropy();
|
||||
void set_max_anisotropy(int v);
|
||||
int get_max_anisotropy();
|
||||
|
||||
void SetBorderColor(uint32_t v);
|
||||
void SetBorderColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
uint32_t GetBorderColor();
|
||||
uint8_t GetBorderColor(bool r, bool g, bool b, bool a);
|
||||
void set_border_color(uint32_t v);
|
||||
void set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a);
|
||||
uint32_t get_border_color();
|
||||
uint8_t get_border_color(bool r, bool g, bool b, bool a);
|
||||
|
||||
gs_sampler_state* Refresh();
|
||||
gs_sampler_state* refresh();
|
||||
|
||||
gs_sampler_state* GetObject();
|
||||
gs_sampler_state* get_object();
|
||||
|
||||
private:
|
||||
bool m_dirty;
|
||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::Texture::Texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
gs::texture::texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
if (width == 0)
|
||||
throw std::logic_error("width must be at least 1");
|
||||
if (height == 0)
|
||||
|
@ -39,7 +39,7 @@ GS::Texture::Texture(uint32_t width, uint32_t height, gs_color_format format, ui
|
|||
if (!mip_data)
|
||||
throw std::logic_error("mip_data is invalid");
|
||||
|
||||
if (mip_levels > 1 || flags & Flags::BuildMipMaps) {
|
||||
if (mip_levels > 1 || flags & flags::BuildMipMaps) {
|
||||
bool isPOT = (pow(2, (int64_t)floor(log(width) / log(2))) == width)
|
||||
&& (pow(2, (int64_t)floor(log(height) / log(2))) == height);
|
||||
if (!isPOT)
|
||||
|
@ -47,14 +47,14 @@ GS::Texture::Texture(uint32_t width, uint32_t height, gs_color_format format, ui
|
|||
}
|
||||
|
||||
obs_enter_graphics();
|
||||
m_texture = gs_texture_create(width, height, format, mip_levels, mip_data, (flags & Flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & Flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
m_texture = gs_texture_create(width, height, format, mip_levels, mip_data, (flags & flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (!m_texture)
|
||||
throw std::runtime_error("Failed to create texture.");
|
||||
}
|
||||
|
||||
GS::Texture::Texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
gs::texture::texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
if (width == 0)
|
||||
throw std::logic_error("width must be at least 1");
|
||||
if (height == 0)
|
||||
|
@ -66,7 +66,7 @@ GS::Texture::Texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
|
|||
if (!mip_data)
|
||||
throw std::logic_error("mip_data is invalid");
|
||||
|
||||
if (mip_levels > 1 || flags & Flags::BuildMipMaps) {
|
||||
if (mip_levels > 1 || flags & flags::BuildMipMaps) {
|
||||
bool isPOT = (pow(2, (int64_t)floor(log(width) / log(2))) == width)
|
||||
&& (pow(2, (int64_t)floor(log(height) / log(2))) == height)
|
||||
&& (pow(2, (int64_t)floor(log(depth) / log(2))) == depth);
|
||||
|
@ -75,14 +75,14 @@ GS::Texture::Texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_f
|
|||
}
|
||||
|
||||
obs_enter_graphics();
|
||||
m_texture = gs_voltexture_create(width, height, depth, format, mip_levels, mip_data, (flags & Flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & Flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
m_texture = gs_voltexture_create(width, height, depth, format, mip_levels, mip_data, (flags & flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (!m_texture)
|
||||
throw std::runtime_error("Failed to create texture.");
|
||||
}
|
||||
|
||||
GS::Texture::Texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
gs::texture::texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data, uint32_t flags) {
|
||||
if (size == 0)
|
||||
throw std::logic_error("size must be at least 1");
|
||||
if (mip_levels == 0)
|
||||
|
@ -90,21 +90,21 @@ GS::Texture::Texture(uint32_t size, gs_color_format format, uint32_t mip_levels,
|
|||
if (!mip_data)
|
||||
throw std::logic_error("mip_data is invalid");
|
||||
|
||||
if (mip_levels > 1 || flags & Flags::BuildMipMaps) {
|
||||
if (mip_levels > 1 || flags & flags::BuildMipMaps) {
|
||||
bool isPOT = (pow(2, (int64_t)floor(log(size) / log(2))) == size);
|
||||
if (!isPOT)
|
||||
throw std::logic_error("mip mapping requires power of two dimensions");
|
||||
}
|
||||
|
||||
obs_enter_graphics();
|
||||
m_texture = gs_cubetexture_create(size, format, mip_levels, mip_data, (flags & Flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & Flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
m_texture = gs_cubetexture_create(size, format, mip_levels, mip_data, (flags & flags::Dynamic) ? GS_DYNAMIC : 0 | (flags & flags::BuildMipMaps) ? GS_BUILD_MIPMAPS : 0);
|
||||
obs_leave_graphics();
|
||||
|
||||
if (!m_texture)
|
||||
throw std::runtime_error("Failed to create texture.");
|
||||
}
|
||||
|
||||
GS::Texture::Texture(std::string file) {
|
||||
gs::texture::texture(std::string file) {
|
||||
struct stat st;
|
||||
if (os_stat(file.c_str(), &st) != 0)
|
||||
throw std::ios_base::failure(file);
|
||||
|
@ -117,7 +117,7 @@ GS::Texture::Texture(std::string file) {
|
|||
throw std::runtime_error("Failed to load texture.");
|
||||
}
|
||||
|
||||
GS::Texture::Texture(Texture& other) {
|
||||
gs::texture::texture(texture& other) {
|
||||
throw std::logic_error("not yet implemented");
|
||||
//obs_enter_graphics();
|
||||
//switch (gs_get_texture_type(other.m_texture)) {
|
||||
|
@ -177,7 +177,7 @@ GS::Texture::Texture(Texture& other) {
|
|||
//obs_leave_graphics();
|
||||
}
|
||||
|
||||
GS::Texture::~Texture() {
|
||||
gs::texture::~texture() {
|
||||
if (m_isOwner && m_texture) {
|
||||
obs_enter_graphics();
|
||||
switch (gs_get_texture_type(m_texture)) {
|
||||
|
@ -196,12 +196,12 @@ GS::Texture::~Texture() {
|
|||
m_texture = nullptr;
|
||||
}
|
||||
|
||||
void GS::Texture::Load(int unit) {
|
||||
void gs::texture::load(int unit) {
|
||||
obs_enter_graphics();
|
||||
gs_load_texture(m_texture, unit);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
gs_texture_t* GS::Texture::GetObject() {
|
||||
gs_texture_t* gs::texture::get_object() {
|
||||
return m_texture;
|
||||
}
|
||||
|
|
|
@ -27,20 +27,20 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class Texture {
|
||||
namespace gs {
|
||||
class texture {
|
||||
protected:
|
||||
gs_texture_t * m_texture;
|
||||
bool m_isOwner = true;
|
||||
|
||||
public:
|
||||
enum Type : uint8_t {
|
||||
enum type : uint8_t {
|
||||
Normal,
|
||||
Volume,
|
||||
Cube
|
||||
};
|
||||
|
||||
enum Flags : uint32_t {
|
||||
enum flags : uint32_t {
|
||||
Dynamic,
|
||||
BuildMipMaps,
|
||||
};
|
||||
|
@ -58,7 +58,7 @@ namespace GS {
|
|||
* \param mip_data
|
||||
* \param flags
|
||||
*/
|
||||
Texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
|
||||
texture(uint32_t width, uint32_t height, gs_color_format format, uint32_t mip_levels,
|
||||
const uint8_t **mip_data, uint32_t flags);
|
||||
|
||||
/*!
|
||||
|
@ -74,7 +74,7 @@ namespace GS {
|
|||
* \param mip_data
|
||||
* \param flags
|
||||
*/
|
||||
Texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
|
||||
texture(uint32_t width, uint32_t height, uint32_t depth, gs_color_format format, uint32_t mip_levels,
|
||||
const uint8_t **mip_data, uint32_t flags);
|
||||
|
||||
/*!
|
||||
|
@ -88,7 +88,7 @@ namespace GS {
|
|||
* \param mip_data
|
||||
* \param flags
|
||||
*/
|
||||
Texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data,
|
||||
texture(uint32_t size, gs_color_format format, uint32_t mip_levels, const uint8_t **mip_data,
|
||||
uint32_t flags);
|
||||
|
||||
/*!
|
||||
|
@ -101,12 +101,12 @@ namespace GS {
|
|||
*
|
||||
* \param file File to create the texture from.
|
||||
*/
|
||||
Texture(std::string file);
|
||||
texture(std::string file);
|
||||
|
||||
/*!
|
||||
* \brief Create a texture from an existing gs_texture_t object.
|
||||
*/
|
||||
Texture(gs_texture_t* tex, bool takeOwnership = false) : m_texture(tex), m_isOwner(takeOwnership) {}
|
||||
texture(gs_texture_t* tex, bool takeOwnership = false) : m_texture(tex), m_isOwner(takeOwnership) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy an existing texture
|
||||
|
@ -117,12 +117,12 @@ namespace GS {
|
|||
* \param other
|
||||
* \return
|
||||
*/
|
||||
Texture(Texture& other);
|
||||
texture(texture& other);
|
||||
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
Texture() : m_texture(nullptr) {}
|
||||
texture() : m_texture(nullptr) {}
|
||||
|
||||
/*!
|
||||
* \brief Destructor
|
||||
|
@ -131,7 +131,7 @@ namespace GS {
|
|||
*
|
||||
* \return
|
||||
*/
|
||||
virtual ~Texture();
|
||||
virtual ~texture();
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
|
@ -141,7 +141,7 @@ namespace GS {
|
|||
* \param unit
|
||||
* \return void
|
||||
*/
|
||||
void Load(int unit);
|
||||
void load(int unit);
|
||||
|
||||
/*!
|
||||
* \brief
|
||||
|
@ -150,6 +150,6 @@ namespace GS {
|
|||
*
|
||||
* \return gs_texture_t*
|
||||
*/
|
||||
gs_texture_t* GetObject();
|
||||
gs_texture_t* get_object();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "gs-vertex.h"
|
||||
#include "util-memory.h"
|
||||
|
||||
GS::Vertex::Vertex() {
|
||||
gs::vertex::vertex() {
|
||||
this->hasStore = true;
|
||||
this->store = util::malloc_aligned(16, sizeof(vec3) * 3 + sizeof(uint32_t) + sizeof(vec4)*MAXIMUM_UVW_LAYERS);
|
||||
this->position = reinterpret_cast<vec3*>(store);
|
||||
|
@ -32,12 +32,12 @@ GS::Vertex::Vertex() {
|
|||
this->color = reinterpret_cast<uint32_t*>(reinterpret_cast<char*>(store) + (16 * (3 + MAXIMUM_UVW_LAYERS)));
|
||||
}
|
||||
|
||||
GS::Vertex::~Vertex() {
|
||||
gs::vertex::~vertex() {
|
||||
if (hasStore)
|
||||
util::free_aligned(store);
|
||||
}
|
||||
|
||||
GS::Vertex::Vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS])
|
||||
gs::vertex::vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uvs[MAXIMUM_UVW_LAYERS])
|
||||
: position(p), normal(n), tangent(t), color(col) {
|
||||
if (uvs != nullptr) {
|
||||
for (size_t idx = 0; idx < MAXIMUM_UVW_LAYERS; idx++) {
|
||||
|
|
|
@ -28,17 +28,17 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
struct Vertex {
|
||||
namespace gs {
|
||||
struct vertex {
|
||||
vec3* position;
|
||||
vec3* normal;
|
||||
vec3* tangent;
|
||||
uint32_t* color;
|
||||
vec4* uv[MAXIMUM_UVW_LAYERS];
|
||||
|
||||
Vertex();
|
||||
Vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uv[MAXIMUM_UVW_LAYERS]);
|
||||
~Vertex();
|
||||
vertex();
|
||||
vertex(vec3* p, vec3* n, vec3* t, uint32_t* col, vec4* uv[MAXIMUM_UVW_LAYERS]);
|
||||
~vertex();
|
||||
|
||||
private:
|
||||
bool hasStore;
|
||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
GS::VertexBuffer::~VertexBuffer() {
|
||||
gs::vertex_buffer::~vertex_buffer() {
|
||||
if (m_positions) {
|
||||
util::free_aligned(m_positions);
|
||||
m_positions = nullptr;
|
||||
|
@ -69,7 +69,7 @@ GS::VertexBuffer::~VertexBuffer() {
|
|||
}
|
||||
}
|
||||
|
||||
GS::VertexBuffer::VertexBuffer(uint32_t maximumVertices) {
|
||||
gs::vertex_buffer::vertex_buffer(uint32_t maximumVertices) {
|
||||
if (maximumVertices > MAXIMUM_VERTICES) {
|
||||
throw std::out_of_range("maximumVertices out of range");
|
||||
}
|
||||
|
@ -109,10 +109,10 @@ GS::VertexBuffer::VertexBuffer(uint32_t maximumVertices) {
|
|||
}
|
||||
}
|
||||
|
||||
GS::VertexBuffer::VertexBuffer(gs_vertbuffer_t* vb) {
|
||||
gs::vertex_buffer::vertex_buffer(gs_vertbuffer_t* vb) {
|
||||
gs_vb_data* vbd = gs_vertexbuffer_get_data(vb);
|
||||
VertexBuffer((uint32_t)vbd->num);
|
||||
this->SetUVLayers((uint32_t)vbd->num_tex);
|
||||
vertex_buffer((uint32_t)vbd->num);
|
||||
this->set_uv_layers((uint32_t)vbd->num_tex);
|
||||
|
||||
if (vbd->points != nullptr)
|
||||
std::memcpy(m_positions, vbd->points, vbd->num * sizeof(vec3));
|
||||
|
@ -141,7 +141,7 @@ GS::VertexBuffer::VertexBuffer(gs_vertbuffer_t* vb) {
|
|||
}
|
||||
|
||||
|
||||
GS::VertexBuffer::VertexBuffer(VertexBuffer const& other) : VertexBuffer(other.m_capacity) {
|
||||
gs::vertex_buffer::vertex_buffer(vertex_buffer const& other) : vertex_buffer(other.m_capacity) {
|
||||
// Copy Constructor
|
||||
std::memcpy(m_positions, other.m_positions, m_capacity * sizeof(vec3));
|
||||
std::memcpy(m_normals, other.m_normals, m_capacity * sizeof(vec3));
|
||||
|
@ -152,7 +152,7 @@ GS::VertexBuffer::VertexBuffer(VertexBuffer const& other) : VertexBuffer(other.m
|
|||
}
|
||||
}
|
||||
|
||||
GS::VertexBuffer::VertexBuffer(VertexBuffer const&& other) {
|
||||
gs::vertex_buffer::vertex_buffer(vertex_buffer const&& other) {
|
||||
// Move Constructor
|
||||
m_capacity = other.m_capacity;
|
||||
m_size = other.m_size;
|
||||
|
@ -168,7 +168,7 @@ GS::VertexBuffer::VertexBuffer(VertexBuffer const&& other) {
|
|||
m_layerdata = other.m_layerdata;
|
||||
}
|
||||
|
||||
void GS::VertexBuffer::operator=(VertexBuffer const&& other) {
|
||||
void gs::vertex_buffer::operator=(vertex_buffer const&& other) {
|
||||
// Move Assignment
|
||||
/// First self-destruct (semi-destruct itself).
|
||||
if (m_positions) {
|
||||
|
@ -226,69 +226,69 @@ void GS::VertexBuffer::operator=(VertexBuffer const&& other) {
|
|||
m_layerdata = other.m_layerdata;
|
||||
}
|
||||
|
||||
void GS::VertexBuffer::Resize(uint32_t new_size) {
|
||||
void gs::vertex_buffer::resize(uint32_t new_size) {
|
||||
if (new_size > m_capacity) {
|
||||
throw std::out_of_range("new_size out of range");
|
||||
}
|
||||
m_size = new_size;
|
||||
}
|
||||
|
||||
uint32_t GS::VertexBuffer::Size() {
|
||||
uint32_t gs::vertex_buffer::size() {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
bool GS::VertexBuffer::Empty() {
|
||||
bool gs::vertex_buffer::empty() {
|
||||
return m_size == 0;
|
||||
}
|
||||
|
||||
const GS::Vertex GS::VertexBuffer::At(uint32_t idx) {
|
||||
const gs::vertex gs::vertex_buffer::at(uint32_t idx) {
|
||||
if ((idx < 0) || (idx >= m_size)) {
|
||||
throw std::out_of_range("idx out of range");
|
||||
}
|
||||
|
||||
GS::Vertex vtx(&m_positions[idx], &m_normals[idx], &m_tangents[idx], &m_colors[idx], nullptr);
|
||||
gs::vertex vtx(&m_positions[idx], &m_normals[idx], &m_tangents[idx], &m_colors[idx], nullptr);
|
||||
for (size_t n = 0; n < MAXIMUM_UVW_LAYERS; n++) {
|
||||
vtx.uv[n] = &m_uvs[n][idx];
|
||||
}
|
||||
return vtx;
|
||||
}
|
||||
|
||||
const GS::Vertex GS::VertexBuffer::operator[](uint32_t const pos) {
|
||||
return At(pos);
|
||||
const gs::vertex gs::vertex_buffer::operator[](uint32_t const pos) {
|
||||
return at(pos);
|
||||
}
|
||||
|
||||
void GS::VertexBuffer::SetUVLayers(uint32_t layers) {
|
||||
void gs::vertex_buffer::set_uv_layers(uint32_t layers) {
|
||||
m_layers = layers;
|
||||
}
|
||||
|
||||
uint32_t GS::VertexBuffer::GetUVLayers() {
|
||||
uint32_t gs::vertex_buffer::get_uv_layers() {
|
||||
return m_layers;
|
||||
}
|
||||
|
||||
vec3* GS::VertexBuffer::GetPositions() {
|
||||
vec3* gs::vertex_buffer::get_positions() {
|
||||
return m_positions;
|
||||
}
|
||||
|
||||
vec3* GS::VertexBuffer::GetNormals() {
|
||||
vec3* gs::vertex_buffer::get_normals() {
|
||||
return m_normals;
|
||||
}
|
||||
|
||||
vec3* GS::VertexBuffer::GetTangents() {
|
||||
vec3* gs::vertex_buffer::get_tangents() {
|
||||
return m_tangents;
|
||||
}
|
||||
|
||||
uint32_t* GS::VertexBuffer::GetColors() {
|
||||
uint32_t* gs::vertex_buffer::get_colors() {
|
||||
return m_colors;
|
||||
}
|
||||
|
||||
vec4* GS::VertexBuffer::GetUVLayer(size_t idx) {
|
||||
vec4* gs::vertex_buffer::get_uv_layer(size_t idx) {
|
||||
if ((idx < 0) || (idx >= m_layers)) {
|
||||
throw std::out_of_range("idx out of range");
|
||||
}
|
||||
return m_uvs[idx];
|
||||
}
|
||||
|
||||
gs_vertbuffer_t* GS::VertexBuffer::Update(bool refreshGPU) {
|
||||
gs_vertbuffer_t* gs::vertex_buffer::update(bool refreshGPU) {
|
||||
if (!refreshGPU)
|
||||
return m_vertexbuffer;
|
||||
|
||||
|
@ -326,6 +326,6 @@ gs_vertbuffer_t* GS::VertexBuffer::Update(bool refreshGPU) {
|
|||
return m_vertexbuffer;
|
||||
}
|
||||
|
||||
gs_vertbuffer_t* GS::VertexBuffer::Update() {
|
||||
return Update(true);
|
||||
gs_vertbuffer_t* gs::vertex_buffer::update() {
|
||||
return update(true);
|
||||
}
|
||||
|
|
|
@ -30,25 +30,25 @@ extern "C" {
|
|||
#pragma warning( pop )
|
||||
}
|
||||
|
||||
namespace GS {
|
||||
class VertexBuffer {
|
||||
namespace gs {
|
||||
class vertex_buffer {
|
||||
public:
|
||||
#pragma region Constructor & Destructor
|
||||
virtual ~VertexBuffer();
|
||||
virtual ~vertex_buffer();
|
||||
|
||||
/*!
|
||||
* \brief Create a Vertex Buffer with a specific number of Vertices.
|
||||
*
|
||||
* \param maximumVertices Maximum amount of vertices to store.
|
||||
*/
|
||||
VertexBuffer(uint32_t maximumVertices);
|
||||
vertex_buffer(uint32_t maximumVertices);
|
||||
|
||||
/*!
|
||||
* \brief Create a Vertex Buffer with the maximum number of Vertices.
|
||||
*
|
||||
* \param maximumVertices Maximum amount of vertices to store.
|
||||
*/
|
||||
VertexBuffer() : VertexBuffer(MAXIMUM_VERTICES) {};
|
||||
vertex_buffer() : vertex_buffer(MAXIMUM_VERTICES) {};
|
||||
|
||||
/*!
|
||||
* \brief Create a copy of a Vertex Buffer
|
||||
|
@ -56,7 +56,7 @@ namespace GS {
|
|||
*
|
||||
* \param other The Vertex Buffer to copy
|
||||
*/
|
||||
VertexBuffer(gs_vertbuffer_t* other);
|
||||
vertex_buffer(gs_vertbuffer_t* other);
|
||||
|
||||
#pragma endregion Constructor & Destructor
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace GS {
|
|||
*
|
||||
* \param other
|
||||
*/
|
||||
VertexBuffer(VertexBuffer const& other);
|
||||
vertex_buffer(vertex_buffer const& other);
|
||||
|
||||
/*!
|
||||
* \brief Copy Assignment
|
||||
|
@ -77,7 +77,7 @@ namespace GS {
|
|||
*
|
||||
* \param other
|
||||
*/
|
||||
void operator=(VertexBuffer const& other) = delete;
|
||||
void operator=(vertex_buffer const& other) = delete;
|
||||
|
||||
// Move Constructor & Assignments
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace GS {
|
|||
*
|
||||
* \param other
|
||||
*/
|
||||
VertexBuffer(VertexBuffer const&& other);
|
||||
vertex_buffer(vertex_buffer const&& other);
|
||||
|
||||
/*!
|
||||
* \brief Move Assignment
|
||||
|
@ -95,24 +95,24 @@ namespace GS {
|
|||
*
|
||||
* \param other
|
||||
*/
|
||||
void operator=(VertexBuffer const&& other);
|
||||
void operator=(vertex_buffer const&& other);
|
||||
#pragma endregion Copy/Move Constructors
|
||||
|
||||
|
||||
|
||||
void Resize(uint32_t new_size);
|
||||
void resize(uint32_t new_size);
|
||||
|
||||
uint32_t Size();
|
||||
uint32_t size();
|
||||
|
||||
bool Empty();
|
||||
bool empty();
|
||||
|
||||
const GS::Vertex At(uint32_t idx);
|
||||
const gs::vertex at(uint32_t idx);
|
||||
|
||||
const GS::Vertex operator[](uint32_t const pos);
|
||||
const gs::vertex operator[](uint32_t const pos);
|
||||
|
||||
void SetUVLayers(uint32_t layers);
|
||||
void set_uv_layers(uint32_t layers);
|
||||
|
||||
uint32_t GetUVLayers();
|
||||
uint32_t get_uv_layers();
|
||||
|
||||
/*!
|
||||
* \brief Directly access the positions buffer
|
||||
|
@ -120,7 +120,7 @@ namespace GS {
|
|||
*
|
||||
* \return A <vec3*> that points at the first vertex's position.
|
||||
*/
|
||||
vec3* GetPositions();
|
||||
vec3* get_positions();
|
||||
|
||||
/*!
|
||||
* \brief Directly access the normals buffer
|
||||
|
@ -128,7 +128,7 @@ namespace GS {
|
|||
*
|
||||
* \return A <vec3*> that points at the first vertex's normal.
|
||||
*/
|
||||
vec3* GetNormals();
|
||||
vec3* get_normals();
|
||||
|
||||
/*!
|
||||
* \brief Directly access the tangents buffer
|
||||
|
@ -136,7 +136,7 @@ namespace GS {
|
|||
*
|
||||
* \return A <vec3*> that points at the first vertex's tangent.
|
||||
*/
|
||||
vec3* GetTangents();
|
||||
vec3* get_tangents();
|
||||
|
||||
/*!
|
||||
* \brief Directly access the colors buffer
|
||||
|
@ -144,7 +144,7 @@ namespace GS {
|
|||
*
|
||||
* \return A <uint32_t*> that points at the first vertex's color.
|
||||
*/
|
||||
uint32_t* GetColors();
|
||||
uint32_t* get_colors();
|
||||
|
||||
/*!
|
||||
* \brief Directly access the uv buffer
|
||||
|
@ -152,12 +152,12 @@ namespace GS {
|
|||
*
|
||||
* \return A <vec4*> that points at the first vertex's uv.
|
||||
*/
|
||||
vec4* GetUVLayer(size_t idx);
|
||||
vec4* get_uv_layer(size_t idx);
|
||||
|
||||
#pragma region Update / Grab GS object
|
||||
gs_vertbuffer_t* Update();
|
||||
gs_vertbuffer_t* update();
|
||||
|
||||
gs_vertbuffer_t* Update(bool refreshGPU);
|
||||
gs_vertbuffer_t* update(bool refreshGPU);
|
||||
#pragma endregion Update / Grab GS object
|
||||
|
||||
private:
|
||||
|
|
|
@ -203,8 +203,8 @@ Source::Mirror::Mirror(obs_data_t* data, obs_source_t* src) {
|
|||
|
||||
m_rescale = false;
|
||||
m_width = m_height = 1;
|
||||
m_renderTargetScale = std::make_unique<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
|
||||
m_sampler = std::make_shared<GS::Sampler>();
|
||||
m_renderTargetScale = std::make_unique<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||
m_sampler = std::make_shared<gs::sampler>();
|
||||
m_scalingEffect = obs_get_base_effect(obs_base_effect::OBS_EFFECT_DEFAULT);
|
||||
|
||||
update(data);
|
||||
|
@ -323,7 +323,7 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
|||
sh = obs_source_get_height(m_mirrorSource->GetObject());
|
||||
|
||||
// Store original Source Texture
|
||||
std::shared_ptr<GS::Texture> tex = m_mirrorSource->Render(sw, sh);
|
||||
std::shared_ptr<gs::texture> tex = m_mirrorSource->Render(sw, sh);
|
||||
|
||||
gs_eparam_t *scale_param = gs_effect_get_param_by_name(m_scalingEffect, "base_dimension_i");
|
||||
if (scale_param) {
|
||||
|
@ -337,7 +337,7 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
|||
if (m_keepOriginalSize) {
|
||||
{
|
||||
vec4 black; vec4_zero(&black);
|
||||
auto op = m_renderTargetScale->Render(m_width, m_height);
|
||||
auto op = m_renderTargetScale->render(m_width, m_height);
|
||||
gs_ortho(0, (float_t)m_width, 0, (float_t)m_height, 0, 1);
|
||||
gs_clear(GS_CLEAR_COLOR, &black, 0, 0);
|
||||
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
||||
|
@ -349,7 +349,7 @@ void Source::Mirror::video_render(gs_effect_t* effect) {
|
|||
while (gs_effect_loop(obs_get_base_effect(OBS_EFFECT_DEFAULT), "Draw")) {
|
||||
gs_eparam_t* image = gs_effect_get_param_by_name(obs_get_base_effect(OBS_EFFECT_DEFAULT), "image");
|
||||
gs_effect_set_next_sampler(image, m_sampler->GetObject());
|
||||
obs_source_draw(m_renderTargetScale->GetTextureObject(), 0, 0, sw, sh, false);
|
||||
obs_source_draw(m_renderTargetScale->get_object(), 0, 0, sw, sh, false);
|
||||
}
|
||||
} else {
|
||||
while (gs_effect_loop(m_scalingEffect, "Draw")) {
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace Source {
|
|||
bool m_rescale = false;
|
||||
bool m_keepOriginalSize = false;
|
||||
uint32_t m_width, m_height;
|
||||
std::unique_ptr<GS::RenderTarget> m_renderTargetScale;
|
||||
std::shared_ptr<GS::Sampler> m_sampler;
|
||||
std::unique_ptr<gs::rendertarget> m_renderTargetScale;
|
||||
std::shared_ptr<gs::sampler> m_sampler;
|
||||
gs_effect_t* m_scalingEffect = nullptr;
|
||||
|
||||
std::unique_ptr<gfx::SourceTexture> m_mirrorSource;
|
||||
|
|
Loading…
Reference in a new issue