[cairo] Cairo with OpenGL
Maximilian Ernestus
erniejunior at googlemail.com
Thu Dec 31 06:58:44 PST 2009
> Yes, you want to use an image surface.
I use a mac and installed cairo via MacPorts. I don't have the "cairo-
surface.c" file. I get the following error during runtime (Debugging
mode because Release mode gets linking errors that i don't know how to
get rid of):
Xcode could not locate source file: cairo-surface.c (line: 383)
How do i get this "cairo-surface.c" file? The only variants of the
cairo port are:
universal: Build for multiple architectures
glitz: Add glitz graphics interface
macosx: Platform variant, do not select manually
quartz: Add Quartz graphics interface
no_x11: Disable support for X11
x11_xcb: Use libxcb for X11 protocol communication
I have "cairo @1.8.6_4+macosx+quartz" installed. Do i have to build
cairo manualy?
Greetings,
Maximilian
> Uploading to an OpenGL texture
> is no different than uploading any other texture. Assuming you have an
> ARGB32 surface:
>
> void *bits = cairo_image_surface_get_data(cairo_get_target(cr));
>
> cairo_surface_flush(cairo_get_target(cr));
> glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureId);
> glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, 0,
> GL_BGRA, GL_UNSIGNED_BYTE, bits);
>
> Of course, if you are targeting OpenGL 2.1+ or have power-of-two
> textures then you do not need to use GL_TEXTURE_RECTANGLE_ARB :)
>
> Performance is satisfactory, so long as you do not redraw the surface
> every frame (caching is important).
>
> Regards, Freddie.
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
More information about the cairo
mailing list