// File: /workspace/github_c_makefile_star2_O3/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 0x438a9(%rip), %rbx     # 0x64a70
movl 0x4a0c3(%rip), %esi     # 0x6b290
movl $0x8a11, %edi           # imm = 0x8A11
callq *(%rbx)
leaq 0x43915(%rip), %rax     # 0x64af0
leaq 0x4a05e(%rip), %rcx     # 0x6b240
xorl %r14d, %r14d
movl $0x50, %edx
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%rax)
movl $0x8a11, %edi           # imm = 0x8A11
xorl %esi, %esi
callq *(%rbx)
movb $0x1, %r12b
leaq 0x49dca(%rip), %r15     # 0x6afd0
leaq 0x49fc3(%rip), %r13     # 0x6b1d0
leaq 0x49fe0(%rip), %rax     # 0x6b1f4
movl (%rax,%r14,4), %esi
movl $0x8d40, %edi           # imm = 0x8D40
leaq 0x4386c(%rip), %rax     # 0x64a90
callq *(%rax)
movss 0xeffe(%rip), %xmm0     # 0x3022c
movss 0xedd6(%rip), %xmm1     # 0x3000c
movss 0xeffe(%rip), %xmm2     # 0x3023c
movss 0xedbe(%rip), %xmm3     # 0x30004
leaq 0x438fb(%rip), %rax     # 0x64b48
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x438bd(%rip), %rax     # 0x64b18
callq *(%rax)
leaq 0x2f6a4(%rip), %rax     # 0x50908
movl (%rax), %eax
btl %r14d, %eax
jae 0x212da
leaq 0x49d45(%rip), %rax     # 0x6afb8
movl (%rax), %edi
leaq 0x44934(%rip), %rax     # 0x65bb0
callq *(%rax)
leaq 0x49d37(%rip), %rax     # 0x6afbc
movl (%rax), %edi
movl %r14d, %esi
leaq 0x44827(%rip), %rax     # 0x65ab8
callq *(%rax)
xorl %ebx, %ebx
leaq (%rbx,%r15), %rdi
callq 0x2db4e
addq $0x20, %rbx
cmpq $0x200, %rbx            # imm = 0x200
jne 0x21295
leaq 0x49d0e(%rip), %rax     # 0x6afc0
movl (%rax), %edi
leaq 0x448f5(%rip), %rax     # 0x65bb0
callq *(%rax)
leaq 0x49cf8(%rip), %rax     # 0x6afbc
movl (%rax), %edi
movl %r14d, %esi
leaq 0x447e8(%rip), %rax     # 0x65ab8
callq *(%rax)
movq %r13, %rdi
callq 0x2dc0a
movl $0x1, %r14d
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x2120d
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
leaq 0x43792(%rip), %rax     # 0x64a90
callq *(%rax)
movss 0xef24(%rip), %xmm0     # 0x3022c
movss 0xef2c(%rip), %xmm1     # 0x3023c
movss 0xecf4(%rip), %xmm2     # 0x3000c
movss 0xece4(%rip), %xmm3     # 0x30004
leaq 0x43821(%rip), %rax     # 0x64b48
callq *(%rax)
movl $0x4100, %edi           # imm = 0x4100
leaq 0x437e3(%rip), %rax     # 0x64b18
callq *(%rax)
callq 0x2025e
leaq 0x49edd(%rip), %rax     # 0x6b220
movq (%rax), %rdi
callq 0x21f0
movl $0x0, 0x8(%r13)
movl 0xc(%r13), %ecx
testq %rcx, %rcx
je 0x2137a
movq 0x10(%r13), %rax
shlq $0x2, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
movl $0x0, (%rax,%rdx)
addq $0xc, %rdx
cmpq %rdx, %rcx
jne 0x2136a
xorl %eax, %eax
movq %rax, %rcx
shlq $0x5, %rcx
movl $0x0, 0x8(%r15,%rcx)
movl 0xc(%r15,%rcx), %edx
testq %rdx, %rdx
je 0x213b7
addq %r15, %rcx
movq 0x10(%rcx), %rcx
shlq $0x2, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
movl $0x0, (%rcx,%rsi)
addq $0xc, %rsi
cmpq %rsi, %rdx
jne 0x213a7
incq %rax
cmpq $0x10, %rax
jne 0x2137c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq