|
| 1 | +/* |
| 2 | +ruis-render-null - null renderer |
| 3 | +
|
| 4 | +Copyright (C) 2024-2024 Ivan Gagis <igagis@gmail.com> |
| 5 | +
|
| 6 | +This program is free software: you can redistribute it and/or modify |
| 7 | +it under the terms of the GNU General Public License as published by |
| 8 | +the Free Software Foundation, either version 3 of the License, or |
| 9 | +(at your option) any later version. |
| 10 | +
|
| 11 | +This program is distributed in the hope that it will be useful, |
| 12 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +GNU General Public License for more details. |
| 15 | +
|
| 16 | +You should have received a copy of the GNU General Public License |
| 17 | +along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | +*/ |
| 19 | + |
| 20 | +/* ================ LICENSE END ================ */ |
| 21 | + |
| 22 | +#include "context.hpp" |
| 23 | + |
| 24 | +#include "frame_buffer.hpp" |
| 25 | +#include "index_buffer.hpp" |
| 26 | +#include "texture_2d.hpp" |
| 27 | +#include "texture_cube.hpp" |
| 28 | +#include "texture_depth.hpp" |
| 29 | +#include "vertex_array.hpp" |
| 30 | +#include "vertex_buffer.hpp" |
| 31 | + |
| 32 | +using namespace ruis::render::null; |
| 33 | + |
| 34 | +utki::shared_ref<ruis::render::frame_buffer> context::create_framebuffer( |
| 35 | + std::shared_ptr<ruis::render::texture_2d> color, |
| 36 | + std::shared_ptr<ruis::render::texture_depth> depth, |
| 37 | + std::shared_ptr<ruis::render::texture_stencil> stencil |
| 38 | +) |
| 39 | +{ |
| 40 | + return utki::make_shared<frame_buffer>( |
| 41 | + this->get_shared_ref(), // |
| 42 | + std::move(color), |
| 43 | + std::move(depth), |
| 44 | + std::move(stencil) |
| 45 | + ); |
| 46 | +} |
| 47 | + |
| 48 | +utki::shared_ref<ruis::render::index_buffer> context::create_index_buffer(utki::span<const uint16_t> indices) |
| 49 | +{ |
| 50 | + return utki::make_shared<index_buffer>( |
| 51 | + this->get_shared_ref(), // |
| 52 | + indices |
| 53 | + ); |
| 54 | +} |
| 55 | + |
| 56 | +utki::shared_ref<ruis::render::index_buffer> context::create_index_buffer(utki::span<const uint32_t> indices) |
| 57 | +{ |
| 58 | + return utki::make_shared<index_buffer>( |
| 59 | + this->get_shared_ref(), // |
| 60 | + indices |
| 61 | + ); |
| 62 | +} |
| 63 | + |
| 64 | +utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d( |
| 65 | + rasterimage::format format, |
| 66 | + rasterimage::dimensioned::dimensions_type dims, |
| 67 | + texture_2d_parameters params |
| 68 | +) |
| 69 | +{ |
| 70 | + return utki::make_shared<texture_2d>( |
| 71 | + this->get_shared_ref(), // |
| 72 | + rasterimage::image_variant(dims, format), |
| 73 | + std::move(params) |
| 74 | + ); |
| 75 | +} |
| 76 | + |
| 77 | +utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d( |
| 78 | + const rasterimage::image_variant& imvar, |
| 79 | + texture_2d_parameters params |
| 80 | +) |
| 81 | +{ |
| 82 | + return utki::make_shared<texture_2d>( |
| 83 | + this->get_shared_ref(), // |
| 84 | + imvar, |
| 85 | + std::move(params) |
| 86 | + ); |
| 87 | +} |
| 88 | + |
| 89 | +utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d( |
| 90 | + rasterimage::image_variant&& imvar, |
| 91 | + texture_2d_parameters params |
| 92 | +) |
| 93 | +{ |
| 94 | + return utki::make_shared<texture_2d>( |
| 95 | + this->get_shared_ref(), // |
| 96 | + std::move(imvar), |
| 97 | + std::move(params) |
| 98 | + ); |
| 99 | +} |
| 100 | + |
| 101 | +utki::shared_ref<ruis::render::texture_depth> context::create_texture_depth(r4::vector2<uint32_t> dims) |
| 102 | +{ |
| 103 | + return utki::make_shared<texture_depth>( |
| 104 | + this->get_shared_ref(), // |
| 105 | + dims |
| 106 | + ); |
| 107 | +} |
| 108 | + |
| 109 | +utki::shared_ref<ruis::render::texture_cube> context::create_texture_cube( |
| 110 | + rasterimage::image_variant&& positive_x, |
| 111 | + rasterimage::image_variant&& negative_x, |
| 112 | + rasterimage::image_variant&& positive_y, |
| 113 | + rasterimage::image_variant&& negative_y, |
| 114 | + rasterimage::image_variant&& positive_z, |
| 115 | + rasterimage::image_variant&& negative_z |
| 116 | +) |
| 117 | +{ |
| 118 | + return utki::make_shared<texture_cube>( |
| 119 | + this->get_shared_ref(), // |
| 120 | + std::move(positive_x), |
| 121 | + std::move(negative_x), |
| 122 | + std::move(positive_y), |
| 123 | + std::move(negative_y), |
| 124 | + std::move(positive_z), |
| 125 | + std::move(negative_z) |
| 126 | + ); |
| 127 | +} |
| 128 | + |
| 129 | +utki::shared_ref<ruis::render::vertex_array> context::create_vertex_array( |
| 130 | + std::vector<utki::shared_ref<const ruis::render::vertex_buffer>> buffers, |
| 131 | + utki::shared_ref<const ruis::render::index_buffer> indices, |
| 132 | + ruis::render::vertex_array::mode rendering_mode |
| 133 | +) |
| 134 | +{ |
| 135 | + return utki::make_shared<vertex_array>( |
| 136 | + this->get_shared_ref(), // |
| 137 | + std::move(buffers), |
| 138 | + std::move(indices), |
| 139 | + rendering_mode |
| 140 | + ); |
| 141 | +} |
| 142 | + |
| 143 | +utki::shared_ref<ruis::render::vertex_buffer> context::create_vertex_buffer(utki::span<const float> vertices) |
| 144 | +{ |
| 145 | + return utki::make_shared<vertex_buffer>( |
| 146 | + this->get_shared_ref(), // |
| 147 | + vertices |
| 148 | + ); |
| 149 | +} |
| 150 | + |
| 151 | +utki::shared_ref<ruis::render::vertex_buffer> context::create_vertex_buffer( |
| 152 | + utki::span<const r4::vector2<float>> vertices |
| 153 | +) |
| 154 | +{ |
| 155 | + return utki::make_shared<vertex_buffer>( |
| 156 | + this->get_shared_ref(), // |
| 157 | + vertices |
| 158 | + ); |
| 159 | +} |
| 160 | + |
| 161 | +utki::shared_ref<ruis::render::vertex_buffer> context::create_vertex_buffer( |
| 162 | + utki::span<const r4::vector3<float>> vertices |
| 163 | +) |
| 164 | +{ |
| 165 | + return utki::make_shared<vertex_buffer>( |
| 166 | + this->get_shared_ref(), // |
| 167 | + vertices |
| 168 | + ); |
| 169 | +} |
| 170 | + |
| 171 | +utki::shared_ref<ruis::render::vertex_buffer> context::create_vertex_buffer( |
| 172 | + utki::span<const r4::vector4<float>> vertices |
| 173 | +) |
| 174 | +{ |
| 175 | + return utki::make_shared<vertex_buffer>( |
| 176 | + this->get_shared_ref(), // |
| 177 | + vertices |
| 178 | + ); |
| 179 | +} |
0 commit comments