def main():
    glfw.set_error_callback(error_callback)
    if (not glfw.init()):
        raise Exception('GLFW Initialization error')
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 5)
    glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
    window = glfw.create_window(640, 480, 'Triangle Viewer', None, None)
    if (not window):
        glfw.terminate()
        raise RuntimeError('Failed to create glfw window')
    glfw.make_context_current(window)
    glfw.swap_interval(1)
    vao = GL.glGenVertexArrays(1)
    GL.glBindVertexArray(vao)
    vertices = vbo.VBO(numpy.array([[(- 0.6), (- 0.4), 1.0, 0.0, 0.0], [0.6, (- 0.4), 0.0, 1.0, 0.0], [0.0, 0.6, 0.0, 0.0, 1.0]], dtype='float32'))
    vertices.bind()
    mvp_location = 0
    vpos_location = 0
    vcol_location = 1
    GL.glEnableVertexAttribArray(vpos_location)
    fsize = vertices.dtype.itemsize
    GL.glVertexAttribPointer(vpos_location, 2, GL.GL_FLOAT, False, (fsize * 5), (vertices + (fsize * 0)))
    GL.glEnableVertexAttribArray(vcol_location)
    GL.glVertexAttribPointer(vcol_location, 3, GL.GL_FLOAT, False, (fsize * 5), (vertices + (fsize * 2)))
    vertex_shader = compileShader(('#version 450 core\n        #line 55\n        \n        layout(location = %d) uniform mat4 MVP = mat4(1);\n        \n        layout(location = %d) in vec2 vPos;\n        layout(location = %d) in vec3 vCol;\n        \n        out vec3 color;\n\n        void main() \n        {\n            gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n            color = vCol;\n        }\n        ' % (mvp_location, vpos_location, vcol_location)), GL.GL_VERTEX_SHADER)
    fragment_shader = compileShader('#version 450 core\n        #line 73\n\n        in vec3 color;\n        out vec4 fragColor;\n\n        void main() \n        {\n            fragColor = vec4(color, 1);\n        }\n        ', GL.GL_FRAGMENT_SHADER)
    program = compileProgram(vertex_shader, fragment_shader)
    while (not glfw.window_should_close(window)):
        glfw.make_context_current(window)
        (width, height) = glfw.get_framebuffer_size(window)
        GL.glViewport(0, 0, width, height)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        m = rotate_z(glfw.get_time())
        ratio = (width / float(height))
        p = ortho((- ratio), ratio, (- 1.0), 1.0, 1.0, (- 1.0))
        mvp = (m * p)
        GL.glBindVertexArray(vao)
        GL.glUseProgram(program)
        GL.glUniformMatrix4fv(mvp_location, 1, False, pack(mvp))
        GL.glDrawArrays(GL.GL_TRIANGLES, 0, 3)
        glfw.swap_buffers(window)
        glfw.poll_events()
    glfw.make_context_current(window)
    glfw.destroy_window(window)
    glfw.terminate()
    sys.exit(0)
def main():
    glfw.set_error_callback(error_callback)
    if (not glfw.init()):
        raise Exception('GLFW Initialization error')
    glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 4)
    glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 5)
    glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
    window = glfw.create_window(640, 480, 'Triangle Viewer', None, None)
    if (not window):
        glfw.terminate()
        raise RuntimeError('Failed to create glfw window')
    glfw.make_context_current(window)
    glfw.swap_interval(1)
    vao = GL.glGenVertexArrays(1)
    GL.glBindVertexArray(vao)
    vertices = vbo.VBO(numpy.array([[(- 0.6), (- 0.4), 1.0, 0.0, 0.0], [0.6, (- 0.4), 0.0, 1.0, 0.0], [0.0, 0.6, 0.0, 0.0, 1.0]], dtype='float32'))
    vertices.bind()
    mvp_location = 0
    vpos_location = 0
    vcol_location = 1
    GL.glEnableVertexAttribArray(vpos_location)
    fsize = vertices.dtype.itemsize
    GL.glVertexAttribPointer(vpos_location, 2, GL.GL_FLOAT, False, (fsize * 5), (vertices + (fsize * 0)))
    GL.glEnableVertexAttribArray(vcol_location)
    GL.glVertexAttribPointer(vcol_location, 3, GL.GL_FLOAT, False, (fsize * 5), (vertices + (fsize * 2)))
    vertex_shader = compileShader(('#version 450 core\n        #line 55\n        \n        layout(location = %d) uniform mat4 MVP = mat4(1);\n        \n        layout(location = %d) in vec2 vPos;\n        layout(location = %d) in vec3 vCol;\n        \n        out vec3 color;\n\n        void main() \n        {\n            gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n            color = vCol;\n        }\n        ' % (mvp_location, vpos_location, vcol_location)), GL.GL_VERTEX_SHADER)
    fragment_shader = compileShader('#version 450 core\n        #line 73\n\n        in vec3 color;\n        out vec4 fragColor;\n\n        void main() \n        {\n            fragColor = vec4(color, 1);\n        }\n        ', GL.GL_FRAGMENT_SHADER)
    program = compileProgram(vertex_shader, fragment_shader)
    while (not glfw.window_should_close(window)):
        glfw.make_context_current(window)
        (width, height) = glfw.get_framebuffer_size(window)
        GL.glViewport(0, 0, width, height)
        GL.glClear(GL.GL_COLOR_BUFFER_BIT)
        m = rotate_z(glfw.get_time())
        ratio = (width / float(height))
        p = ortho((- ratio), ratio, (- 1.0), 1.0, 1.0, (- 1.0))
        mvp = (m * p)
        GL.glBindVertexArray(vao)
        GL.glUseProgram(program)
        GL.glUniformMatrix4fv(mvp_location, 1, False, pack(mvp))
        GL.glDrawArrays(GL.GL_TRIANGLES, 0, 3)
        glfw.swap_buffers(window)
        glfw.poll_events()
    glfw.make_context_current(window)
    glfw.destroy_window(window)
    glfw.terminate()
    sys.exit(0)