mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 04:15:11 +00:00
e0e2d9fe80
While Linux was not an original goal of the project, it should still be supported out of the box. Therefore a number of changes are contained in this changeset: - All C++ .h files were renamed to .hpp. - All C includes (<....h>) were replaced with C++ includes (<c...>) and missing includes were added. - std::memset and std::memcpy was replaced with memset and memcpy. - All anonymous structs were removed where necessary. - `extern "C"` was removed where it wasn't needed. - #pragma warning was placed behind an #ifdef _MSC_VER - The macros for `min`, `max` and `clamp` were removed as they were not used. - `-fpedantic` was added to the GCC flags for bitmask support. - `gs::rendertarget_op` is now declared before use. - std::exception(const char*) was replaced with std::runtime_error(const char*). - Added aligned_alloc and aligned_free macros for GCC and MSVC support. - Replaced use of `sprintf_s` with `snprintf`. - Placed additional guards around windows only code. Additonally some changes were made that do not affect Linux: - `NOMINMAX` and `NOINOUT` were removed. Fixes: #27 Fixes: #13
133 lines
3.1 KiB
C++
133 lines
3.1 KiB
C++
/*
|
|
* Modern effects for a modern Streamer
|
|
* Copyright (C) 2017 Michael Fabian Dirks
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
*/
|
|
|
|
#include "gs-sampler.hpp"
|
|
|
|
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()
|
|
{
|
|
if (m_samplerState)
|
|
gs_samplerstate_destroy(m_samplerState);
|
|
}
|
|
|
|
void gs::sampler::set_filter(gs_sample_filter v)
|
|
{
|
|
m_dirty = true;
|
|
m_samplerInfo.filter = v;
|
|
}
|
|
|
|
gs_sample_filter gs::sampler::get_filter()
|
|
{
|
|
return m_samplerInfo.filter;
|
|
}
|
|
|
|
void gs::sampler::set_address_mode_u(gs_address_mode v)
|
|
{
|
|
m_dirty = true;
|
|
m_samplerInfo.address_u = v;
|
|
}
|
|
|
|
gs_address_mode gs::sampler::get_address_mode_u()
|
|
{
|
|
return m_samplerInfo.address_u;
|
|
}
|
|
|
|
void gs::sampler::set_address_mode_v(gs_address_mode v)
|
|
{
|
|
m_dirty = true;
|
|
m_samplerInfo.address_v = v;
|
|
}
|
|
|
|
gs_address_mode gs::sampler::get_address_mode_v()
|
|
{
|
|
return m_samplerInfo.address_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::get_address_mode_w()
|
|
{
|
|
return m_samplerInfo.address_w;
|
|
}
|
|
|
|
void gs::sampler::set_max_anisotropy(int v)
|
|
{
|
|
m_dirty = true;
|
|
m_samplerInfo.max_anisotropy = v;
|
|
}
|
|
|
|
int gs::sampler::get_max_anisotropy()
|
|
{
|
|
return m_samplerInfo.max_anisotropy;
|
|
}
|
|
|
|
void gs::sampler::set_border_color(uint32_t v)
|
|
{
|
|
m_dirty = true;
|
|
m_samplerInfo.border_color = v;
|
|
}
|
|
|
|
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::get_border_color()
|
|
{
|
|
return m_samplerInfo.border_color;
|
|
}
|
|
|
|
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)
|
|
return (m_samplerInfo.border_color >> 16) & 0xFF;
|
|
if (g)
|
|
return (m_samplerInfo.border_color >> 8) & 0xFF;
|
|
if (b)
|
|
return m_samplerInfo.border_color & 0xFF;
|
|
return 0;
|
|
}
|
|
|
|
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::get_object()
|
|
{
|
|
if (m_dirty)
|
|
return refresh();
|
|
return m_samplerState;
|
|
}
|