MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / draw

Method draw

src/visualization/components/buffer.cpp:609–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

607}
608
609void Buffer::draw(const mat4& projection, const mat4& viewInv) {
610 buff_prog_.use();
611 const auto model = game_object_ref().get_pose();
612 const auto mvp = projection * viewInv * model;
613
614 gl_canvas_ref().glEnableVertexAttribArray(0);
615 gl_canvas_ref().glActiveTexture(GL_TEXTURE0);
616
617 buff_prog_.uniform1i("sampler", 0);
618 if (const auto stage = game_object_ref().get_stage();
619 stage.has_value() && stage->get().get_contrast_enabled()) {
620 buff_prog_.uniform4fv(
621 "brightness_contrast", 2, auto_buffer_contrast_brightness_.data());
622 } else {
623 buff_prog_.uniform4fv("brightness_contrast", 2, no_ac_params.data());
624 }
625
626 const auto buffer_width_i = static_cast<int>(buffer_width_f);
627 const auto buffer_height_i = static_cast<int>(buffer_height_f);
628
629 auto remaining_h = buffer_height_i;
630
631 auto py = static_cast<float>(-buffer_height_i) / 2.0f;
632 if (buffer_height_i % 2 == 1) {
633 py -= 0.5f;
634 }
635
636 for (int ty = 0; ty < num_textures_y; ++ty) {
637 const auto buff_h = (std::min)(remaining_h, max_texture_size);
638 remaining_h -= buff_h;
639
640 py += static_cast<float>(buff_h) / 2.0f;
641 if (buff_h % 2 == 1) {
642 py += 0.5f;
643 }
644
645 auto remaining_w = buffer_width_i;
646
647 auto px = static_cast<float>(-buffer_width_i) / 2.0f;
648 if (buffer_width_i % 2 == 1) {
649 px -= 0.5f;
650 }
651
652 for (int tx = 0; tx < num_textures_x; ++tx) {
653 const auto buff_w = (std::min)(remaining_w, max_texture_size);
654 remaining_w -= buff_w;
655
656 gl_canvas_ref().glBindTexture(GL_TEXTURE_2D,
657 buff_tex[ty * num_textures_x + tx]);
658
659 auto tile_model = mat4{};
660
661 px += static_cast<float>(buff_w) / 2.0f;
662 if (buff_w % 2 == 1) {
663 px += 0.5f;
664 }
665
666 tile_model.set_from_st(static_cast<float>(buff_w),

Callers

nothing calls this directly

Calls 15

useMethod · 0.80
get_poseMethod · 0.80
glActiveTextureMethod · 0.80
uniform1iMethod · 0.80
get_stageMethod · 0.80
get_contrast_enabledMethod · 0.80
uniform4fvMethod · 0.80
glBindTextureMethod · 0.80
set_from_stMethod · 0.80
uniform_matrix4fvMethod · 0.80
uniform2fMethod · 0.80

Tested by

no test coverage detected