@@ -120,7 +120,7 @@ context::context(utki::shared_ref<ruis::render::native_window> native_window) :
120120 });
121121}
122122
123- utki::shared_ref<ruis::render::context::shaders> context::make_shaders ()
123+ utki::shared_ref<ruis::render::context::shaders> context::make_shaders () const
124124{
125125 // TODO: are those lint supressions still valid?
126126 auto ret = utki::make_shared<ruis::render::context::shaders>();
@@ -140,27 +140,35 @@ utki::shared_ref<ruis::render::context::shaders> context::make_shaders()
140140}
141141
142142utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
143- rasterimage::format format,
143+ rasterimage::format format, //
144144 rasterimage::dimensioned::dimensions_type dims,
145145 texture_2d_parameters params
146- )
146+ ) const
147147{
148- return this ->create_texture_2d_internal (format, dims, {}, std::move (params));
148+ return this ->create_texture_2d_internal (
149+ format, //
150+ dims,
151+ {},
152+ std::move (params)
153+ );
149154}
150155
151156utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
152- const rasterimage::image_variant& imvar,
157+ const rasterimage::image_variant& imvar, //
153158 texture_2d_parameters params
154- )
159+ ) const
155160{
156161 auto imvar_copy = imvar;
157- return this ->make_texture_2d (std::move (imvar_copy), std::move (params));
162+ return this ->make_texture_2d (
163+ std::move (imvar_copy), //
164+ std::move (params)
165+ );
158166}
159167
160168utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
161- rasterimage::image_variant&& imvar,
169+ rasterimage::image_variant&& imvar, //
162170 texture_2d_parameters params
163- )
171+ ) const
164172{
165173 auto iv = std::move (imvar);
166174 return std::visit (
@@ -186,11 +194,11 @@ utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d(
186194}
187195
188196utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d_internal (
189- rasterimage::format type,
197+ rasterimage::format type, //
190198 rasterimage::dimensioned::dimensions_type dims,
191199 utki::span<const uint8_t > data,
192200 texture_2d_parameters params
193- )
201+ ) const
194202{
195203 return utki::make_shared<texture_2d>(
196204 this ->get_shared_ref (), //
@@ -203,7 +211,7 @@ utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d_internal(
203211
204212utki::shared_ref<ruis::render::texture_depth> context::make_texture_depth ( //
205213 rasterimage::dimensioned::dimensions_type dims
206- )
214+ ) const
207215{
208216 return utki::make_shared<texture_depth>(
209217 this ->get_shared_ref (), //
@@ -218,7 +226,7 @@ utki::shared_ref<ruis::render::texture_cube> context::make_texture_cube(
218226 rasterimage::image_variant&& negative_y,
219227 rasterimage::image_variant&& positive_z,
220228 rasterimage::image_variant&& negative_z
221- )
229+ ) const
222230{
223231 constexpr auto num_cube_sides = 6 ;
224232 std::array<rasterimage::image_variant, num_cube_sides> sides = {
@@ -264,31 +272,39 @@ utki::shared_ref<ruis::render::texture_cube> context::make_texture_cube(
264272 );
265273}
266274
267- utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer (utki::span<const r4::vector4<float >> vertices)
275+ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer ( //
276+ utki::span<const r4::vector4<float >> vertices
277+ ) const
268278{
269279 return utki::make_shared<vertex_buffer>(
270280 this ->get_shared_ref (), //
271281 vertices
272282 );
273283}
274284
275- utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer (utki::span<const r4::vector3<float >> vertices)
285+ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer ( //
286+ utki::span<const r4::vector3<float >> vertices
287+ ) const
276288{
277289 return utki::make_shared<vertex_buffer>(
278290 this ->get_shared_ref (), //
279291 vertices
280292 );
281293}
282294
283- utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer (utki::span<const r4::vector2<float >> vertices)
295+ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer ( //
296+ utki::span<const r4::vector2<float >> vertices
297+ ) const
284298{
285299 return utki::make_shared<vertex_buffer>(
286300 this ->get_shared_ref (), //
287301 vertices
288302 );
289303}
290304
291- utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer (utki::span<const float > vertices)
305+ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer ( //
306+ utki::span<const float > vertices
307+ ) const
292308{
293309 return utki::make_shared<vertex_buffer>(
294310 this ->get_shared_ref (), //
@@ -297,10 +313,10 @@ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer(utki::
297313}
298314
299315utki::shared_ref<ruis::render::vertex_array> context::make_vertex_array (
300- std::vector<utki::shared_ref<const ruis::render::vertex_buffer>> buffers,
316+ std::vector<utki::shared_ref<const ruis::render::vertex_buffer>> buffers, //
301317 utki::shared_ref<const ruis::render::index_buffer> indices,
302318 ruis::render::vertex_array::mode mode
303- )
319+ ) const
304320{
305321 return utki::make_shared<vertex_array>(
306322 this ->get_shared_ref (), //
@@ -310,24 +326,28 @@ utki::shared_ref<ruis::render::vertex_array> context::make_vertex_array(
310326 );
311327}
312328
313- utki::shared_ref<ruis::render::index_buffer> context::make_index_buffer (utki::span<const uint16_t > indices)
329+ utki::shared_ref<ruis::render::index_buffer> context::make_index_buffer ( //
330+ utki::span<const uint16_t > indices
331+ ) const
314332{
315333 return utki::make_shared<index_buffer>(
316334 this ->get_shared_ref (), //
317335 indices
318336 );
319337}
320338
321- utki::shared_ref<ruis::render::index_buffer> context::make_index_buffer (utki::span<const uint32_t > indices)
339+ utki::shared_ref<ruis::render::index_buffer> context::make_index_buffer ( //
340+ utki::span<const uint32_t > indices
341+ ) const
322342{
323343 return utki::make_shared<index_buffer>(
324344 this ->get_shared_ref (), //
325345 indices
326346 );
327347}
328348
329- utki::shared_ref<ruis::render::frame_buffer> context::make_framebuffer ( //
330- std::shared_ptr<ruis::render::texture_2d> color,
349+ utki::shared_ref<ruis::render::frame_buffer> context::make_framebuffer (
350+ std::shared_ptr<ruis::render::texture_2d> color, //
331351 std::shared_ptr<ruis::render::texture_depth> depth,
332352 std::shared_ptr<ruis::render::texture_stencil> stencil
333353)
@@ -377,16 +397,16 @@ void context::clear_framebuffer_stencil()
377397 assert_opengl_no_error ();
378398}
379399
380- r4::vector2<uint32_t > context::to_window_coords (ruis::vec2 point) const
400+ r4::vector2<uint32_t > context::to_window_coords (const ruis::vec2& point) const
381401{
382402 auto vp = this ->get_viewport ();
383403
384- point += ruis::vec2 (1 , 1 );
385- point = max (point , {0 , 0 }); // clamp to >= 0
386- point /= 2 ;
387- point .comp_multiply (vp.d .to <real>());
388- point = round (point );
389- return point .to <uint32_t >() + vp.p ;
404+ auto p = point + ruis::vec2 (1 , 1 );
405+ p = max (p , {0 , 0 }); // clamp to >= 0
406+ p /= 2 ;
407+ p .comp_multiply (vp.d .to <real>());
408+ p = round (p );
409+ return p .to <uint32_t >() + vp.p ;
390410}
391411
392412bool context::is_scissor_enabled () const noexcept
@@ -422,9 +442,14 @@ r4::rectangle<uint32_t> context::get_scissor() const
422442 };
423443}
424444
425- void context::set_scissor (r4::rectangle<uint32_t > r)
445+ void context::set_scissor (const r4::rectangle<uint32_t >& r)
426446{
427- glScissor (GLint (r.p .x ()), GLint (r.p .y ()), GLint (r.d .x ()), GLint (r.d .y ()));
447+ glScissor (
448+ GLint (r.p .x ()), //
449+ GLint (r.p .y ()),
450+ GLint (r.d .x ()),
451+ GLint (r.d .y ())
452+ );
428453 assert_opengl_no_error ();
429454}
430455
@@ -448,9 +473,14 @@ r4::rectangle<uint32_t> context::get_viewport() const
448473 };
449474}
450475
451- void context::set_viewport (r4::rectangle<uint32_t > r)
476+ void context::set_viewport (const r4::rectangle<uint32_t >& r)
452477{
453- glViewport (GLint (r.p .x ()), GLint (r.p .y ()), GLint (r.d .x ()), GLint (r.d .y ()));
478+ glViewport (
479+ GLint (r.p .x ()), //
480+ GLint (r.p .y ()),
481+ GLint (r.d .x ()),
482+ GLint (r.d .y ())
483+ );
454484 assert_opengl_no_error ();
455485}
456486
0 commit comments