Mercurial > touhou
view pytouhou/ui/opengl/renderer.pxd @ 772:7492d384d122 default tip
Rust: Add a Glide renderer (2D only for now)
This is an experiment for a Rust renderer, iterating over the Python data using
pyo3. It requires --feature=glide to be passed to cargo build, doesn’t support
NPOT textures, text rendering, the background, or even msg faces, some of that
may come in a future changeset.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 05 Sep 2022 17:53:36 +0200 |
parents | ec972eb44391 |
children |
line wrap: on
line source
from cpython cimport PyObject from pytouhou.lib.opengl cimport GLuint from .texture cimport TextureManager, FontManager from .framebuffer cimport Framebuffer cdef struct Vertex: short x, y, z, padding float u, v unsigned char r, g, b, a cdef struct TextVertex: short x, y float u, v unsigned char r, g, b, a cdef class Texture: cdef long key cdef GLuint texture cdef GLuint *pointer cdef unsigned short indices[2][65536] #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid. cdef Renderer renderer cdef class Renderer: cdef TextureManager texture_manager cdef FontManager font_manager cdef Vertex vertex_buffer[MAX_ELEMENTS] cdef long x, y, width, height # For modern GL. cdef GLuint vbo, text_vbo cdef GLuint vao, text_vao cdef GLuint textures[MAX_TEXTURES] cdef unsigned short *indices[MAX_TEXTURES][2] cdef unsigned short last_indices[2 * MAX_TEXTURES] cdef PyObject *elements[640*3] cdef void set_state(self) nogil cdef void set_text_state(self) nogil cdef bint render_elements(self, elements) except True cdef bint render_quads(self, rects, colors, GLuint texture) except True