annotate pytouhou/ui/opengl/backend_glfw.pyx @ 718:c187e0a6b751

ecl_vm: Implement 121 functions 0 and 1.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 24 Sep 2019 17:49:23 +0200
parents 4fa0a8e7d941
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
636
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 ## Copyright (C) 2016 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 ## by the Free Software Foundation; version 3 only.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 ## This program is distributed in the hope that it will be useful,
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 ## GNU General Public License for more details.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ##
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 from .backend cimport profile, major, minor, double_buffer, is_legacy
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 cimport pytouhou.lib.glfw as glfw
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 def create_glfw_window(title, width, height):
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 '''Create a window (using GLFW) and an OpenGL context.'''
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 glfw.init()
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 if profile == 'core':
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 glfw.window_hint(glfw.CLIENT_API, glfw.OPENGL_API)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 elif profile == 'es':
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 glfw.window_hint(glfw.CLIENT_API, glfw.OPENGL_ES_API)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, major)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, minor)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 glfw.window_hint(glfw.ALPHA_BITS, 0)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 glfw.window_hint(glfw.DEPTH_BITS, 24 if is_legacy else 0)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 if double_buffer >= 0:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 glfw.window_hint(glfw.DOUBLEBUFFER, double_buffer)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 # Legacy contexts don’t support our required extensions for scaling.
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 if not is_legacy:
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 glfw.window_hint(glfw.RESIZABLE, True)
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40
4fa0a8e7d941 Add a GLFW implementation of gui.Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 return glfw.Window(width, height, title)