pygame-3dce 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pygame-3dce
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A clean 3D extension for pygame-ce using PyOpenGL
|
|
5
|
+
Author-email: PeaiiYT <kaelwerkAPPLE@outlook.com>
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Requires-Python: >=3.8
|
|
10
|
+
Requires-Dist: pygame-ce
|
|
11
|
+
Requires-Dist: pyopengl
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
\# pygame-3dce
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Just a 3d Extension
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
\## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
|
|
26
|
+
pip install pygame-3dce
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pygame-3dce"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="PeaiiYT", email="kaelwerkAPPLE@outlook.com" },
|
|
10
|
+
]
|
|
11
|
+
description = "A clean 3D extension for pygame-ce using PyOpenGL"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.8"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"pygame-ce",
|
|
16
|
+
"PyOpenGL",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .main import Pygame3D
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import pygame
|
|
2
|
+
from pygame.locals import *
|
|
3
|
+
from OpenGL.GL import *
|
|
4
|
+
from OpenGL.GLU import *
|
|
5
|
+
|
|
6
|
+
class Pygame3D:
|
|
7
|
+
def __init__(self, width=800, height=600, fov=45):
|
|
8
|
+
"""Initializes a pygame-ce window with a 3D OpenGL context."""
|
|
9
|
+
pygame.init()
|
|
10
|
+
self.display = (width, height)
|
|
11
|
+
pygame.display.set_mode(self.display, DOUBLEBUF | OPENGL)
|
|
12
|
+
|
|
13
|
+
glEnable(GL_DEPTH_TEST)
|
|
14
|
+
gluPerspective(fov, (self.display[0] / self.display[1]), 0.1, 100.0)
|
|
15
|
+
glTranslatef(0.0, 0.0, -10.0)
|
|
16
|
+
|
|
17
|
+
def clear(self):
|
|
18
|
+
"""Clears the screen and depth buffers for the next frame."""
|
|
19
|
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
|
20
|
+
|
|
21
|
+
def update(self):
|
|
22
|
+
"""Flips the display buffer to render the new graphics frame."""
|
|
23
|
+
pygame.display.flip()
|
|
24
|
+
|
|
25
|
+
def draw_cube(self, size=1.0):
|
|
26
|
+
"""A built-in helper method to draw a simple 3D wireframe cube."""
|
|
27
|
+
s = size
|
|
28
|
+
vertices = (
|
|
29
|
+
(s, -s, -s), (s, s, -s), (-s, s, -s), (-s, -s, -s),
|
|
30
|
+
(s, -s, s), (s, s, s), (-s, -s, s), (-s, s, s)
|
|
31
|
+
)
|
|
32
|
+
edges = (
|
|
33
|
+
(0,1), (0,3), (0,4), (2,1), (2,3), (2,7),
|
|
34
|
+
(6,3), (6,4), (6,7), (5,1), (5,4), (5,7)
|
|
35
|
+
)
|
|
36
|
+
glBegin(GL_LINES)
|
|
37
|
+
for edge in edges:
|
|
38
|
+
for vertex in edge:
|
|
39
|
+
glVertex3fv(vertices[vertex])
|
|
40
|
+
glEnd()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pygame
|
|
2
|
+
from src.pygame_3dce import Pygame3D
|
|
3
|
+
from OpenGL.GL import glRotatef
|
|
4
|
+
|
|
5
|
+
# Fire up your custom engine extension
|
|
6
|
+
engine = Pygame3D()
|
|
7
|
+
|
|
8
|
+
clock = pygame.time.Clock()
|
|
9
|
+
running = True
|
|
10
|
+
|
|
11
|
+
while running:
|
|
12
|
+
for event in pygame.event.get():
|
|
13
|
+
if event.type == pygame.QUIT:
|
|
14
|
+
running = False
|
|
15
|
+
|
|
16
|
+
# Rotate the 3D space matrix continuously
|
|
17
|
+
glRotatef(1, 1, 1, 0)
|
|
18
|
+
|
|
19
|
+
# Render using your package methods
|
|
20
|
+
engine.clear()
|
|
21
|
+
engine.draw_cube(size=2.0)
|
|
22
|
+
engine.update()
|
|
23
|
+
|
|
24
|
+
clock.tick(60)
|
|
25
|
+
|
|
26
|
+
pygame.quit()
|