[cairo] PyCairo + OpenGL = Segmentation Fault? I need a hand

Clemens Nylandsted Klokmose clemensklokmose at gmail.com
Tue Oct 2 01:43:31 PDT 2007


Hi,I have for some time now tried to generate a texture through cairo and
plaster onto an OpenGL surface via python, but I think I am missing some
memory subtlety.


I define a surface like this:
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1024, 1024)
ctx = cairo.Context(surface)
//I do some drawing//
surface.finish()


Then some OpenGL texture setup:


glBindTexture(GL_TEXTURE_2D, 1)
glPixelStorei(GL_UNPACK_ALIGNMENT,1)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)


And now the call that leads to a segmentation fault:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, int( surface.get_width()), int(
surface.get_height()), 0, GL_BGRA, GL_UNSIGNED_BYTE, surface.get_data())


Is there any of you who have had luck using PyCairo with OpenGL and can see
what I do wrong?


Thanks,
Clemens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20071002/dd68603a/attachment.htm 


More information about the cairo mailing list