Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - The screen is flash when draw a bitmap by OpenVg: (4 Items)
   
The screen is flash when draw a bitmap by OpenVg  
Hi!Everyone!
I want to draw a bitmap with full screen.
The size of map data is 480*272,the resolution of screen is 640*480.
The process is:
1.OpenKode and EGl initialization
2.OpenVg initialization
   eglBindAPI;
   vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE)
   vgScale(640/480, 480/272)
   vgCreateImage
3.read data from frame buffer and display the image(while loop)
   read(fd,buffer,length)
   vgImageSubData
   vgDrawImage
   eglSwapBuffers

result:
1.The picture of display is right,but the screen is flash three times in one second(The data is read three times in one 
second)
2.sometimes the display of picture is the picture which have been displayed last time.

ps:
1.The screen is don't flash When read data and draw image only one time.
2.The platform is ARM. The same of code run on the x86(HP) don't flash,but run on the ARM is flash.

my question:
1.The cause of the error
2.How to resolved?

Thank you very much! 
     
   
RE: The screen is flash when draw a bitmap by OpenVg  
Hi Hu,
	I have a few questions regarding your inquiry­.

	What boards (with processor speed) are you using exactly (both the ARM and the x86)?  What EGL, OpenKode and OpenVG 
solution are you using on the x86?

	In your result #1, by flash, do you mean flicker, or refresh?

	In your result #2, you mean that the picture you want to display isn't updated even after the eglSwapBuffers?

	How do you use OpenKode, and what is the eglSwapInterval set to?

	How is your buffer (destination of your read) allocated?

	Can you provide us the code for your app?

Cheers,
Gaétan

-----Original Message-----
From: hu xiaohua [mailto:community-noreply@qnx.com] 
Sent: June 25, 2009 4:11 AM
To: openvg-graphics
Subject: The screen is flash when draw a bitmap by OpenVg

Hi!Everyone!
I want to draw a bitmap with full screen.
The size of map data is 480*272,the resolution of screen is 640*480.
The process is:
1.OpenKode and EGl initialization
2.OpenVg initialization
   eglBindAPI;
   vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE)
   vgScale(640/480, 480/272)
   vgCreateImage
3.read data from frame buffer and display the image(while loop)
   read(fd,buffer,length)
   vgImageSubData
   vgDrawImage
   eglSwapBuffers

result:
1.The picture of display is right,but the screen is flash three times in one second(The data is read three times in one 
second) 2.sometimes the display of picture is the picture which have been displayed last time.

ps:
1.The screen is don't flash When read data and draw image only one time.
2.The platform is ARM. The same of code run on the x86(HP) don't flash,but run on the ARM is flash.

my question:
1.The cause of the error
2.How to resolved?

Thank you very much! 
     
   

_______________________________________________
OpenVG
http://community.qnx.com/sf/go/post32498
Re: RE: The screen is flash when draw a bitmap by OpenVg  
result #1 flash is refresh
result #2 The picture is updated with right one time after the eglSwapBuffers,but next time the display of picture is 
not right where the data and last time is same.

There is no refresh when I run the sample code on x86,but the same code run on the ARM is refresh.(sample code is sw-kd-
vsync)  

the process:
video_display()
{
    unsigned char * buffer_data = (unsigned char *)malloc(480*272*2) ;

      egl_init(){
      }

    vgCreateImage();
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE)
    vgScale(640/480, 480/272)

       
    while(1){
          data_size = read(fd,buffer_data,480*272*2);
          vgImageSubData(image,buffer_data, 0, VG_sRGB_565, 0, 0,480,272);
         vgDrawImage(image);
         eglSwapBuffers(egl_disp, egl_surf); 
           
    }  
 
The data is read three times on one second!So the display refresh is three times on one second!

