Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - gf_layer_attach() failed !!!: (8 Items)
   
gf_layer_attach() failed !!!  
Dear All,

Dear All,

I am new to qnx GF, I have read “Advanced Graphics Developers Guide.pdf” and trying to draw a rectangle on GF. I have 
x86 target machine connected to QNX Momentics IDE 4.7.

gf_layer_attach() is failed... can some help...

find output and code below.

Output:
Number of displays: 1
Display 0: 1024X768, refresh = 60Hz
Number of layers: 1

code snippet:

#include <stdio.h>
#include <stdlib.h>
#include <gf/gf.h>




int main() {

//device & display
gf_dev_t            gdev;
gf_dev_info_t       gdev_info;
gf_display_t        display;
gf_display_info_t   display_info;
int i;

//layer
gf_layer_t  layer;

//surface
gf_surface_t    surface;
unsigned height;
unsigned width;
gf_layer_info_t layer_info;

//context
gf_context_t context;


if (gf_dev_attach(&gdev, GF_DEVICE_INDEX(0), &gdev_info) != GF_ERR_OK) {
    printf("gf_dev_attach() failed\n");
    return (-1);
}

printf("Number of displays: %d\n",gdev_info.ndisplays);

for (i = 0; i < gdev_info.ndisplays; i++) {
    printf("Display %d: ", i);
    if (gf_display_attach(&display, gdev, i, &display_info) == GF_ERR_OK) {
        printf("%dX%d, refresh = %dHz\n", display_info.xres,
            display_info.yres, display_info.refresh);
        printf("Number of layers: %d\n", display_info.nlayers);
    } else {
        printf("gf_display_attach() failed\n");
    }
}

if (display != NULL) {


    if (gf_layer_attach(&layer,display,display_info.main_layer_index, 0) == GF_ERR_OK) {
    //if(gf_layer_attach(&layer,display,0, 0) == GF_ERR_OK) {
		printf("Attaching to Layer : 2\n ");
    }
    else {
        printf("gf_layer_attach() failed\n");
    }
}

if((gf_layer_query(layer,0,&layer_info))==GF_ERR_OK){
	printf("Layer is of Format %d\n",layer_info.format);
}
else{
	printf(" gf_layer_query() failed");
}

width = display_info.xres;
height = display_info.yres;

if (gf_surface_create_layer(&surface, &layer, 1, 0,
width, height, layer_info.format, NULL, 0) == GF_ERR_OK) {
		printf("Succesfully created surface on top of layer\n");
        gf_layer_set_surfaces(layer, &surface, 1);

        /* draw stuff here */

    } else {
        printf("gf_surface_create_layer() failed\n");
    }

if (gf_context_create(&context) != GF_ERR_OK) {
        fprintf(stderr, "gf_context_create failed\n");
        return -1;
    }

else{
printf(" Created the context succefully\n");
}


if (gf_context_set_surface(context,surface)!= GF_ERR_OK) {
            fprintf(stderr, "gf_context_set_surface failed\n");
            return -1;
        }
 else{
        printf("Context Surface is Set Succesfully\n");
        }





gf_draw_begin(context);


gf_context_set_fgcolor(context,0xFFFFFF);
gf_draw_rect(context,10,10,50,50);

gf_context_set_fgcolor(context,0x000000);
gf_draw_rect(context,20,20,40,40);
gf_draw_end(context);
gf_dev_detach(gdev);
return 0;
}



Attachment: Text draw.c 2.51 KB
RE: gf_layer_attach() failed !!!  
What is the return value from gf_layer_attach()?

-----Original Message-----
From: Ashwini Dubey [mailto:community-noreply@qnx.com] 
Sent: November-27-12 2:02 AM
To: advanced-graphics
Subject: gf_layer_attach() failed !!!

Dear All,

Dear All,

I am new to qnx GF, I have read “Advanced Graphics Developers Guide.pdf” and trying to draw a rectangle on GF. I have 
x86 target machine connected to QNX Momentics IDE 4.7.

gf_layer_attach() is failed... can some help...

find output and code below.

Output:
Number of displays: 1
Display 0: 1024X768, refresh = 60Hz
Number of layers: 1

