mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-16 14:08:59 +07:00
Merge pull request #30 from enduro2d/hotfix/default_sampler_state_values
fix default sampler_state values
This commit is contained in:
@@ -586,6 +586,7 @@ namespace e2d
|
|||||||
sampler_state& wrap(sampler_wrap st) noexcept;
|
sampler_state& wrap(sampler_wrap st) noexcept;
|
||||||
sampler_state& s_wrap(sampler_wrap s) noexcept;
|
sampler_state& s_wrap(sampler_wrap s) noexcept;
|
||||||
sampler_state& t_wrap(sampler_wrap t) noexcept;
|
sampler_state& t_wrap(sampler_wrap t) noexcept;
|
||||||
|
sampler_state& r_wrap(sampler_wrap t) noexcept;
|
||||||
|
|
||||||
sampler_state& filter(sampler_min_filter min, sampler_mag_filter mag) noexcept;
|
sampler_state& filter(sampler_min_filter min, sampler_mag_filter mag) noexcept;
|
||||||
sampler_state& min_filter(sampler_min_filter min) noexcept;
|
sampler_state& min_filter(sampler_min_filter min) noexcept;
|
||||||
@@ -595,15 +596,17 @@ namespace e2d
|
|||||||
|
|
||||||
sampler_wrap s_wrap() const noexcept;
|
sampler_wrap s_wrap() const noexcept;
|
||||||
sampler_wrap t_wrap() const noexcept;
|
sampler_wrap t_wrap() const noexcept;
|
||||||
|
sampler_wrap r_wrap() const noexcept;
|
||||||
|
|
||||||
sampler_min_filter min_filter() const noexcept;
|
sampler_min_filter min_filter() const noexcept;
|
||||||
sampler_mag_filter mag_filter() const noexcept;
|
sampler_mag_filter mag_filter() const noexcept;
|
||||||
private:
|
private:
|
||||||
texture_ptr texture_;
|
texture_ptr texture_;
|
||||||
sampler_wrap s_wrap_;
|
sampler_wrap s_wrap_ = sampler_wrap::repeat;
|
||||||
sampler_wrap t_wrap_;
|
sampler_wrap t_wrap_ = sampler_wrap::repeat;
|
||||||
sampler_min_filter min_filter_;
|
sampler_wrap r_wrap_ = sampler_wrap::repeat;
|
||||||
sampler_mag_filter mag_filter_;
|
sampler_min_filter min_filter_ = sampler_min_filter::nearest_mipmap_linear;
|
||||||
|
sampler_mag_filter mag_filter_ = sampler_mag_filter::linear;
|
||||||
};
|
};
|
||||||
|
|
||||||
using property_value = stdex::variant<
|
using property_value = stdex::variant<
|
||||||
|
|||||||
@@ -647,6 +647,7 @@ namespace e2d
|
|||||||
render::sampler_state& render::sampler_state::wrap(sampler_wrap st) noexcept {
|
render::sampler_state& render::sampler_state::wrap(sampler_wrap st) noexcept {
|
||||||
s_wrap(st);
|
s_wrap(st);
|
||||||
t_wrap(st);
|
t_wrap(st);
|
||||||
|
r_wrap(st);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,6 +661,11 @@ namespace e2d
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render::sampler_state& render::sampler_state::r_wrap(sampler_wrap r) noexcept {
|
||||||
|
r_wrap_ = r;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
render::sampler_state& render::sampler_state::filter(sampler_min_filter min, sampler_mag_filter mag) noexcept {
|
render::sampler_state& render::sampler_state::filter(sampler_min_filter min, sampler_mag_filter mag) noexcept {
|
||||||
min_filter(min);
|
min_filter(min);
|
||||||
mag_filter(mag);
|
mag_filter(mag);
|
||||||
@@ -688,6 +694,10 @@ namespace e2d
|
|||||||
return t_wrap_;
|
return t_wrap_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render::sampler_wrap render::sampler_state::r_wrap() const noexcept {
|
||||||
|
return r_wrap_;
|
||||||
|
}
|
||||||
|
|
||||||
render::sampler_min_filter render::sampler_state::min_filter() const noexcept {
|
render::sampler_min_filter render::sampler_state::min_filter() const noexcept {
|
||||||
return min_filter_;
|
return min_filter_;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,10 @@ namespace
|
|||||||
texture_id.target(),
|
texture_id.target(),
|
||||||
GL_TEXTURE_WRAP_T,
|
GL_TEXTURE_WRAP_T,
|
||||||
convert_sampler_wrap(sampler.t_wrap())));
|
convert_sampler_wrap(sampler.t_wrap())));
|
||||||
|
GL_CHECK_CODE(debug, glTexParameteri(
|
||||||
|
texture_id.target(),
|
||||||
|
GL_TEXTURE_WRAP_R,
|
||||||
|
convert_sampler_wrap(sampler.r_wrap())));
|
||||||
GL_CHECK_CODE(debug, glTexParameteri(
|
GL_CHECK_CODE(debug, glTexParameteri(
|
||||||
texture_id.target(),
|
texture_id.target(),
|
||||||
GL_TEXTURE_MIN_FILTER,
|
GL_TEXTURE_MIN_FILTER,
|
||||||
|
|||||||
@@ -8,6 +8,27 @@
|
|||||||
using namespace e2d;
|
using namespace e2d;
|
||||||
|
|
||||||
TEST_CASE("render"){
|
TEST_CASE("render"){
|
||||||
|
SECTION("sampler_state"){
|
||||||
|
{
|
||||||
|
const auto ss = render::sampler_state();
|
||||||
|
REQUIRE_FALSE(ss.texture());
|
||||||
|
REQUIRE(ss.s_wrap() == render::sampler_wrap::repeat);
|
||||||
|
REQUIRE(ss.t_wrap() == render::sampler_wrap::repeat);
|
||||||
|
REQUIRE(ss.r_wrap() == render::sampler_wrap::repeat);
|
||||||
|
REQUIRE(ss.min_filter() == render::sampler_min_filter::nearest_mipmap_linear);
|
||||||
|
REQUIRE(ss.mag_filter() == render::sampler_mag_filter::linear);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const auto ss = render::sampler_state()
|
||||||
|
.wrap(render::sampler_wrap::clamp)
|
||||||
|
.filter(render::sampler_min_filter::linear, render::sampler_mag_filter::nearest);
|
||||||
|
REQUIRE(ss.s_wrap() == render::sampler_wrap::clamp);
|
||||||
|
REQUIRE(ss.t_wrap() == render::sampler_wrap::clamp);
|
||||||
|
REQUIRE(ss.r_wrap() == render::sampler_wrap::clamp);
|
||||||
|
REQUIRE(ss.min_filter() == render::sampler_min_filter::linear);
|
||||||
|
REQUIRE(ss.mag_filter() == render::sampler_mag_filter::nearest);
|
||||||
|
}
|
||||||
|
}
|
||||||
SECTION("property_block"){
|
SECTION("property_block"){
|
||||||
{
|
{
|
||||||
const auto pb1 = render::property_block()
|
const auto pb1 = render::property_block()
|
||||||
|
|||||||
Reference in New Issue
Block a user