Henry,<br>I try swap buffer before draw and also after, both not work.<br>notice:my display surface is created by cairo_image_surface_create_for_data, and the data comes from androidbitmap<br><br>Thanks,<br>Wei<br><br><br>
<div class="gmail_quote">2012/5/18 Henry (Yu) Song - SISA <span dir="ltr"><<a href="mailto:hsong@sisa.samsung.com" target="_blank">hsong@sisa.samsung.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, Jihe<br>
<br>
Since you have the gl surface as a window surface, you can swap buffer on the surface directly - cairo_gl_surface_swapbuffers (surface).<br>
<br>
Henry<br>
________________________________________<br>
From: cairo-bounces+henry.song=<a href="mailto:samsung.com@cairographics.org">samsung.com@cairographics.org</a> [cairo-bounces+henry.song=<a href="mailto:samsung.com@cairographics.org">samsung.com@cairographics.org</a>] on behalf of Jihe Wei [<a href="mailto:jihe.wei@gmail.com">jihe.wei@gmail.com</a>]<br>
Sent: Friday, May 18, 2012 2:54 AM<br>
To: <a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
Subject: [cairo] Could I use cairo with opengles in android?<br>
<div class="HOEnZb"><div class="h5"><br>
Hi ,<br>
I wonder where can find some samples show use cairo in android device.<br>
rarely found ,so i try it myself, but seems can't render anything<br>
details as below,<br>
cairo_surface_t *surface = NULL;<br>
const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE,<br>
8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_RENDERABLE_TYPE,<br>
EGL_OPENGL_ES2_BIT, EGL_NONE };<br>
const EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };<br>
<br>
EGLint format;<br>
EGLint numConfigs;<br>
EGLConfig config;<br>
EGLContext context;<br>
EGLint err;<br>
<br>
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);<br>
err = eglGetError();<br>
LOGE("eglGetDisplay err:%d", err);//return 12288<br>
<br>
eglInitialize(display, 0, 0);<br>
err = eglGetError();<br>
LOGE("eglInitialize err:%d", err);//return 12288<br>
<br>
eglChooseConfig(display, attribs, &config, 1, &numConfigs);<br>
err = eglGetError();<br>
LOGE("eglChooseConfig err:%d", err);<br>
<br>
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);<br>
<br>
context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attribs);<br>
err = eglGetError();<br>
LOGE("eglCreateContext err:%d", err);//return 12288<br>
<br>
cairo_device_t * device = cairo_egl_device_create(display, context);<br>
cairo_status_t status = cairo_device_status(device);//return success<br>
<br>
surface = cairo_gl_surface_create(device, CAIRO_CONTENT_ALPHA, info->width,<br>
info->height);//return CAIRO_SURFACE_TYPE_GL type<br>
<br>
I use another surface to display the result from surface(gl)<br>
cairo_set_operator(cr_display, CAIRO_OPERATOR_ADD);<br>
cairo_set_source_surface(cr_display, surface, 0, 0);<br>
cairo_paint(cr_display);<br>
<br>
Who could help to figure out? thx<br>
</div></div></blockquote></div><br>