Re: Could I use cairo with opengles in android?
Jihe Wei <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAJPDu6xs7C2mR5e0Z6mvL7nm678OQ22G2psZF2AR7C5YzRvncA@mail.gmail.com> |
Hi,Henry i found the implementation of the method cairo_egl_device_create(display, context) is very strange,as below: 1. init attribs with EGL_WIDTH=1and EGL_HEIGHT=1 2. init config use eglChooseConfig method 3. create EGLSurface use eglCreatePbufferSurface method 4. then use eglMakeCurrent to release 5. last, return as &ctx->base.base problems: 1.EGLSurface's width and height both were set to 1 but the method cairo_gl_surface_create supply two parameters for setting width and height another thing, the code i send before should set EGL_SURFACE_TYPE=EGL_PUBUFFER_BIT not EGL_SURFACE_TYPE=EGL_WINDOW_BIT but still nothing display in my phone. 2012/5/18 Jihe Wei <[email protected]> > Henry, > I try swap buffer before draw and also after, both not work. > notice:my display surface is created by > cairo_image_surface_create_for_data, and the data comes from androidbitmap > > Thanks, > Wei > > > 2012/5/18 Henry (Yu) Song - SISA <[email protected]> > > Hi, Jihe >> >> Since you have the gl surface as a window surface, you can swap buffer on >> the surface directly - cairo_gl_surface_swapbuffers (surface). >> >> Henry >> ________________________________________ >> From: [email protected][cairo-bounces+henry.song= >> [email protected]] on behalf of Jihe Wei [[email protected]] >> Sent: Friday, May 18, 2012 2:54 AM >> To: [email protected] >> Subject: [cairo] Could I use cairo with opengles in android? >> >> Hi , >> I wonder where can find some samples show use cairo in android device. >> rarely found ,so i try it myself, but seems can't render anything >> details as below, >> cairo_surface_t *surface = NULL; >> const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, >> EGL_BLUE_SIZE, >> 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_RENDERABLE_TYPE, >> EGL_OPENGL_ES2_BIT, EGL_NONE }; >> const EGLint ctx_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE >> }; >> >> EGLint format; >> EGLint numConfigs; >> EGLConfig config; >> EGLContext context; >> EGLint err; >> >> EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); >> err = eglGetError(); >> LOGE("eglGetDisplay err:%d", err);//return 12288 >> >> eglInitialize(display, 0, 0); >> err = eglGetError(); >> LOGE("eglInitialize err:%d", err);//return 12288 >> >> eglChooseConfig(display, attribs, &config, 1, &numConfigs); >> err = eglGetError(); >> LOGE("eglChooseConfig err:%d", err); >> >> eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); >> >> context = eglCreateContext(display, config, EGL_NO_CONTEXT, >> ctx_attribs); >> err = eglGetError(); >> LOGE("eglCreateContext err:%d", err);//return 12288 >> >> cairo_device_t * device = cairo_egl_device_create(display, context); >> cairo_status_t status = cairo_device_status(device);//return success >> >> surface = cairo_gl_surface_create(device, CAIRO_CONTENT_ALPHA, >> info->width, >> info->height);//return CAIRO_SURFACE_TYPE_GL type >> >> I use another surface to display the result from surface(gl) >> cairo_set_operator(cr_display, CAIRO_OPERATOR_ADD); >> cairo_set_source_surface(cr_display, surface, 0, 0); >> cairo_paint(cr_display); >> >> Who could help to figure out? thx >> > > -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo