Reputation: 14603
I make a GL
context with freeglut
like this:
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_STENCIL);
and a draw with cairo
like this:
if (!device_)
{
device_ = cairo_glx_device_create(glXGetCurrentDisplay(),
glXGetCurrentContext());
}
// else do nothing
auto const surface(cairo_gl_surface_create_for_window(device_,
glXGetCurrentDrawable(), width, height));
auto const cr(cairo_create(surface));
// draw using cairo calls
cairo_destroy(cr);
cairo_gl_surface_swapbuffers(surface); // !!!
cairo_surface_destroy(surface);
If I don't call cairo_gl_surface_swapbuffers()
, but call glutSwapBuffers()
, nothing shows, but there is an error:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 156 (GLX)
Minor opcode of failed request: 11 (X_GLXSwapBuffers)
Serial number of failed request: 69
Current serial number in output stream: 72
But, if I call cairo_gl_surface_swapbuffers()
, but don't call glutSwapBuffers()
, the drawing will show and there will be no error. How can I call glutSwapBuffers()
, not cairo_gl_surface_swapbuffers()
and not trigger the error? I'd like to mix other content alongside cairo
content.
Upvotes: 1
Views: 358
Reputation: 9867
The function cairo_gl_surface_swapbuffers
should be equivalent to calling cairo_surface_flush
and afterwards calling the right function for swapping buffers.
So I guess you are looking for cairo_surface_flush(surface)
?
Upvotes: 1