@@ -120,7 +120,7 @@ context::context(utki::shared_ref<ruis::render::native_window> native_window) :
120
120
});
121
121
}
122
122
123
- utki::shared_ref<ruis::render::context::shaders> context::make_shaders ()
123
+ utki::shared_ref<ruis::render::context::shaders> context::make_shaders () const
124
124
{
125
125
// TODO: are those lint supressions still valid?
126
126
auto ret = utki::make_shared<ruis::render::context::shaders>();
@@ -140,27 +140,35 @@ utki::shared_ref<ruis::render::context::shaders> context::make_shaders()
140
140
}
141
141
142
142
utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
143
- rasterimage::format format,
143
+ rasterimage::format format, //
144
144
rasterimage::dimensioned::dimensions_type dims,
145
145
texture_2d_parameters params
146
- )
146
+ ) const
147
147
{
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
+ );
149
154
}
150
155
151
156
utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
152
- const rasterimage::image_variant& imvar,
157
+ const rasterimage::image_variant& imvar, //
153
158
texture_2d_parameters params
154
- )
159
+ ) const
155
160
{
156
161
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
+ );
158
166
}
159
167
160
168
utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d (
161
- rasterimage::image_variant&& imvar,
169
+ rasterimage::image_variant&& imvar, //
162
170
texture_2d_parameters params
163
- )
171
+ ) const
164
172
{
165
173
auto iv = std::move (imvar);
166
174
return std::visit (
@@ -186,11 +194,11 @@ utki::shared_ref<ruis::render::texture_2d> context::make_texture_2d(
186
194
}
187
195
188
196
utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d_internal (
189
- rasterimage::format type,
197
+ rasterimage::format type, //
190
198
rasterimage::dimensioned::dimensions_type dims,
191
199
utki::span<const uint8_t > data,
192
200
texture_2d_parameters params
193
- )
201
+ ) const
194
202
{
195
203
return utki::make_shared<texture_2d>(
196
204
this ->get_shared_ref (), //
@@ -203,7 +211,7 @@ utki::shared_ref<ruis::render::texture_2d> context::create_texture_2d_internal(
203
211
204
212
utki::shared_ref<ruis::render::texture_depth> context::make_texture_depth ( //
205
213
rasterimage::dimensioned::dimensions_type dims
206
- )
214
+ ) const
207
215
{
208
216
return utki::make_shared<texture_depth>(
209
217
this ->get_shared_ref (), //
@@ -218,7 +226,7 @@ utki::shared_ref<ruis::render::texture_cube> context::make_texture_cube(
218
226
rasterimage::image_variant&& negative_y,
219
227
rasterimage::image_variant&& positive_z,
220
228
rasterimage::image_variant&& negative_z
221
- )
229
+ ) const
222
230
{
223
231
constexpr auto num_cube_sides = 6 ;
224
232
std::array<rasterimage::image_variant, num_cube_sides> sides = {
@@ -264,31 +272,39 @@ utki::shared_ref<ruis::render::texture_cube> context::make_texture_cube(
264
272
);
265
273
}
266
274
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
268
278
{
269
279
return utki::make_shared<vertex_buffer>(
270
280
this ->get_shared_ref (), //
271
281
vertices
272
282
);
273
283
}
274
284
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
276
288
{
277
289
return utki::make_shared<vertex_buffer>(
278
290
this ->get_shared_ref (), //
279
291
vertices
280
292
);
281
293
}
282
294
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
284
298
{
285
299
return utki::make_shared<vertex_buffer>(
286
300
this ->get_shared_ref (), //
287
301
vertices
288
302
);
289
303
}
290
304
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
292
308
{
293
309
return utki::make_shared<vertex_buffer>(
294
310
this ->get_shared_ref (), //
@@ -297,10 +313,10 @@ utki::shared_ref<ruis::render::vertex_buffer> context::make_vertex_buffer(utki::
297
313
}
298
314
299
315
utki::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, //
301
317
utki::shared_ref<const ruis::render::index_buffer> indices,
302
318
ruis::render::vertex_array::mode mode
303
- )
319
+ ) const
304
320
{
305
321
return utki::make_shared<vertex_array>(
306
322
this ->get_shared_ref (), //
@@ -310,24 +326,28 @@ utki::shared_ref<ruis::render::vertex_array> context::make_vertex_array(
310
326
);
311
327
}
312
328
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
314
332
{
315
333
return utki::make_shared<index_buffer>(
316
334
this ->get_shared_ref (), //
317
335
indices
318
336
);
319
337
}
320
338
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
322
342
{
323
343
return utki::make_shared<index_buffer>(
324
344
this ->get_shared_ref (), //
325
345
indices
326
346
);
327
347
}
328
348
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, //
331
351
std::shared_ptr<ruis::render::texture_depth> depth,
332
352
std::shared_ptr<ruis::render::texture_stencil> stencil
333
353
)
@@ -377,16 +397,16 @@ void context::clear_framebuffer_stencil()
377
397
assert_opengl_no_error ();
378
398
}
379
399
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
381
401
{
382
402
auto vp = this ->get_viewport ();
383
403
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 ;
390
410
}
391
411
392
412
bool context::is_scissor_enabled () const noexcept
@@ -422,9 +442,14 @@ r4::rectangle<uint32_t> context::get_scissor() const
422
442
};
423
443
}
424
444
425
- void context::set_scissor (r4::rectangle<uint32_t > r)
445
+ void context::set_scissor (const r4::rectangle<uint32_t >& r)
426
446
{
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
+ );
428
453
assert_opengl_no_error ();
429
454
}
430
455
@@ -448,9 +473,14 @@ r4::rectangle<uint32_t> context::get_viewport() const
448
473
};
449
474
}
450
475
451
- void context::set_viewport (r4::rectangle<uint32_t > r)
476
+ void context::set_viewport (const r4::rectangle<uint32_t >& r)
452
477
{
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
+ );
454
484
assert_opengl_no_error ();
455
485
}
456
486
0 commit comments