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