code snippet:

#include <stdio.h>
#include <stdlib.h>
#include <gf/gf.h>




int main() {

//device & display
gf_dev_t            gdev;
gf_dev_info_t       gdev_info;
gf_display_t        display;
gf_display_info_t   display_info;
int i;

//layer
gf_layer_t  layer;

//surface
gf_surface_t    surface;
unsigned height;
unsigned width;
gf_layer_info_t layer_info;

//context
gf_context_t context;


if (gf_dev_attach(&gdev, GF_DEVICE_INDEX(0), &gdev_info) != GF_ERR_OK) {
    printf("gf_dev_attach() failed\n");
    return (-1);
}

printf("Number of displays: %d\n",gdev_info.ndisplays);

for (i = 0; i < gdev_info.ndisplays; i++) {
    printf("Display %d: ", i);
    if (gf_display_attach(&display, gdev, i, &display_info) == GF_ERR_OK) {
        printf("%dX%d, refresh = %dHz\n", display_info.xres,
            display_info.yres, display_info.refresh);
        printf("Number of layers: %d\n", display_info.nlayers);
    } else {
        printf("gf_display_attach() failed\n");
    }
}

if (display != NULL) {


    if (gf_layer_attach(&layer,display,display_info.main_layer_index, 0) == GF_ERR_OK) {
    //if(gf_layer_attach(&layer,display,0, 0) == GF_ERR_OK) {
		printf("Attaching to Layer : 2\n ");
    }
    else {
        printf("gf_layer_attach() failed\n");
    }
}

if((gf_layer_query(layer,0,&layer_info))==GF_ERR_OK){
	printf("Layer is of Format %d\n",layer_info.format); } else{
	printf(" gf_layer_query() failed");
}

width = display_info.xres;
height = display_info.yres;

if (gf_surface_create_layer(&surface, &layer, 1, 0, width, height, layer_info.format, NULL, 0) == GF_ERR_OK) {
		printf("Succesfully created surface on top of layer\n");
        gf_layer_set_surfaces(layer, &surface, 1);

        /* draw stuff here */

    } else {
        printf("gf_surface_create_layer() failed\n");
    }

if (gf_context_create(&context) != GF_ERR_OK) {
        fprintf(stderr, "gf_context_create failed\n");
        return -1;
    }

else{
printf(" Created the context succefully\n"); }


if (gf_context_set_surface(context,surface)!= GF_ERR_OK) {
            fprintf(stderr, "gf_context_set_surface failed\n");
            return -1;
        }
 else{
        printf("Context Surface is Set Succesfully\n");
        }





gf_draw_begin(context);


gf_context_set_fgcolor(context,0xFFFFFF);
gf_draw_rect(context,10,10,50,50);

gf_context_set_fgcolor(context,0x000000);
gf_draw_rect(context,20,20,40,40);
gf_draw_end(context);
gf_dev_detach(gdev);
return 0;
}







_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post97473
To cancel your subscription to this discussion, please e-mail advanced-graphics-unsubscribe@community.qnx.com
Re: RE: gf_layer_attach() failed !!!  
Return Value =  0x8
which is GF_ERR_INUSE..

I have installed qnx on i5 intel machine....and i can connect to it and run basic hello world...
i can use web browser too.

RE: RE: gf_layer_attach() failed !!!  
What else is running on the machine?  Is Photon running?  You only have one layer on your machine, so no other graphics 
environment or application can be running.

-----Original Message-----
From: Ashwini Dubey [mailto:community-noreply@qnx.com] 
Sent: November-28-12 3:45 AM
To: advanced-graphics
Subject: Re: RE: gf_layer_attach() failed !!!


Return Value =  0x8
which is GF_ERR_INUSE..

I have installed qnx on i5 intel machine....and i can connect to it and run basic hello world...
i can use web browser too.





_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post97541
To cancel your subscription to this discussion, please e-mail advanced-graphics-unsubscribe@community.qnx.com
Re: RE: RE: gf_layer_attach() failed !!!  
What else is running on the machine? 
I have a default installation and basic GUI is running.
…......
Is Photon running?
Yes. 
176152   1 /photon/bin/Photon  10r RECEIVE     1
…......
Number of displays: 1
Display 0: 1024X768, refresh = 60Hz
Number of layers: 1
…......

