comparison pytouhou/ui/opengl/renderer.pxd @ 586:4b0593da29d5

Simplify framebuffer rendering with glDrawArrays, and move it all to its own file.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 08 Oct 2014 16:34:24 +0200
parents c759b97f4f81
children 6c9d8a3d853f
comparison
equal deleted inserted replaced
585:e0166cda75d5 586:4b0593da29d5
1 from cpython cimport PyObject 1 from cpython cimport PyObject
2 from pytouhou.lib.opengl cimport GLuint 2 from pytouhou.lib.opengl cimport GLuint
3 from .texture cimport TextureManager, FontManager 3 from .texture cimport TextureManager, FontManager
4 from .framebuffer cimport Framebuffer
4 5
5 cdef struct Vertex: 6 cdef struct Vertex:
6 short x, y, z, padding 7 short x, y, z, padding
7 float u, v 8 float u, v
8 unsigned char r, g, b, a 9 unsigned char r, g, b, a
9
10
11 cdef struct PassthroughVertex:
12 short x, y
13 float u, v
14 10
15 11
16 cdef class Texture: 12 cdef class Texture:
17 cdef long key 13 cdef long key
18 cdef GLuint texture 14 cdef GLuint texture
28 cdef FontManager font_manager 24 cdef FontManager font_manager
29 cdef Vertex vertex_buffer[MAX_ELEMENTS] 25 cdef Vertex vertex_buffer[MAX_ELEMENTS]
30 cdef long x, y, width, height 26 cdef long x, y, width, height
31 27
32 # For modern GL. 28 # For modern GL.
33 cdef GLuint vbo, framebuffer_vbo, framebuffer_ibo 29 cdef GLuint vbo
34 cdef GLuint vao, framebuffer_vao 30 cdef GLuint vao
35 31
36 cdef GLuint textures[MAX_TEXTURES] 32 cdef GLuint textures[MAX_TEXTURES]
37 cdef unsigned short *indices[MAX_TEXTURES][2] 33 cdef unsigned short *indices[MAX_TEXTURES][2]
38 cdef unsigned short last_indices[2 * MAX_TEXTURES] 34 cdef unsigned short last_indices[2 * MAX_TEXTURES]
39 cdef PyObject *elements[640*3] 35 cdef PyObject *elements[640*3]
40 36
41 cdef void set_state(self) nogil 37 cdef void set_state(self) nogil
42 cdef void render_elements(self, elements) except * 38 cdef void render_elements(self, elements) except *
43 cdef void render_quads(self, rects, colors, GLuint texture) except * 39 cdef void render_quads(self, rects, colors, GLuint texture) except *
44
45 cdef void set_framebuffer_state(self) nogil
46 cdef void render_framebuffer(self, Framebuffer fb) except * 40 cdef void render_framebuffer(self, Framebuffer fb) except *
47
48
49 cdef class Framebuffer:
50 cdef GLuint fbo, texture, rbo
51 cdef int x, y, width, height
52
53 cpdef bind(self)