54 lines
No EOL
1.5 KiB
Python
54 lines
No EOL
1.5 KiB
Python
import pyglet
|
|
from . import config
|
|
|
|
def auto_res(res: list) -> list:
|
|
return res
|
|
|
|
def get_config() -> dict:
|
|
return config.init
|
|
|
|
|
|
|
|
def get_best_config(self):
|
|
configs = None
|
|
try_configs = [pyggl.Config(double_buffer=True, depth_size=24, major_version=3, minor_version=3),
|
|
gl.Config(double_buffer=True, depth_size=16, major_version=3, minor_version=3),
|
|
None]
|
|
for tryc in try_configs:
|
|
try:
|
|
configs = (tryc)
|
|
break
|
|
except window.NoSuchConfigException:
|
|
pass
|
|
if not configs:
|
|
raise window.NoSuchConfigException()
|
|
return configs[0]
|
|
|
|
|
|
|
|
|
|
def init_window() -> None:
|
|
global window
|
|
|
|
cfg = get_config()
|
|
res = [cfg.get('width'), cfg.get('height')]
|
|
fs = cfg.get('fullscreen')
|
|
borderless_fullscreen = cfg.get('borderless_fullscreen')
|
|
borderless_window = cfg.get('borderless_window')
|
|
scaling = cfg.get('scaling')
|
|
vsync = cfg.get('vsync')
|
|
|
|
if fs and not borderless_fullscreen:
|
|
# real fullscreen mode is requested
|
|
# that means we need to carefully select
|
|
# an available resolution
|
|
pass
|
|
|
|
display = pyglet.display.get_display()
|
|
screens = display.get_screens()
|
|
windows = []
|
|
# for screen in screens:
|
|
# print(f"creating window on screen {screen}")
|
|
# windows.append(pyglet.window.Window(fullscreen=True, screen=screen))
|
|
window = pyglet.window.Window(fullscreen=fs, screen=screens[0])
|
|
cfg.save() |