// File: /workspace/github_c_makefile_star2_O0/FredTheDino[P]Fog/src/engine/renderer/opengl_renderer.cpp
// Function: Renderer::Impl::create_frame_buffers(int, int)
void create_frame_buffers(int width, int height) {
    glGenTextures(OPENGL_NUM_CAMERAS, (GLuint *) &screen_textures);
    glGenFramebuffers(OPENGL_NUM_CAMERAS, (GLuint *) &screen_fbos);
    glGenRenderbuffers(OPENGL_NUM_CAMERAS, (GLuint *) &screen_rbos);
    for (u32 cam = 0; cam < OPENGL_NUM_CAMERAS; cam++) {
        GLuint fbo = screen_fbos[cam];
        GLuint rbo = screen_rbos[cam];
        GLuint texture = screen_textures[cam];

        glBindTexture(GL_TEXTURE_2D, texture);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
                GL_UNSIGNED_BYTE, NULL);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glBindTexture(GL_TEXTURE_2D, 0);

        glBindFramebuffer(GL_FRAMEBUFFER, fbo);
        {
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                    GL_TEXTURE_2D, texture, 0);

            glBindRenderbuffer(GL_RENDERBUFFER, rbo);
            {
                glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
                        width, height);
            }
            glBindRenderbuffer(GL_RENDERBUFFER, 0);

            glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
                    GL_RENDERBUFFER, rbo);

            if (glCheckFramebufferStatus(fbo) != GL_FRAMEBUFFER_COMPLETE)
                ERR("Incomplete framebuffer");
        }
    }
    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    Vec4 quad_verticies[] = {
        V4(-1, -1, 0, 0),
        V4( 1, -1, 1, 0),
        V4( 1,  1, 1, 1),

        V4(-1, -1, 0, 0),
        V4( 1,  1, 1, 1),
        V4(-1,  1, 0, 1),
    };

    glGenVertexArrays(1, &screen_quad_vao);
    glBindVertexArray(screen_quad_vao);

    glGenBuffers(1, &screen_quad_vbo);
    glBindBuffer(GL_ARRAY_BUFFER, screen_quad_vbo);
    glBufferData(GL_ARRAY_BUFFER, sizeof(quad_verticies), &quad_verticies,
                 GL_STATIC_DRAW);

    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);

    glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vec4),
                          (void *) offsetof(Vec4, x));
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vec4),
                          (void *) offsetof(Vec4, z));
    glBindVertexArray(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl $0x2, %edi
leaq 0x599d7(%rip), %rsi     # 0x85244
leaq 0x53774(%rip), %rax     # 0x7efe8
callq *(%rax)
movl $0x2, %edi
leaq 0x599b2(%rip), %rsi     # 0x85234
leaq 0x5373f(%rip), %rax     # 0x7efc8
callq *(%rax)
movl $0x2, %edi
leaq 0x599a5(%rip), %rsi     # 0x8523c
leaq 0x53742(%rip), %rax     # 0x7efe0
callq *(%rax)
movl $0x0, -0xc(%rbp)
cmpl $0x2, -0xc(%rbp)
jae 0x2ba63
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x59977(%rip), %rax     # 0x85234
movl (%rax,%rcx,4), %eax
movl %eax, -0x10(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x5996d(%rip), %rax     # 0x8523c
movl (%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0x59963(%rip), %rax     # 0x85244
movl (%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
leaq 0x531f2(%rip), %rax     # 0x7eae0
movq (%rax), %rax
movl -0x18(%rbp), %esi
movl $0xde1, %edi            # imm = 0xDE1
callq *%rax
leaq 0x54156(%rip), %rax     # 0x7fa58
movq (%rax), %rax
movl -0x4(%rbp), %ecx
movl -0x8(%rbp), %r8d
movl $0xde1, %edi            # imm = 0xDE1
xorl %r9d, %r9d
movl $0x1907, %edx           # imm = 0x1907
xorl %esi, %esi
movl %r9d, %esi
movl $0x1907, (%rsp)         # imm = 0x1907
movl $0x1401, 0x8(%rsp)      # imm = 0x1401
movq $0x0, 0x10(%rsp)
callq *%rax
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2601, %edx           # imm = 0x2601
leaq 0x5414a(%rip), %rax     # 0x7fa98
callq *(%rax)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2601, %edx           # imm = 0x2601
leaq 0x54132(%rip), %rax     # 0x7fa98
callq *(%rax)
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
leaq 0x5316a(%rip), %rax     # 0x7eae0
callq *(%rax)
leaq 0x53151(%rip), %rax     # 0x7ead0
movq (%rax), %rax
movl -0x10(%rbp), %esi
movl $0x8d40, %edi           # imm = 0x8D40
callq *%rax
leaq 0x53605(%rip), %rax     # 0x7ef98
movq (%rax), %rax
movl -0x18(%rbp), %ecx
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x8ce0, %esi           # imm = 0x8CE0
movl $0xde1, %edx            # imm = 0xDE1
xorl %r8d, %r8d
callq *%rax
leaq 0x53124(%rip), %rax     # 0x7ead8
movq (%rax), %rax
movl -0x14(%rbp), %esi
movl $0x8d41, %edi           # imm = 0x8D41
callq *%rax
leaq 0x53e10(%rip), %rax     # 0x7f7d8
movq (%rax), %rax
movl -0x4(%rbp), %edx
movl -0x8(%rbp), %ecx
movl $0x8d41, %edi           # imm = 0x8D41
movl $0x88f0, %esi           # imm = 0x88F0
callq *%rax
movl $0x8d41, %edi           # imm = 0x8D41
xorl %esi, %esi
leaq 0x530ed(%rip), %rax     # 0x7ead8
callq *(%rax)
leaq 0x5358c(%rip), %rax     # 0x7ef80
movq (%rax), %rax
movl -0x14(%rbp), %ecx
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x821a, %esi           # imm = 0x821A
movl $0x8d41, %edx           # imm = 0x8D41
callq *%rax
leaq 0x53136(%rip), %rax     # 0x7eb48
movq (%rax), %rax
movl -0x10(%rbp), %edi
callq *%rax
cmpl $0x8cd5, %eax           # imm = 0x8CD5
je 0x2ba53
movq 0x3d5b8(%rip), %rax     # 0x68fe0
movq (%rax), %rsi
leaq 0x1a23d(%rip), %rdi     # 0x45c6f
leaq 0x1a60c(%rip), %rdx     # 0x46045
movl $0x11c, %ecx            # imm = 0x11C
leaq 0x1a628(%rip), %r8      # 0x4606d
leaq 0x1a636(%rip), %r9      # 0x46082
movb $0x0, %al
callq 0xb100
jmp 0x2ba55
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2b8a7
leaq 0x53066(%rip), %rax     # 0x7ead0
movq (%rax), %rax
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
callq *%rax
movss 0x1959a(%rip), %xmm1    # 0x45018
movss %xmm1, -0x84(%rbp)
xorps %xmm3, %xmm3
movss %xmm3, -0x8c(%rbp)
movaps %xmm1, %xmm0
movaps %xmm3, %xmm2
callq 0xbc90
movss -0x8c(%rbp), %xmm3
movaps %xmm0, %xmm2
movaps %xmm1, %xmm0
movss -0x84(%rbp), %xmm1
movlpd %xmm2, -0x80(%rbp)
movlpd %xmm0, -0x78(%rbp)
movss 0x19544(%rip), %xmm2    # 0x45008
movss %xmm2, -0x88(%rbp)
movaps %xmm2, %xmm0
callq 0xbc90
movss -0x88(%rbp), %xmm3
movlpd %xmm0, -0x70(%rbp)
movlpd %xmm1, -0x68(%rbp)
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0xbc90
movss -0x8c(%rbp), %xmm3
movaps %xmm0, %xmm2
movaps %xmm1, %xmm0
movss -0x84(%rbp), %xmm1
movlpd %xmm2, -0x60(%rbp)
movlpd %xmm0, -0x58(%rbp)
movaps %xmm1, %xmm0
movaps %xmm3, %xmm2
callq 0xbc90
movss -0x88(%rbp), %xmm3
movlpd %xmm0, -0x50(%rbp)
movlpd %xmm1, -0x48(%rbp)
movaps %xmm3, %xmm0
movaps %xmm3, %xmm1
movaps %xmm3, %xmm2
callq 0xbc90
movss -0x8c(%rbp), %xmm2
movss -0x88(%rbp), %xmm3
movaps %xmm0, %xmm4
movss -0x84(%rbp), %xmm0
movlpd %xmm4, -0x40(%rbp)
movlpd %xmm1, -0x38(%rbp)
movaps %xmm3, %xmm1
callq 0xbc90
movlpd %xmm0, -0x30(%rbp)
movlpd %xmm1, -0x28(%rbp)
movl $0x1, %edi
leaq 0x596ca(%rip), %rsi     # 0x8524c
leaq 0x53467(%rip), %rax     # 0x7eff0
callq *(%rax)
leaq 0x52f56(%rip), %rax     # 0x7eae8
movq (%rax), %rax
leaq 0x596b0(%rip), %rcx     # 0x8524c
movl (%rcx), %edi
callq *%rax
movl $0x1, %edi
leaq 0x596a4(%rip), %rsi     # 0x85250
leaq 0x5340d(%rip), %rax     # 0x7efc0
callq *(%rax)
leaq 0x52ef4(%rip), %rax     # 0x7eab0
movq (%rax), %rax
leaq 0x5968a(%rip), %rcx     # 0x85250
movl (%rcx), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *%rax
movl $0x8892, %edi           # imm = 0x8892
movl $0x60, %esi
leaq -0x80(%rbp), %rdx
movl $0x88e4, %ecx           # imm = 0x88E4
leaq 0x52f3f(%rip), %rax     # 0x7eb28
callq *(%rax)
xorl %edi, %edi
leaq 0x53284(%rip), %rax     # 0x7ee78
callq *(%rax)
movl $0x1, %edi
leaq 0x53276(%rip), %rax     # 0x7ee78
callq *(%rax)
xorl %ecx, %ecx
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
movl $0x10, %r8d
xorl %eax, %eax
movl %eax, %r9d
leaq 0x54266(%rip), %rax     # 0x7fe88
movl %ecx, %edi
callq *(%rax)
movl $0x1, %edi
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x10, %r8d
movl $0x8, %r9d
leaq 0x5423e(%rip), %rax     # 0x7fe88
callq *(%rax)
xorl %edi, %edi
leaq 0x52e93(%rip), %rax     # 0x7eae8
callq *(%rax)
addq $0xb0, %rsp
popq %rbp
retq