// File: /workspace/github_c_makefile_star2_O3/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, -0x30(%rbp)
movl %edi, -0x2c(%rbp)
leaq 0x45034(%rip), %rax     # 0x64fa8
leaq 0x4b289(%rip), %rsi     # 0x6b204
movl $0x2, %edi
callq *(%rax)
leaq 0x44fff(%rip), %rax     # 0x64f88
leaq 0x4b264(%rip), %rsi     # 0x6b1f4
movl $0x2, %edi
callq *(%rax)
leaq 0x45002(%rip), %rax     # 0x64fa0
leaq 0x4b257(%rip), %rsi     # 0x6b1fc
movl $0x2, %edi
callq *(%rax)
movb $0x1, %cl
xorl %eax, %eax
movl -0x2c(%rbp), %ebx
movl -0x30(%rbp), %r14d
movl %ecx, -0x38(%rbp)
leaq 0x4b233(%rip), %rcx     # 0x6b1f4
movl (%rcx,%rax,4), %r12d
leaq 0x4b230(%rip), %rcx     # 0x6b1fc
movl (%rcx,%rax,4), %ecx
movl %ecx, -0x34(%rbp)
leaq 0x4b22b(%rip), %rcx     # 0x6b204
movl (%rcx,%rax,4), %r13d
movl $0xde1, %edi            # imm = 0xDE1
movl %r13d, %esi
leaq 0x44ab4(%rip), %rax     # 0x64aa0
callq *(%rax)
subq $0x8, %rsp
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
movl $0x1907, %edx           # imm = 0x1907
movl %ebx, %ecx
movl %r14d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x1401                 # imm = 0x1401
pushq $0x1907                 # imm = 0x1907
leaq 0x459ff(%rip), %rax     # 0x65a18
callq *(%rax)
addq $0x20, %rsp
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2801, %esi           # imm = 0x2801
movl $0x2601, %edx           # imm = 0x2601
leaq 0x45a23(%rip), %r15     # 0x65a58
callq *(%r15)
movl $0xde1, %edi            # imm = 0xDE1
movl $0x2800, %esi           # imm = 0x2800
movl $0x2601, %edx           # imm = 0x2601
callq *(%r15)
movl $0xde1, %edi            # imm = 0xDE1
xorl %esi, %esi
leaq 0x44a48(%rip), %rax     # 0x64aa0
callq *(%rax)
movl $0x8d40, %edi           # imm = 0x8D40
movl %r12d, %esi
leaq 0x44a27(%rip), %rax     # 0x64a90
callq *(%rax)
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x8ce0, %esi           # imm = 0x8CE0
movl $0xde1, %edx            # imm = 0xDE1
movl %r13d, %ecx
xorl %r8d, %r8d
leaq 0x44ed1(%rip), %rax     # 0x64f58
callq *(%rax)
movl $0x8d41, %edi           # imm = 0x8D41
movl -0x34(%rbp), %r13d
movl %r13d, %esi
leaq 0x449fc(%rip), %r15     # 0x64a98
callq *(%r15)
movl $0x8d41, %edi           # imm = 0x8D41
movl $0x88f0, %esi           # imm = 0x88F0
movl %ebx, %edx
movl %r14d, %ecx
leaq 0x456e3(%rip), %rax     # 0x65798
callq *(%rax)
movl $0x8d41, %edi           # imm = 0x8D41
xorl %esi, %esi
callq *(%r15)
movl $0x8d40, %edi           # imm = 0x8D40
movl $0x821a, %esi           # imm = 0x821A
movl $0x8d41, %edx           # imm = 0x8D41
movl %r13d, %ecx
leaq 0x44e66(%rip), %rax     # 0x64f40
callq *(%rax)
movl %r12d, %edi
leaq 0x44a22(%rip), %rax     # 0x64b08
callq *(%rax)
cmpl $0x8cd5, %eax           # imm = 0x8CD5
je 0x20121
movq 0x2eeda(%rip), %rax     # 0x4efd0
movq (%rax), %rsi
leaq 0x10b9f(%rip), %rdi     # 0x30c9f
leaq 0x10f6e(%rip), %rdx     # 0x31075
movl $0x11c, %ecx            # imm = 0x11C
leaq 0x10f8a(%rip), %r8      # 0x3109d
leaq 0x10f98(%rip), %r9      # 0x310b2
xorl %eax, %eax
callq 0x718c
movl $0x1, %eax
testb $0x1, -0x38(%rbp)
movl $0x0, %ecx
jne 0x1ffb7
movl $0x8d40, %edi           # imm = 0x8D40
xorl %esi, %esi
leaq 0x4494d(%rip), %rax     # 0x64a90
callq *(%rax)
movsd 0x1091b(%rip), %xmm0    # 0x30a68
leaq -0xa0(%rbp), %rbx
movaps %xmm0, (%rbx)
movsd 0x10131(%rip), %xmm1    # 0x30290
movss 0xfe9d(%rip), %xmm2     # 0x30004
movlhps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0]
movaps %xmm1, 0x10(%rbx)
movaps 0x1012b(%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 0x10124(%rip), %xmm0    # 0x302b0
movaps %xmm0, 0x50(%rbx)
leaq 0x44e19(%rip), %rax     # 0x64fb0
leaq 0x4b06e(%rip), %r14     # 0x6b20c
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
leaq 0x448f9(%rip), %r15     # 0x64aa8
movl (%r14), %edi
callq *(%r15)
leaq 0x44dc4(%rip), %rax     # 0x64f80
leaq 0x4b04d(%rip), %r14     # 0x6b210
movl $0x1, %edi
movq %r14, %rsi
callq *(%rax)
leaq 0x4489c(%rip), %rax     # 0x64a70
movl (%r14), %esi
movl $0x8892, %edi           # imm = 0x8892
callq *(%rax)
leaq 0x44903(%rip), %rax     # 0x64ae8
movl $0x60, %esi
movl $0x8892, %edi           # imm = 0x8892
movq %rbx, %rdx
movl $0x88e4, %ecx           # imm = 0x88E4
callq *(%rax)
leaq 0x44c38(%rip), %rbx     # 0x64e38
xorl %edi, %edi
callq *(%rbx)
movl $0x1, %edi
callq *(%rbx)
leaq 0x45c36(%rip), %rbx     # 0x65e48
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