ソースを参照

bmp render is now portable

devel
Ludovic 'Archivist' Lagouardette 4年前
コミット
f896a5745f
3個のファイルの変更21行の追加31行の削除
  1. +2
    -2
      include/gp/bitops.hpp
  2. +8
    -8
      include/gp/rendering/bmp_viewport.hpp
  3. +11
    -21
      tests/math.cpp

+ 2
- 2
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;
}

+ 8
- 8
include/gp/rendering/bmp_viewport.hpp ファイルの表示

@ -34,10 +34,10 @@ namespace gp{
{}
gp::buffer<char>::associated_iterator write(gp::buffer<char> destination) {
using sle16 = cm">/*gp::endian_wrapper<*/int16_t/*, gp::endian::little>*/;
using sbe16 = cm">/*gp::endian_wrapper<*/int16_t/*, gp::endian::big>*/;
using sle32 = cm">/*gp::endian_wrapper<*/int32_t/*, gp::endian::little>*/;
using sbe32 = cm">/*gp::endian_wrapper<*/int32_t/*, gp::endian::big>*/;
using sle16 = n">gp::endian_wrapper<int16_t, gp::endian::little>;
using sbe16 = n">gp::endian_wrapper<int16_t, gp::endian::big>;
using sle32 = n">gp::endian_wrapper<int32_t, gp::endian::little>;
using sbe32 = n">gp::endian_wrapper<int32_t, gp::endian::big>;
auto it = destination.begin();
*(it++) = 'B';
@ -105,10 +105,10 @@ namespace gp{
if constexpr (std::is_same<color_type, gp::vec4_g<uint8_t>>::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);
}

+ 11
- 21
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<uint8_t>;
gp::bmp_viewport<true, pic_color> vp{
{1000,500},
{128,64},
[&](gp::vec2_g<int32_t> 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<char, 400000000>* buff = new gp::array<char, 400000000>();
gp::array<char, 300000>* buff = new gp::array<char, 300000>();
auto begin = std::chrono::steady_clock::now();

読み込み中…
キャンセル
保存