// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, -0x2c(%rbp)
movl %edi, -0x30(%rbp)
leaq 0x44d76(%rip), %rax     # 0x64fb8
leaq 0x4afcb(%rip), %rsi     # 0x6b214
movl $0x2, %edi
callq *(%rax)
leaq 0x44d41(%rip), %rax     # 0x64f98
leaq 0x4afa6(%rip), %rsi     # 0x6b204
movl $0x2, %edi
callq *(%rax)
leaq 0x44d44(%rip), %rax     # 0x64fb0
leaq 0x4af99(%rip), %rsi     # 0x6b20c
movl $0x2, %edi
callq *(%rax)
xorl %ebx, %ebx
movl -0x30(%rbp), %r15d
leaq 0x4af7d(%rip), %rax     # 0x6b204
movl (%rax,%rbx,4), %eax
movl %eax, -0x34(%rbp)
leaq 0x4af78(%rip), %rax     # 0x6b20c
movl (%rax,%rbx,4), %eax
movl %eax, -0x38(%rbp)
leaq 0x4af73(%rip), %rax     # 0x6b214
movl (%rax,%rbx,4), %r13d
movl $0xde1, %edi            # imm = 0xDE1
movl %r13d, %esi
leaq 0x447fc(%rip), %rax     # 0x64ab0
callq *(%rax)
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1907, %edx           # imm = 0x1907
movl %r15d, %ecx
movl -0x2c(%rbp), %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x1401                 # imm = 0x1401
pushq $0x1907                 # imm = 0x1907
leaq 0x45745(%rip), %rax     # 0x65a28
callq *(%rax)
addq $0x20, %rsp
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2601, %edx           # imm = 0x2601
leaq 0x45769(%rip), %r12     # 0x65a68
callq *(%r12)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2601, %edx           # imm = 0x2601
callq *(%r12)
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
leaq 0x4478c(%rip), %rax     # 0x64ab0
callq *(%rax)
movl $0x8d40, %edi           # imm = 0x8D40
movl -0x34(%rbp), %r12d
movl %r12d, %esi
leaq 0x44767(%rip), %rax     # 0x64aa0
callq *(%rax)
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x8ce0, %esi           # imm = 0x8CE0
movl $0xde1, %edx            # imm = 0xDE1
movl %r13d, %ecx
xorl %r8d, %r8d
leaq 0x44c11(%rip), %rax     # 0x64f68
callq *(%rax)
movl $0x8d41, %edi           # imm = 0x8D41
movl -0x38(%rbp), %r13d
movl %r13d, %esi
leaq 0x4473c(%rip), %r14     # 0x64aa8
callq *(%r14)
movl $0x8d41, %edi           # imm = 0x8D41
movl $0x88f0, %esi           # imm = 0x88F0
movl %r15d, %edx
movl -0x2c(%rbp), %ecx
leaq 0x45422(%rip), %rax     # 0x657a8
callq *(%rax)
movl $0x8d41, %edi           # imm = 0x8D41
xorl %esi, %esi
callq *(%r14)
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x821a, %esi           # imm = 0x821A
movl $0x8d41, %edx           # imm = 0x8D41
movl %r13d, %ecx
leaq 0x44ba5(%rip), %rax     # 0x64f50
callq *(%rax)
movl %r12d, %edi
leaq 0x44761(%rip), %rax     # 0x64b18
callq *(%rax)
cmpl $0x8cd5, %eax           # imm = 0x8CD5
je 0x203f2
movq 0x2ec09(%rip), %rax     # 0x4efd0
movq (%rax), %rsi
leaq 0x108de(%rip), %rdi     # 0x30caf
leaq 0x10cad(%rip), %rdx     # 0x31085
movl $0x11c, %ecx            # imm = 0x11C
leaq 0x10cc9(%rip), %r8      # 0x310ad
leaq 0x10cd7(%rip), %r9      # 0x310c2
xorl %eax, %eax
callq 0x711f
incq %rbx
cmpq $0x1, %rbx
je 0x20280
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
leaq 0x44693(%rip), %rax     # 0x64aa0
callq *(%rax)
movsd 0x10661(%rip), %xmm0    # 0x30a78
leaq -0xa0(%rbp), %rbx
movaps %xmm0, (%rbx)
movsd 0xfe67(%rip), %xmm1     # 0x30290
movss 0xfbd3(%rip), %xmm2     # 0x30004
movlhps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movaps %xmm1, 0x10(%rbx)
movaps 0xfe61(%rip), %xmm1     # 0x302a0
shufps $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movaps %xmm1, 0x20(%rbx)
movaps %xmm0, 0x30(%rbx)
movaps %xmm1, 0x40(%rbx)
movaps 0xfe5a(%rip), %xmm0     # 0x302b0
movaps %xmm0, 0x50(%rbx)
leaq 0x44b5f(%rip), %rax     # 0x64fc0
leaq 0x4adb4(%rip), %r14     # 0x6b21c
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
leaq 0x4463f(%rip), %r15     # 0x64ab8
movl (%r14), %edi
callq *(%r15)
leaq 0x44b0a(%rip), %rax     # 0x64f90
leaq 0x4ad93(%rip), %r14     # 0x6b220
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
leaq 0x445e2(%rip), %rax     # 0x64a80
movl (%r14), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
leaq 0x44649(%rip), %rax     # 0x64af8
movl $0x60, %esi
movl $0x8892, %edi           # imm = 0x8892
movq %rbx, %rdx
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
leaq 0x4497e(%rip), %rbx     # 0x64e48
xorl %edi, %edi
callq *(%rbx)
movl $0x1, %edi
callq *(%rbx)
leaq 0x4597c(%rip), %rbx     # 0x65e58
xorl %edi, %edi
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x10, %r8d
xorl %r9d, %r9d
callq *(%rbx)
movl $0x8, %r9d
movl $0x1, %edi
movl $0x2, %esi
movl $0x1406, %edx           # imm = 0x1406
xorl %ecx, %ecx
movl $0x10, %r8d
callq *(%rbx)
xorl %edi, %edi
callq *(%r15)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq