コード例 #1
0
            elif ev.key == pygame.K_z:
                renderer.setShaders(shaders.vertex_shader, shaders.colors_shader)
            elif ev.key == pygame.K_x:
                renderer.setShaders(shaders.vertex_shader, shaders.toon_shader)
            elif ev.key == pygame.K_c:
                renderer.setShaders(shaders.vertex_shader, shaders.yellow_shader)
            elif ev.key == pygame.K_v:
                renderer.setShaders(shaders.vertex_shader, shaders.blue_shader)
            elif ev.key == pygame.K_b:
                renderer.setShaders(shaders.vertex_shader, shaders.green_shader)
            elif ev.key == pygame.K_n:
                renderer.setShaders(shaders.vertex_shader, shaders.fragment_shader)
        elif ev.type == pygame.MOUSEBUTTONDOWN or ev.type == pygame.MOUSEBUTTONUP:
            if ev.button == 4:
                if renderer.camPosition.z >= 0.75:
                    renderer.camPosition.z -= 2 * deltaTime
            elif ev.button == 5:
                if renderer.camPosition.z <= 10:
                    renderer.camPosition.z += 2 * deltaTime
            elif ev.button == 1:
                renderer.activeShaderIndex = (renderer.activeShaderIndex + 1) % len(renderer.shaderList)

    renderer.cameraView()
    renderer.render()

    pygame.display.flip()
    clock.tick(60)
    deltaTime = clock.get_time()/1000

pygame.quit()
コード例 #2
0
ファイル: renderer.py プロジェクト: FR98/open-gl
    for ev in pygame.event.get():
        if ev.type == pygame.QUIT:
            isPlaying = False
        elif ev.type == pygame.KEYDOWN:
            if ev.key == pygame.K_1:
                r.filledMode()
            elif ev.key == pygame.K_2:
                r.wireframeMode()
            elif ev.key == pygame.K_SPACE:
                r.activeModelIndex = (r.activeModelIndex + 1) % len(r.modelList)
            elif ev.key == pygame.K_5:
                actual_shader_index = (actual_shader_index + 1) % len(all_shaders)
                r.setShaders(shaders.vertex_shader, all_shaders[actual_shader_index])
            elif ev.key == pygame.K_ESCAPE:
                isPlaying = False
        elif ev.type == pygame.MOUSEBUTTONDOWN or ev.type == pygame.MOUSEBUTTONUP:
            if ev.button == 4:
                if r.camPosition.z >= 0:
                    r.camPosition.z -= 10 * deltaTime
            if ev.button == 5:
                if r.camPosition.z <= 100:
                    r.camPosition.z += 10 * deltaTime

    r.cameraView()
    r.render()
    pygame.display.flip()
    clock.tick(60)
    deltaTime = clock.get_time() / 1000
pygame.quit()