[cairo] Problem with Cairo with openglesv2 backend

Ali Sarlak ali.sarlak at aol.com
Fri Apr 10 05:41:05 PDT 2015


Dear Developers

  
 I tried to use Cairo with EGL and OpenGLESv2 backend after compilation the Cairo and writing an application with Cairo I can't see anything on screen just display back light turned on and after few second turned off again.
 
 may be my configuration and my program can help to solve my issue.
 
 my configuration is :
 
  ./configure --prefix=/home/super/Desktop/ROOTFS/MY_ROOTFS/usr --host=${CROSS_COMPILE} CFLAGS="-I/home/super/Desktop/ROOTFS/MY_ROOTFS/usr/include/ -DLINUX -DEGL_API_FB" LIBS="-L/home/super/Desktop/ROOTFS/MY_ROOTFS/usr/lib/ -lz" --enable-xlib=no --enable-egl --enable-glesv2
 
 With above configuration Cairo compiled correctly.
 
 My program is :
 
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 //============================================================================
 // Name        : test_app.cpp
 // Author      : Ali Sarlak
 // Version     :
 // Copyright   : GPL
 // Description : EGL+Cairo GLIB
 //============================================================================
 
 #include <iostream>
 #include <stdio.h>
 #include <cairo.h>
 #include <egl.h>
 #include <EGL/eglext.h>
 #include <eglplatform.h>
 #include <cairo-gl.h>
 #include <stdlib.h>
 
 using namespace std;
 
 int main()
 {
     EGLContext eglContext;
     EGLSurface eglSurface;
     EGLBoolean resultB;
 
     /* Get a display handle and initalize EGL */
     EGLint major, minor;
     EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
 
     printf("egldisplay = %x\n", eglGetError());
 
     resultB = eglInitialize(display, &major, &minor);
 
     printf("eglInitialize = %d\n<Major(%d),Minor(%d)>\n", resultB, major,
             minor);
 
      EGLint attributes[] =
     {
     EGL_RENDERABLE_TYPE,
     EGL_OPENGL_ES2_BIT,
     EGL_RED_SIZE, 8,
     EGL_GREEN_SIZE, 8,
     EGL_BLUE_SIZE, 8,
     EGL_DEPTH_SIZE, 1,
     EGL_NONE };
 
     EGLint numberConfigs = 0;
     EGLConfig* matchingConfigs=NULL;
 
    if (EGL_FALSE
             == eglChooseConfig(display, attributes, NULL, 0, &numberConfigs))
     {
         printf("eglChooseConfig EROR\n");
     }
     if (numberConfigs == 0)
     {
         printf("eglChooseConfig EROR\n");
     }
 
     printf("numberConfigs = %d\n", numberConfigs);
     /* Allocate some space to store list of matching configs... */
     matchingConfigs = (EGLConfig*) malloc(numberConfigs * sizeof(EGLConfig));
     /* ...and this time actually get the list (notice the 3rd argument is
      * now the buffer to write matching EGLConfig's to)
      */
 
     if (EGL_FALSE
             == eglChooseConfig(display, attributes, matchingConfigs,
                     numberConfigs, &numberConfigs))
     {
         printf("eglChooseConfig EROR\n");
     }
 
     printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
 
     EGLint attribList[] =
     {
     EGL_WIDTH, 600,
     EGL_HEIGHT, 600,
     EGL_LARGEST_PBUFFER, EGL_TRUE,
     EGL_NONE };
 
     eglSurface = eglCreatePbufferSurface(display, matchingConfigs[0],
             attribList);
     if (eglSurface == EGL_NO_SURFACE)
     {
         printf("eglSurface = %x\n", eglGetError());
     }
 
     const EGLint attribListCtx[] =
     {
     // EGL_KHR_create_context is required
             EGL_CONTEXT_CLIENT_VERSION, 2,
             EGL_NONE };
 
     eglContext = eglCreateContext(display, matchingConfigs[0], EGL_NO_CONTEXT,
             attribListCtx);
 
     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     if (eglContext == EGL_NO_CONTEXT)
     {
         printf("eglContext = %x\n", eglGetError());
     }
 
     cairo_device_t* cdt = cairo_egl_device_create(display, eglContext);
 
     printf("cdt = %x\n", eglGetError());
 
     eglMakeCurrent(display, eglSurface, eglSurface, eglContext);
 
     cairo_surface_t *surface = cairo_gl_surface_create_for_egl(cdt, eglSurface,
             600, 600);
 
 //    EGL_SUCCESS
     printf("surface = %x\n", eglGetError());
 
     cairo_t *cr = cairo_create(surface);
 
     //******************************************************************************************************************
     cairo_set_source_rgb (cr, 0, 0, 0);
 
     cairo_move_to (cr, 0, 0);
     cairo_line_to (cr, 200, 200);
     cairo_move_to (cr, 200, 0);
     cairo_line_to (cr, 0, 200);
     cairo_set_line_width (cr, 1);
     cairo_stroke (cr);
 
     cairo_rectangle (cr, 0, 0, 100,100);
     cairo_set_source_rgba (cr, 1, 0, 0, 0.8);
     cairo_fill (cr);
 
     cairo_rectangle (cr, 0, 100, 100, 100);
     cairo_set_source_rgba (cr, 0, 1, 0, 0.60);
     cairo_fill (cr);
 
     cairo_rectangle (cr, 100, 0, 100, 100);
     cairo_set_source_rgba (cr, 0, 0, 1, 0.40);
     cairo_fill (cr);
 
     cairo_rectangle (cr, 100, 100, 100, 100);
     cairo_set_source_rgba (cr, 1, 1, 0, 0.20);
     cairo_fill (cr);
     //******************************************************************************************************************
 
 //    cairo_surface_flush(surface);
 
 //    if (eglWaitClient() == EGL_TRUE)
 //    {
 //        printf("EGL GET FINISHED!\n");
 //    }
 
     //to check that cairo can make the photo from the surface it's OK and png created
     cairo_status_t s = cairo_surface_write_to_png(surface, "surface.png");
     //it is a photo that made by cairo [OK]
 
     cairo_destroy(cr);
 
     if (CAIRO_STATUS_SUCCESS == s)
     {
         printf("Status = OK \n");
     }
     else
     {
         printf("Status = ERROR <ERROR_CODE->%d>\n", s);
     }
 
     if(matchingConfigs!=NULL)
     {
         free(matchingConfigs);
         matchingConfigs=NULL;
     }
 
     cairo_surface_destroy(surface);
     printf("END!\n");
     return 0;
 }
 
 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Compiler prefix is :
 arm-none-linux-gnueabi
 
 Target Device is :
 IMX6Q
 
 Is it possible that there is a bug here in Cairo?or in my configuration or in my application?
 Of course I checked my application and replace the Cairo function with OpenGLES to saw that my EGL's settings were true and OpenGLES works, I saw something on my screen; but with Cairo no?
 
 Best Regards:
 Ali
   
    
    
   
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20150410/19542b03/attachment.html>


More information about the cairo mailing list