From 3062d3b331217033e63ffa57d3372084dcb56fa6 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 1 Jan 2020 04:21:02 +0100 Subject: [PATCH] gfx-shader: Better logging, and ViewSize parameter --- source/gfx/shader/gfx-shader.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/source/gfx/shader/gfx-shader.cpp b/source/gfx/shader/gfx-shader.cpp index a8c1f9ed..b965dd9a 100644 --- a/source/gfx/shader/gfx-shader.cpp +++ b/source/gfx/shader/gfx-shader.cpp @@ -64,7 +64,8 @@ try { } return false; -} catch (const std::exception&) { +} catch (const std::exception& ex) { + P_LOG_ERROR("Loading shader '%s' failed with error: %s", file.c_str(), ex.what()); return false; } @@ -163,6 +164,9 @@ try { } return true; +} catch (const std::exception& ex) { + P_LOG_ERROR("Loading shader '%s' failed with error: %s", file.c_str(), ex.what()); + return false; } catch (...) { return false; } @@ -382,6 +386,7 @@ void gfx::shader::shader::render() kv.second->assign(); } + // Time: (Current Time), (Zero), (Zero), (Random Value) if (gs::effect_parameter el = _shader.get_parameter("Time"); el != nullptr) { if (el.get_type() == gs::effect_parameter::type::Float4) { el.set_float4( @@ -391,6 +396,14 @@ void gfx::shader::shader::render() } } + // ViewSize: (Width), (Height), (1.0 / Width), (1.0 / Height) + if (auto el = _shader.get_parameter("ViewSize"); el != nullptr) { + if (el.get_type() == gs::effect_parameter::type::Float4) { + el.set_float4(static_cast(width()), static_cast(height()), + 1.0f / static_cast(width()), 1.0f / static_cast(height())); + } + } + while (gs_effect_loop(_shader.get_object(), _shader_tech.c_str())) { gs_draw_sprite(nullptr, 0, szw, szh); }