일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Arduino #PlatformIO #macOS
- centos7 #yum update #/boot
- Callaway #Mavrik #Epic Flash
- ITOP40
- 다이슨 #배터리
- CM-EF-NEX
- cycloidal #rv reducer
- TensorFlow #Python #pip
- 매크로렌즈 #리버스링
- VMware #Shared Folder
- Oh My Zsh #macOS
- Arduino #Wall Plotter
- razer #deathadder #viper #g102
- fat32 #rufus
- Laptop #CPUID
- Tarantula #3D 프린터
- VirtualBox #VMware
- egpu #aorus gaming box #gtx1070 #tb3
- Linux #VirtualBox
- Xeon #E5-2680
- k6 #피코프레소
- macro lens #EF #FD
- ESP32 #Arduino
- Java #MacBook #macOS
- Dell #Latitude #BIOS
- 피코프레소 #ITOP40
- XTU #Virtual Machine System
- Octave #homebrew #macOS
- x99 itx/ac
- VNC #Firewall #CenOS7 #VMware
- Today
- Total
얕고 넓게
[OpenGL] PyOpenGL @Python 3.10 본문
0. Ref
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=samsjang&logNo=220708189400
파이썬으로 OpenGL 활용하기1 - 준비하기
OpenGL은 컴퓨터 프로그래밍을 위한 가장 광범위하게 사용되고 있는 2D, 3D 그래픽 라이브러리입니다....
blog.naver.com
1. PyOpenGL, PyOpenGL_accelerate 설치
c:\ pip install PyOpenGL
c:\ pip install PyOpenGL_accelerate
2. 코딩
import pygame -> error
c:\ pip install pygame
3. PyOpenGL_accelerate 재설치
Installing collected packages: PyOpenGL-accelerate Running setup.py install for PyOpenGL-accelerate ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\black\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-ib3rfxqr\\pyopengl-accelerate_7718c6c5e5584173a1c62b12e0f0e042\\setup.py'"'"'; __file__='"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-ib3rfxqr\\pyopengl-accelerate_7718c6c5e5584173a1c62b12e0f0e042\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\black\AppData\Local\Temp\pip-record-2oh6luuq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\black\AppData\Local\Programs\Python\Python310\Include\PyOpenGL-accelerate' cwd: C:\Users\black\AppData\Local\Temp\pip-install-ib3rfxqr\pyopengl-accelerate_7718c6c5e5584173a1c62b12e0f0e042\ Complete output (11 lines): Unable to import numpy, skipping numpy extension building running install running build running build_py creating build creating build\lib.win-amd64-3.10 creating build\lib.win-amd64-3.10\OpenGL_accelerate copying OpenGL_accelerate\__init__.py -> build\lib.win-amd64-3.10\OpenGL_accelerate running build_ext building 'OpenGL_accelerate.wrapper' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'C:\Users\black\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-ib3rfxqr\\pyopengl-accelerate_7718c6c5e5584173a1c62b12e0f0e042\\setup.py'"'"'; __file__='"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-ib3rfxqr\\pyopengl-accelerate_7718c6c5e5584173a1c62b12e0f0e042\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\black\AppData\Local\Temp\pip-record-2oh6luuq\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\black\AppData\Local\Programs\Python\Python310\Include\PyOpenGL-accelerate' Check the logs for full command output.
numpy, wheel 설치
c:\ pip install numpy
c:\ pip install wheel
"Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools
https://visualstudio.microsoft.com/ko/downloads/
Visual Studio Tools 다운로드 - Windows, Mac, Linux용 무료 설치
Visual Studio IDE 또는 VS Code를 무료로 다운로드하세요. Windows 또는 Mac에서 Visual Studio Professional 또는 Enterprise Edition을 사용해 보세요.
visualstudio.microsoft.com
https://aka.ms/vs/17/release/vs_BuildTools.exe
4. PyOpenGL_accelerate 재설치
Collecting PyOpenGL_accelerate Using cached PyOpenGL-accelerate-3.1.5.tar.gz (538 kB) Building wheels for collected packages: PyOpenGL-accelerate Building wheel for PyOpenGL-accelerate (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\black\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-y7smyzdu\\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642\\setup.py'"'"'; __file__='"'"'C:\\Users\\black\\AppData\\Local\\Temp\\pip-install-y7smyzdu\\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\black\AppData\Local\Temp\pip-wheel-97ju005s' cwd: C:\Users\black\AppData\Local\Temp\pip-install-y7smyzdu\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642\ Complete output (59 lines): running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.10 creating build\lib.win-amd64-3.10\OpenGL_accelerate copying OpenGL_accelerate\__init__.py -> build\lib.win-amd64-3.10\OpenGL_accelerate running build_ext building 'OpenGL_accelerate.wrapper' extension creating build\temp.win-amd64-3.10 creating build\temp.win-amd64-3.10\Release creating build\temp.win-amd64-3.10\Release\src C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\black\AppData\Local\Temp\pip-install-y7smyzdu\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642\.. -IC:\Users\black\AppData\Local\Temp\pip-install-y7smyzdu\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642\src -IC:\Users\black\AppData\Local\Temp\pip-install-y7smyzdu\pyopengl-accelerate_6457d76b8d424d27a172c5afaf632642 -IC:\Users\black\AppData\Local\Programs\Python\Python310\include -IC:\Users\black\AppData\Local\Programs\Python\Python310\Include -IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt -IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt /Tcsrc\wrapper.c /Fobuild\temp.win-amd64-3.10\Release\src\wrapper.obj wrapper.c src\wrapper.c(6903): warning C4244: '=': 'Py_ssize_t'?? 'int'(?)? ????? ???? ??? ? ????. src\wrapper.c(7665): warning C4244: '=': 'Py_ssize_t'?? 'int'(?)? ????? ???? ??? ? ????. src\wrapper.c(25804): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 src\wrapper.c(25820): warning C4996: '_PyUnicode_get_wstr_length': deprecated in 3.3 C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO ...
pyarrow 설치
PyOpenGL_accelerate 재설치 -> 실패
5. PyOpenGL*.whl 다운로드 후 설치
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl
Python Extension Packages for Windows - Christoph Gohlke
by Christoph Gohlke, Laboratory for Fluorescence Dynamics, University of California, Irvine. Updated on 29 January 2022 at 21:28 UTC. This page provides 32 and 64-bit Windows binaries of many scientific open-source extension packages for the official CPyth
www.lfd.uci.edu
c:\ pip install PyOpenGL_accelerate-3.1.5-cp310-cp310-win_amd64.whl
성공!!!
6. 코드
__author__ = 'samsjang@naver.com'
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
colors = ((1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(0, 1, 0))
surfaces = ((0, 1, 2, 3),
(3, 2, 7, 6),
(6, 7, 5, 4),
(4, 5, 1, 0),
(1, 5, 7, 2),
(4, 0, 3, 6))
vertices = ((1, -1, -1),
( 1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
( 1, -1, 1),
( 1, 1, 1),
(-1, -1, 1),
(-1, 1, 1))
edges = ((0, 1), (0, 3), (0, 4),
(2, 1), (2, 3), (2, 7),
(6, 3), (6, 4), (6, 7),
(5, 1), (5, 4), (5, 7))
def drawCube():
glBegin(GL_QUADS)
for surface in surfaces:
x = 0
for vertex in surface:
glColor3fv(colors[x])
glVertex3fv(vertices[vertex])
x += 1
glEnd()
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(vertices[vertex])
glEnd()
def myOpenGL():
pygame.init()
display = (800,600)
pygame.display.set_mode(display, DOUBLEBUF | OPENGL)
gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
glTranslatef(0.0, 0.0, -7)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
glRotate(1, 3, 0, 0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
drawCube()
pygame.display.flip()
pygame.time.wait(10)
myOpenGL()