(This method should work for SVG too but Im not sure how to use
'create_for_data' along with an svg surface - you can probably just
draw the svg surface to the other surface )
# do the following once at init...
data = (ctypes.c_ubyte * w * h * 4)()
stride = w * 4
surface = cairo.ImageSurface.create_for_data (data, cairo.FORMAT_ARGB32,
w, h, stride);
texture = pyglet.image.Texture.create_for_size(GL_TEXTURE_2D, w, h, GL_RGBA)
# when drawing....
glEnable(GL_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, texture.id)
if needs_redraw:
ctx = cairo.Context(surface)
# .... do you cairo draw/svg calls here ....
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA,
GL_UNSIGNED_BYTE,
data)
# ... draw a quad here
Looks much nicer indeed! That's precisely the sort of thing it'd be good to
have in the pyglet-users web space.
Hey, it looks like the web pages are back!
Could you please add something?
Thanks,
Richard
ill write up a simple example when i get time unless someone beats me to it
> glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA,
> GL_UNSIGNED_BYTE,
> data)
glTexSubImage2D (equivalently, pyglet.image.Texture.blit_into) is much
more efficient than glTexImage2D for updating a texture (it is how
video frames are rendered, for example).
Alex.