Thank you very much!
    

    


}
Re: RE: The screen is flash when draw a bitmap by OpenVg  
This is my code:
KDint kdMain(KDint argc, const KDchar *const *argv)
{
        EGLint egl_conf_attr[] = {

        EGL_SURFACE_TYPE, EGL_WINDOW_BIT|EGL_LOCK_SURFACE_BIT_KHR|EGL_SWAP_BEHAVIOR_PRESERVED_BIT,
        EGL_RENDERABLE_TYPE, EGL_OPENVG_API,   /* We don't care about renderable type */
        EGL_NATIVE_RENDERABLE, EGL_DONT_CARE, /* We won't use native rendering either */
        EGL_LEVEL, EGL_DONT_CARE,             /* Use main layer by default */
        EGL_RED_SIZE, 5,                     
        EGL_GREEN_SIZE, 6,                   
        EGL_BLUE_SIZE, 5,                    
        EGL_ALPHA_SIZE,EGL_DONT_CARE,                                          EGL_NONE                              /* 
End of list */
    };



    const KDint32 exit_area_size = 20;

    EGLDisplay egl_disp;               
    EGLConfig egl_conf = (EGLConfig)0;  
    EGLint egl_num_configs;             
    EGLSurface egl_surf;               
    KDWindow *kd_win;                  
    EGLNativeWindowType egl_win;     
    KDint32 kd_size[2] = { -1, -1 };   
    KDint32 kd_pos[2] = { -1, -1 };    
    EGLint interval = 1;               
    KDboolean kd_vis = KD_TRUE;         
    KDust timeout = 0;                
    const KDEvent *event;             
    int rval = EXIT_FAILURE;          
    int rc;                          
    int i;                             
    EGLContext egl_context;

    egl_disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (egl_disp == EGL_NO_DISPLAY) {
        egl_perror("eglGetDisplay");
        goto fail1;
    }

    rc = eglInitialize(egl_disp, NULL, NULL);
    if (rc != EGL_TRUE) {
        egl_perror("eglInitialize");
        goto fail2;
    }

    eglBindAPI(EGL_OPENVG_API);

    if (egl_conf == 0) {
        rc = eglChooseConfig(egl_disp, egl_conf_attr, &egl_conf, 1, &egl_num_configs);
        if (rc != EGL_TRUE) {
            egl_perror("eglChooseConfig");
            goto fail2;
        }
        if (egl_num_configs == 0) {
            fprintf(stderr, "eglChooseConfig: could not find a configuration\n");
            goto fail2;
        }
    }

    kd_win = kdCreateWindow(egl_disp, egl_conf, KD_NULL);
    if (kd_win == KD_NULL) {
        kd_perror("kdCreateWindow");
        goto fail2;
    }


    if (kd_size[0] != -1 && kd_size[1] != -1) {
        kdSetWindowPropertyiv(kd_win, KD_WINDOWPROPERTY_SIZE, kd_size);
    }
    if (kd_pos[0] != -1 && kd_pos[1] != -1) {

    }

    rc = kdRealizeWindow(kd_win, &egl_win);
    if (rc) {
        kd_perror("kdRealizeWindow");
        goto fail3;
    }


    egl_surf = eglCreateWindowSurface(egl_disp, egl_conf, egl_win, NULL);
    if (egl_surf == EGL_NO_SURFACE) {
        egl_perror("eglCreateWindowSurface");
        goto fail3;
    }

    egl_context = eglCreateContext(egl_disp, egl_conf, NULL,NULL);

    eglMakeCurrent(egl_disp,egl_surf, egl_surf,egl_context);



    rc = eglSurfaceAttrib(egl_disp, egl_surf, EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
    if (rc != EGL_TRUE) {
        egl_perror("eglSurfaceAttrib");
        goto fail4;
    }


    rc = eglSurfaceAttrib(egl_disp, egl_surf, EGL_SWAP_INTERVAL_QNX, interval);
    if (rc != EGL_TRUE) {
        egl_perror("eglSurfaceAttrib");
        goto fail2;
    }



    if (kd_size[0] == -1 || kd_size[1] == -1) {
        kdGetWindowPropertyiv(kd_win, KD_WINDOWPROPERTY_SIZE, kd_size);
    }

  eglSwapInterval(egl_disp,60);


   VGImage image;

    unsigned char * buffer=(unsigned char * )malloc(200*300);

    image = vgCreateImage(VG_sRGB_565,480,272, VG_IMAGE_QUALITY_NONANTIALIASED);
    vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
    vgScale(640.0/480.0, 480.0/272.0);
    i = 0;
    while (1) {
       

        while ((event = kdWaitEvent(timeout)) != KD_NULL) {
            switch (event->type) {
                case KD_EVENT_WINDOW_CLOSE:

                    goto...
View Full Message