コード例 #1
0
ファイル: main.py プロジェクト: TanVD/itmo-graphics
def main():
    # Will use GLUT https://compgraphics.info/OpenGL/template_glut.php,
    # but on Python https://wiki.python.org/moin/PyOpenGL

    obj_file = ObjLoader(f"models/{Config.model}.obj")
    obj_file.add_plane(plane(0.2, 0.1))

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
    glutInitWindowSize(Config.width, Config.height)
    glutCreateWindow("HW3, Shadows, Tankov Vladislav")

    # glEnable(GL_DEBUG_OUTPUT)
    # glDebugMessageCallback(GLDEBUGPROC(cb_dbg_msg), None)
    glEnable(GL_TEXTURE_2D)
    glEnable(GL_DEPTH_TEST)

    Model.create_buffers(obj_file.prepared_vertices,
                         obj_file.prepared_tex_coords,
                         obj_file.prepared_normals)
    ShadowMap.create()

    ShadowProgram.create()
    ShadowProgram.attach_shader(
        Shader.load("shader/shadow_vertex.glsl", GL_VERTEX_SHADER))
    ShadowProgram.attach_shader(
        Shader.load("shader/shadow_fragment.glsl", GL_FRAGMENT_SHADER))
    ShadowProgram.link()
    ShadowProgram.use()

    Program.create()
    Program.attach_shader(
        Shader.load("shader/main_vertex.glsl", GL_VERTEX_SHADER))
    Program.attach_shader(
        Shader.load("shader/main_fragment.glsl", GL_FRAGMENT_SHADER))
    Program.link()
    Program.use()

    Camera.update_gl()
    Lightning.update_gl()

    glutDisplayFunc(
        Display.display(obj_file.prepared_vertices, obj_file.prepared_normals))
    glutReshapeFunc(Display.reshape)

    glutIdleFunc(Display.idle)

    glutMouseFunc(Controls.mouse)
    glutMotionFunc(Controls.motion)

    glutMainLoop()
コード例 #2
0
ファイル: main.py プロジェクト: TanVD/itmo-graphics
def main():
    # Will use GLUT https://compgraphics.info/OpenGL/template_glut.php,
    # but on Python https://wiki.python.org/moin/PyOpenGL

    obj_file = ObjLoader(f"models/{Config.model}.obj")

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH)
    glutInitWindowSize(Config.width, Config.height)
    glutCreateWindow("HW2, Object, Tankov Vladislav")

    Program.prepare(obj_file.prepared_vertices, obj_file.prepared_normals)

    Program.create()
    # forward tex coord to fragment
    Program.attach_shader(
        Shader.load("shader/vertex_noise.glsl", GL_VERTEX_SHADER))
    # apply noise
    Program.attach_shader(
        Shader.load("shader/fragment_noise.glsl", GL_FRAGMENT_SHADER))
    Program.link()

    Texture.create_2d(obj_file.prepared_tex_coords)

    Program.use()

    Camera.update_gl()
    Lightning.update_gl()

    glutDisplayFunc(Display.display(obj_file.prepared_vertices))
    glutReshapeFunc(Display.reshape)

    glutIdleFunc(Display.idle)

    glutMouseFunc(Controls.mouse)
    glutMotionFunc(Controls.motion)

    glutCreateMenu(Controls.menu)
    glutAddMenuEntry("Disable Dissolve", 0)
    glutAddMenuEntry("Enable Dissolve", 1)
    glutAttachMenu(GLUT_RIGHT_BUTTON)

    glutMainLoop()
コード例 #3
0
def main():
    # Will use GLUT https://compgraphics.info/OpenGL/template_glut.php,
    # but on Python https://wiki.python.org/moin/PyOpenGL

    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE)
    glutInitWindowSize(Display.width, Display.height)
    glutCreateWindow("HW1, Mandelbrot, Tankov Vladislav")

    Texture.create_1d()
    Program.create()
    Program.attach_shader(Shader.load_fragment("shader/shader_frag.glsl"))
    Program.link()

    glutDisplayFunc(display)
    glutReshapeFunc(Display.reshape)
    glutMouseFunc(Controls.mouse)
    glutMotionFunc(Controls.motion)
    # For some reason wheel event is not working on my computer
    glutKeyboardUpFunc(Controls.key_up)

    glutMainLoop()