// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::blit()
void blit() {
    glBindBuffer(GL_UNIFORM_BUFFER, ubo_global);
    glBufferSubData(GL_UNIFORM_BUFFER, 0, ubo_global_size, &_fog_global_window_state);
    glBindBuffer(GL_UNIFORM_BUFFER, 0);

    for (u32 cam = 0; cam < OPENGL_NUM_CAMERAS; cam++) {
        glBindFramebuffer(GL_FRAMEBUFFER, screen_fbos[cam]);
        glClearColor(0.1f, 0.2f, 0.3f, 1.0f);
        clear();
        u32 bit = (cam == 0) ? 1 : (1 << cam);
        if (!(_fog_active_cameras & bit)) continue;

        master_shader_program.bind();
        glUniform1ui(master_shader_current_cam_loc, cam);
        for (u32 layer = 0; layer < OPENGL_NUM_LAYERS; layer++)
            sprite_render_queues[layer].draw();

        font_shader_program.bind();
        // TODO(ed): Some way to do camera specific text or rendering
        // would probably be good.
        glUniform1ui(master_shader_current_cam_loc, cam);
        font_render_queue.draw();
    }

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glClearColor(0.1f, 0.3f, 0.2f, 1.0f);
    clear();
    render_post_processing();
    // TODO(ed): This is where screen space reflections can be rendered.
    // TODO(ed): Passing values is kinda tricky right now, might need some
    // way to pass uniforms to the shader...

    SDL_GL_SwapWindow(window);

    font_render_queue.clear();
    for (u32 layer = 0; layer < OPENGL_NUM_LAYERS; layer++)
        sprite_render_queues[layer].clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x3ff51(%rip), %r14     # 0x5fa80
movl 0x46767(%rip), %esi     # 0x6629c
movl $0x8a11, %edi           # imm = 0x8A11
callq *(%r14)
leaq 0x3ffbc(%rip), %rax     # 0x5fb00
leaq 0x46701(%rip), %rcx     # 0x6624c
xorl %ebx, %ebx
pushq $0x50
popq %rdx
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%rax)
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%r14)
leaq 0x41056(%rip), %r12     # 0x60bc0
leaq 0x4645b(%rip), %r13     # 0x65fcc
leaq 0x46468(%rip), %r15     # 0x65fe0
leaq 0x3ff21(%rip), %rax     # 0x5faa0
movq (%rax), %rax
cmpq $0x2, %rbx
je 0x1fc4e
leaq 0x46671(%rip), %rcx     # 0x66204
movl (%rcx,%rbx,4), %esi
movl $0x8d40, %edi           # imm = 0x8D40
callq *%rax
movss 0xb68b(%rip), %xmm0     # 0x2b230
movss 0xb45f(%rip), %xmm1     # 0x2b00c
movss 0xb687(%rip), %xmm2     # 0x2b23c
movss 0xb447(%rip), %xmm3     # 0x2b004
leaq 0x3ff94(%rip), %rax     # 0x5fb58
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x3ff56(%rip), %rax     # 0x5fb28
callq *(%rax)
leaq 0x2bd3d(%rip), %rax     # 0x4b918
movl (%rax), %eax
btl %ebx, %eax
jae 0x1fc46
leaq 0x463df(%rip), %rax     # 0x65fc8
movl (%rax), %edi
movq %r12, %r14
callq *(%r12)
movl (%r13), %edi
movl %ebx, %esi
leaq 0x40ec9(%rip), %rax     # 0x60ac8
callq *(%rax)
xorl %r12d, %r12d
cmpq $0x200, %r12            # imm = 0x200
je 0x1fc1c
leaq (%r12,%r15), %rdi
callq 0x298a0
addq $0x20, %r12
jmp 0x1fc04
leaq 0x463ad(%rip), %rax     # 0x65fd0
movl (%rax), %edi
movq %r14, %r12
callq *(%r14)
movl (%r13), %edi
movl %ebx, %esi
leaq 0x40e90(%rip), %rax     # 0x60ac8
callq *(%rax)
leaq 0x4659f(%rip), %rdi     # 0x661e0
callq 0x2995a
incq %rbx
jmp 0x1fb78
xorl %ebx, %ebx
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
callq *%rax
movss 0xb5cf(%rip), %xmm0     # 0x2b230
movss 0xb5d3(%rip), %xmm1     # 0x2b23c
movss 0xb39b(%rip), %xmm2     # 0x2b00c
movss 0xb38b(%rip), %xmm3     # 0x2b004
leaq 0x3fed8(%rip), %rax     # 0x5fb58
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x3fe9a(%rip), %rax     # 0x5fb28
callq *(%rax)
callq 0x1ebf6
leaq 0x46594(%rip), %rax     # 0x66230
movq (%rax), %rdi
callq 0x21f0
leaq 0x46535(%rip), %rdi     # 0x661e0
callq 0x29a14
cmpq $0x200, %rbx            # imm = 0x200
je 0x1fcc8
leaq (%rbx,%r15), %rdi
callq 0x29a38
addq $0x20, %rbx
jmp 0x1fcb0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq