2018-01-19 04:06:42 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-sampler.hpp"
|
2018-01-19 04:06:42 +00:00
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs::sampler::sampler()
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
|
|
|
m_samplerInfo = {GS_FILTER_LINEAR, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, GS_ADDRESS_WRAP, 1, 0};
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerState = nullptr;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs::sampler::~sampler()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
if (m_samplerState)
|
|
|
|
gs_samplerstate_destroy(m_samplerState);
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_filter(gs_sample_filter v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.filter = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_sample_filter gs::sampler::get_filter()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.filter;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_address_mode_u(gs_address_mode v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.address_u = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_address_mode gs::sampler::get_address_mode_u()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.address_u;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_address_mode_v(gs_address_mode v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.address_v = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_address_mode gs::sampler::get_address_mode_v()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.address_v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_address_mode_w(gs_address_mode v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.address_w = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_address_mode gs::sampler::get_address_mode_w()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.address_w;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_max_anisotropy(int v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.max_anisotropy = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
int gs::sampler::get_max_anisotropy()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.max_anisotropy;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_border_color(uint32_t v)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.border_color = v;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
void gs::sampler::set_border_color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
|
|
|
{
|
|
|
|
m_dirty = true;
|
2018-01-19 04:06:42 +00:00
|
|
|
m_samplerInfo.border_color = a << 24 | r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
uint32_t gs::sampler::get_border_color()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerInfo.border_color;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
uint8_t gs::sampler::get_border_color(bool r, bool g, bool b, bool a)
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_sampler_state* gs::sampler::refresh()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
gs_samplerstate_destroy(m_samplerState);
|
|
|
|
m_samplerState = gs_samplerstate_create(&m_samplerInfo);
|
2018-11-07 14:24:25 +00:00
|
|
|
m_dirty = false;
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerState;
|
|
|
|
}
|
|
|
|
|
2018-11-07 14:24:25 +00:00
|
|
|
gs_sampler_state* gs::sampler::get_object()
|
|
|
|
{
|
2018-01-19 04:06:42 +00:00
|
|
|
if (m_dirty)
|
2018-03-20 11:43:37 +00:00
|
|
|
return refresh();
|
2018-01-19 04:06:42 +00:00
|
|
|
return m_samplerState;
|
|
|
|
}
|