I am very new to QNX, but I am experienced in linux application and kernel development.
Currently I am using intel HD Graphics, PCI device, Vendor ID:8086, Device ID:0152.
….
please suggest what I need to draw a rectangle or circle or line.
Below is list of all the process running. Result of pidin command.

     pid tid name               prio STATE       Blocked                     
       1   1 boot/procnto-instr   0f READY                                   
       1   2 boot/procnto-instr 255r RECEIVE     1                           
       1   3 boot/procnto-instr  10r RECEIVE     1                           
       1   4 boot/procnto-instr  10r RUNNING                                 
       1   5 boot/procnto-instr 255r RECEIVE     1                           
       1   7 boot/procnto-instr  10r RECEIVE     1                           
       1   8 boot/procnto-instr  10r RECEIVE     1                           
       1  10 boot/procnto-instr  10r RECEIVE     1                           
       1  11 boot/procnto-instr  10r RECEIVE     1                           
       1  12 boot/procnto-instr  10r RECEIVE     1                           
       1  15 boot/procnto-instr  10r RECEIVE     1                           
       1  16 boot/procnto-instr  10r RECEIVE     1                           
       2   1 sbin/tinit          10o REPLY       1                           
    4099   1 proc/boot/pci-bios  10o RECEIVE     1                           
    4100   1 proc/boot/slogger   10o RECEIVE     1                           
    4101   1 proc/boot/io-usb    10o SIGWAITINFO                             
    4101   2 proc/boot/io-usb    21r RECEIVE     4                           
    4101   3 proc/boot/io-usb    21r RECEIVE     7                           
    4101   4 proc/boot/io-usb    21r RECEIVE     1                           
    4101   5 proc/boot/io-usb    10o RECEIVE     10                          
    4101   6 proc/boot/io-usb    10r NANOSLEEP                               
    4101   7 proc/boot/io-usb    10o RECEIVE     10                          
    4101   8 proc/boot/io-usb    10o RECEIVE     10                          
    4102   1 proc/boot/io-hid    10o SIGWAITINFO                             
    4102   2 proc/boot/io-hid    21r RECEIVE     1                           
    4102   4 proc/boot/io-hid    10o RECEIVE     4                           
    4102   5 proc/boot/io-hid    10r REPLY       4101                        
    4102   6 proc/boot/io-hid    10r REPLY       4101                        
    4102   7 proc/boot/io-hid     9r RECEIVE     12                          
    4102   8 proc/boot/io-hid     9r RECEIVE     16                          
    4102   9 proc/boot/io-hid    10o RECEIVE     4                           
    4103   1 /boot/devc-con-hid  20o RECEIVE     1                           
    4103   2 /boot/devc-con-hid  10o REPLY       4102                        
    8200   1 roc/boot/devb-eide  10o SIGWAITINFO                             
    8200   2 roc/boot/devb-eide  21r RECEIVE     1                           
    8200   3 roc/boot/devb-eide  21o RECEIVE     7                           
    8200   4 roc/boot/devb-eide  10o RECEIVE     4                           
    8200   5 roc/boot/devb-eide  10o RECEIVE     4                           
    8200   6 roc/boot/devb-eide  10o RECEIVE     4                           
    8200   7 roc/boot/devb-eide  10o RECEIVE     4                           
    8200  10 roc/boot/devb-eide  10o RECEIVE     4                           
    8200  13 roc/boot/devb-eide  10o RECEIVE     4                           
  ...
View Full Message
RE: RE: RE: gf_layer_attach() failed !!!  
If you want to use Photon, ypu must use Pg photon drawing lines, please see helpviewer in Photon.
If you want to use GF application, then you must exit Photon to text mode, then to make it easy, telnet into the QNX box
, then run the GF application.

-----Original Message-----
From: Ashwini Dubey [mailto:community-noreply@qnx.com] 
Sent: November-29-12 3:16 AM
To: advanced-graphics
Subject: Re: RE: RE: gf_layer_attach() failed !!!


