view pytouhou/ui/opengl/renderer.pxd @ 612:73f134f84c7f

Request a RGB888 context, since SDL2’s default of RGB332 sucks. On X11/GLX, it will select the first config available, that is the best one, while on EGL it will iterate over them to select the one closest to what the application requested. Of course, anything lower than RGB888 looks bad and we really don’t want that.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 26 Mar 2015 20:20:37 +0100
parents 6c9d8a3d853f
children a6af3ff86612
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 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
    cdef GLuint 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 render_elements(self, elements) except *
    cdef void render_quads(self, rects, colors, GLuint texture) except *