diff --git a/include/gp/bitops.hpp b/include/gp/bitops.hpp index b6a62ec..142a58c 100644 --- a/include/gp/bitops.hpp +++ b/include/gp/bitops.hpp @@ -62,8 +62,8 @@ namespace gp{ v.value }{} - endian_wrapper& operator=(T value) { - mode == endian::native ? value : swap_endian(value); + endian_wrapper& operator=(T p) { + value = mode == endian::native ? p : swap_endian(p); return *this; } diff --git a/include/gp/rendering/bmp_viewport.hpp b/include/gp/rendering/bmp_viewport.hpp index 571b1bb..16c8c69 100644 --- a/include/gp/rendering/bmp_viewport.hpp +++ b/include/gp/rendering/bmp_viewport.hpp @@ -34,10 +34,10 @@ namespace gp{ {} gp::buffer::associated_iterator write(gp::buffer destination) { - using sle16 = /*gp::endian_wrapper<*/int16_t/*, gp::endian::little>*/; - using sbe16 = /*gp::endian_wrapper<*/int16_t/*, gp::endian::big>*/; - using sle32 = /*gp::endian_wrapper<*/int32_t/*, gp::endian::little>*/; - using sbe32 = /*gp::endian_wrapper<*/int32_t/*, gp::endian::big>*/; + using sle16 = gp::endian_wrapper; + using sbe16 = gp::endian_wrapper; + using sle32 = gp::endian_wrapper; + using sbe32 = gp::endian_wrapper; auto it = destination.begin(); *(it++) = 'B'; @@ -105,10 +105,10 @@ namespace gp{ if constexpr (std::is_same>::value) { auto color = get(row, line); - *(it++) = color.x; - *(it++) = color.y; - *(it++) = color.z; - *(it++) = color.w; + *(it++) = color.b(); + *(it++) = color.g(); + *(it++) = color.r(); + *(it++) = color.a(); } else { it = it + sizeof(color_type); } diff --git a/tests/math.cpp b/tests/math.cpp index 537d077..7639ae3 100644 --- a/tests/math.cpp +++ b/tests/math.cpp @@ -45,29 +45,19 @@ struct render_test : public test_scaffold { virtual int run() { int res = 0; renderer a; - a._resolution = vec2{1000,500}; + a._resolution = vec2{128,64}; + a.passes = 6; + a.projection_end = 4; a.sky_box = [](vec3) -> color_t {return {0,0,0,0};}; auto v = a.materials.push( [&](vec3 p) -> color_t { - //return color_t{0,0,1,1}; - const float EPSILON = 0.001; - /*vec3( - a.sdf(vec3(p.x + EPSILON, p.y, p.z)).distance - a.sdf(vec3(p.x - EPSILON, p.y, p.z)).distance, - a.sdf(vec3(p.x, p.y + EPSILON, p.z)).distance - a.sdf(vec3(p.x, p.y - EPSILON, p.z)).distance, - a.sdf(vec3(p.x, p.y, p.z + EPSILON)).distance - a.sdf(vec3(p.x, p.y, p.z - EPSILON)).distance - )*/ - auto normals = p.normalize(); - - auto light = vec3(1,1,1).normalize(); - - auto tmp = light*p; - auto color = tmp.x+tmp.y+tmp.z; - - - - return vec4(vec3(color, color, color), 1.0); - //return {v.normalize(), 1.0}; + color_t ret; + ret.r() = 1; + ret.g() = 1; + ret.b() = 0; + ret.a() = 1; + return ret; } ); @@ -86,7 +76,7 @@ struct render_test : public test_scaffold { using pic_color = gp::vec4_g; gp::bmp_viewport vp{ - {1000,500}, + {128,64}, [&](gp::vec2_g p) -> pic_color { auto orig = a.render({(float)p.x,(float)p.y}); pic_color ret{}; @@ -98,7 +88,7 @@ struct render_test : public test_scaffold { } }; - gp::array* buff = new gp::array(); + gp::array* buff = new gp::array(); auto begin = std::chrono::steady_clock::now();