annotate pytouhou/ui/opengl/renderer.pxd @ 760:eba9a3d0c484

formats: Fix the tests.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 05 Jan 2021 04:28:45 +0100
parents ec972eb44391
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
449
d56536ef28e8 Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
1 from cpython cimport PyObject
462
a71b912b45b7 Render to framebuffers first, and reposition some interface elements in the game area.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 458
diff changeset
2 from pytouhou.lib.opengl cimport GLuint
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
3 from .texture cimport TextureManager, FontManager
586
4b0593da29d5 Simplify framebuffer rendering with glDrawArrays, and move it all to its own file.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 560
diff changeset
4 from .framebuffer cimport Framebuffer
449
d56536ef28e8 Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
5
222
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
6 cdef struct Vertex:
518
75ae628522c9 Use shorts instead of ints for vertex position, reducing the size of a vertex to 20 bytes from 24.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 515
diff changeset
7 short x, y, z, padding
222
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
8 float u, v
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
9 unsigned char r, g, b, a
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
10
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
11
627
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
12 cdef struct TextVertex:
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
13 short x, y
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
14 float u, v
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
15 unsigned char r, g, b, a
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
16
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
17
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
18 cdef class Texture:
515
b3193b43a86c Add an indirection layer for textures, to cope with drivers assigning them random names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
19 cdef long key
540
53fa73932e9a Fix warnings introduced in Cython 0.20, when more than one pointer is defined on the same line.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 537
diff changeset
20 cdef GLuint texture
53fa73932e9a Fix warnings introduced in Cython 0.20, when more than one pointer is defined on the same line.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 537
diff changeset
21 cdef GLuint *pointer
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
22 cdef unsigned short indices[2][65536]
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
23
537
63440d1e0717 Fix a segfault happening at exit time on Windows.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 520
diff changeset
24 #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid.
63440d1e0717 Fix a segfault happening at exit time on Windows.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 520
diff changeset
25 cdef Renderer renderer
63440d1e0717 Fix a segfault happening at exit time on Windows.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 520
diff changeset
26
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
27
222
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
28 cdef class Renderer:
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
29 cdef TextureManager texture_manager
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
30 cdef FontManager font_manager
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
31 cdef Vertex vertex_buffer[MAX_ELEMENTS]
503
c622eaf64428 Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 468
diff changeset
32 cdef long x, y, width, height
222
5cac48b328ad Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
33
520
c0b3f8709f74 Store the indices of the framebuffer in a static ibo.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 518
diff changeset
34 # For modern GL.
627
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
35 cdef GLuint vbo, text_vbo
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
36 cdef GLuint vao, text_vao
520
c0b3f8709f74 Store the indices of the framebuffer in a static ibo.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 518
diff changeset
37
515
b3193b43a86c Add an indirection layer for textures, to cope with drivers assigning them random names.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
38 cdef GLuint textures[MAX_TEXTURES]
505
bfea9e9a6845 Manage the texture-specific indices in the Texture, and some more renderer optimisations.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 503
diff changeset
39 cdef unsigned short *indices[MAX_TEXTURES][2]
449
d56536ef28e8 Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
40 cdef unsigned short last_indices[2 * MAX_TEXTURES]
d56536ef28e8 Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
41 cdef PyObject *elements[640*3]
d56536ef28e8 Improve render_elements’ speed a lot, and fix it in some corner cases. Thanks liori!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 423
diff changeset
42
558
94725968dabb Use vertex array objects, to be compatible with OpenGL 3.1+ core profile.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 540
diff changeset
43 cdef void set_state(self) nogil
627
ec972eb44391 Use a specific vbo/vao pair for text rendering.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 617
diff changeset
44 cdef void set_text_state(self) nogil
617
a6af3ff86612 Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
45 cdef bint render_elements(self, elements) except True
a6af3ff86612 Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
46 cdef bint render_quads(self, rects, colors, GLuint texture) except True