Skip to content

Commit bcdf5d2

Browse files
committed
Display SDL2 library version
1 parent 926e60e commit bcdf5d2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

demosys/context/sdl2/window.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sdl2
99
import sdl2.ext
1010
import sdl2.video
11+
from sdl2 import version
1112

1213

1314
class Window(BaseWindow):
@@ -28,6 +29,8 @@ def __init__(self):
2829
self.tmp_size_x = c_int()
2930
self.tmp_size_y = c_int()
3031

32+
print("Using sdl2 library version:", self.get_library_version())
33+
3134
if sdl2.SDL_Init(sdl2.SDL_INIT_VIDEO) != 0:
3235
raise ValueError("Failed to initialize sdl2")
3336

@@ -44,7 +47,7 @@ def __init__(self):
4447

4548
flags = sdl2.SDL_WINDOW_OPENGL
4649
if self.fullscreen:
47-
flags |= sdl2.SDL_WINDOW_FULLSCREEN
50+
flags |= sdl2.SDL_WINDOW_FULLSCREEN_DESKTOP
4851
else:
4952
if self.resizable:
5053
flags |= sdl2.SDL_WINDOW_RESIZABLE
@@ -62,8 +65,7 @@ def __init__(self):
6265
raise ValueError("Failed to create window:", sdl2.SDL_GetError())
6366

6467
self.context = sdl2.SDL_GL_CreateContext(self.window)
65-
if self.vsync:
66-
sdl2.video.SDL_GL_SetSwapInterval(1)
68+
sdl2.video.SDL_GL_SetSwapInterval(1 if self.vsync else 0)
6769

6870
self.ctx = moderngl.create_context(require=self.gl_version.code)
6971
context.WINDOW = self
@@ -119,3 +121,8 @@ def terminate(self):
119121
sdl2.SDL_GL_DeleteContext(self.context)
120122
sdl2.SDL_DestroyWindow(self.window)
121123
sdl2.SDL_Quit()
124+
125+
def get_library_version(self):
126+
v = version.SDL_version()
127+
sdl2.SDL_GetVersion(v)
128+
return v.major, v.minor, v.patch

0 commit comments

Comments
 (0)