What else is running on the machine? 
I have a default installation and basic GUI is running.
…......
Is Photon running?
Yes. 
176152   1 /photon/bin/Photon  10r RECEIVE     1
…......
Number of displays: 1
Display 0: 1024X768, refresh = 60Hz
Number of layers: 1
…......

I am very new to QNX, but I am experienced in linux application and kernel development.
Currently I am using intel HD Graphics, PCI device, Vendor ID:8086, Device ID:0152.
….
please suggest what I need to draw a rectangle or circle or line.
Below is list of all the process running. Result of pidin command.

     pid tid name               prio STATE       Blocked                     
       1   1 boot/procnto-instr   0f READY                                   
       1   2 boot/procnto-instr 255r RECEIVE     1                           
       1   3 boot/procnto-instr  10r RECEIVE     1                           
       1   4 boot/procnto-instr  10r RUNNING                                 
       1   5 boot/procnto-instr 255r RECEIVE     1                           
       1   7 boot/procnto-instr  10r RECEIVE     1                           
       1   8 boot/procnto-instr  10r RECEIVE     1                           
       1  10 boot/procnto-instr  10r RECEIVE     1                           
       1  11 boot/procnto-instr  10r RECEIVE     1                           
       1  12 boot/procnto-instr  10r RECEIVE     1                           
       1  15 boot/procnto-instr  10r RECEIVE     1                           
       1  16 boot/procnto-instr  10r RECEIVE     1                           
       2   1 sbin/tinit          10o REPLY       1                           
    4099   1 proc/boot/pci-bios  10o RECEIVE     1                           
    4100   1 proc/boot/slogger   10o RECEIVE     1                           
    4101   1 proc/boot/io-usb    10o SIGWAITINFO                             
    4101   2 proc/boot/io-usb    21r RECEIVE     4                           
    4101   3 proc/boot/io-usb    21r RECEIVE     7                           
    4101   4 proc/boot/io-usb    21r RECEIVE     1                           
    4101   5 proc/boot/io-usb    10o RECEIVE     10                          
    4101   6 proc/boot/io-usb    10r NANOSLEEP                               
    4101   7 proc/boot/io-usb    10o RECEIVE     10                          
    4101   8 proc/boot/io-usb    10o RECEIVE     10                          
    4102   1 proc/boot/io-hid    10o SIGWAITINFO                             
    4102   2 proc/boot/io-hid    21r RECEIVE     1                           
    4102   4 proc/boot/io-hid    10o RECEIVE     4                           
    4102   5 proc/boot/io-hid    10r REPLY       4101                        
    4102   6 proc/boot/io-hid    10r REPLY       4101                        
    4102   7 proc/boot/io-hid     9r RECEIVE     12                          
    4102   8 proc/boot/io-hid     9r RECEIVE     16                          
    4102   9 proc/boot/io-hid    10o RECEIVE     4                           
    4103   1 /boot/devc-con-hid  20o RECEIVE     1                           
    4103   2 /boot/devc-con-hid  10o REPLY       4102                        
    8200   1 roc/boot/devb-eide  10o SIGWAITINFO                             
    8200   2 roc/boot/devb-eide  21r RECEIVE     1                           
    8200   3 roc/boot/devb-eide  21o RECEIVE     7                           
    8200   4 roc/boot/devb-eide ...
View Full Message
Re: RE: RE: RE: gf_layer_attach() failed !!!  

Can you please provide example of working GF drawing code.
Do let me also know how to toggle between GUI and text mode.

RE: RE: RE: RE: gf_layer_attach() failed !!!  
Please contact tech support for this level of support.

-----Original Message-----
From: Ashwini Dubey [mailto:community-noreply@qnx.com] 
Sent: November-29-12 10:20 AM
To: advanced-graphics
Subject: Re: RE: RE: RE: gf_layer_attach() failed !!!



Can you please provide example of working GF drawing code.
Do let me also know how to toggle between GUI and text mode.





_______________________________________________

Advanced Graphics
http://community.qnx.com/sf/go/post97622
To cancel your subscription to this discussion, please e-mail advanced-graphics-unsubscribe@community.qnx.com