Форум программистов, компьютерный форум, киберфорум
Наши страницы
8Observer8
Войти
Регистрация
Восстановить пароль
Рейтинг: 5.00. Голосов: 1.

Set Up OpenGL 3 for Python

Запись от 8Observer8 размещена 18.02.2019 в 17:41
Обновил(-а) 8Observer8 19.02.2019 в 02:47

You need to type commands in the console terminal (you need to run the console terminal as administrator):

Цитата:
pip install GLFW
pip install PyOpenGL
pip install Pyrr
pip install NumPy
Pyrr - for trigonometry and linear algebra
NumPy - for special arrays for OpenGL functions
You will see how to use these libraries in video tutorial below.

Now you are ready to create simple games in Python and OpenGL. See this video tutorial about basics of OpenGL. You can start from the second lesson: Modern OpenGL programming in Python - part 02 - creating a GLFW window

Youtube


After studying of this tutorial you can rewrite a prototype of Snake 2D Tutorial: Python Snake Game from deprecated/legacy OpenGL 1 to modern OpenGL 3 and make it 3D with textures and lighting. And you will be able to load 3D models from Blender because the video tutorial above covers loading 3D models from Blender.

How to create an empty window using GLFW:
  • Copy the file below ("main.py")
  • Place glfw3.dll with "main.py"
  • Run the application. For this run the command in the console terminal:

Цитата:
python main.py
main.py

Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import glfw
 
def main():
 
    # Initialize glfw
    if not glfw.init():
        return
 
    window = glfw.create_window(800, 600, "My OpenGL Window", None, None)
 
    if not window:
        glfw.terminate()
        return
 
    glfw.make_context_current(window)
 
    while not glfw.window_should_close(window):
        glfw.poll_events()
        glfw.swap_buffers(window)
 
    glfw.terminate()
 
if __name__ == "__main__":
    main()
Размещено в Без категории
Просмотров 86 Комментарии 0
Всего комментариев 0
Комментарии
 
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Рейтинг@Mail.ru