-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_3d.py
56 lines (45 loc) · 1.57 KB
/
main_3d.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import ctypes
import os
import sys
from ctypes import ARRAY
from typing import Type
from OpenGL.GL import *
# from OpenGL.GLUT import *
import sdl3
import numpy as np
from src.core.render.window import Window3d
os.environ["SDL_MAIN_USE_CALLBACKS"] = "1"
def main():
context = sdl3.SDL_GL_CreateContext(None)
window_object = Window3d(title=b"Morph in 3D", width=800, height=800, flags=sdl3.SDL_WINDOW_OPENGL)
if sdl3.SDL_InitSubSystem(sdl3.SDL_INIT_VIDEO) < 0:
raise Exception(f"SDL couldn't be initialized! {sdl3.SDL_GetError()}")
open_gl_context = sdl3.SDL_GL_CreateContext(window_object.window)
if open_gl_context is None:
print(sdl3.SDL_GetError())
sdl3.SDL_GL_SwapWindow(window_object.window) # Update screen
glClearColor(1.0, 0.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
sdl3.SDL_GL_SwapWindow(window_object.window)
sdl3.SDL_Delay(2000)
glClearColor(0.0, 1.0, 0.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
sdl3.SDL_GL_SwapWindow(window_object.window)
sdl3.SDL_Delay(2000)
glClearColor(0.0, 0.0, 1.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
sdl3.SDL_GL_SwapWindow(window_object.window)
sdl3.SDL_Delay(2000)
exit_loop = False
Input(exit_loop)
sdl3.SDL_GL_DeleteContext(context)
sdl3.SDL_DestroyWindow(window_object)
sdl3.SDL_Quit()
def Input(exitloop):
event = sdl3.SDL_Event()
while not exitloop:
while sdl3.SDL_PollEvent(ctypes.byref(event)):
if event.type == sdl3.SDL_EVENT_QUIT:
exitloop = True
if __name__ == "__main__":
raise SystemExit(main())