The PtGetResource() always confuses me. Its parameters are same as PtSetResource, but actually they’re not same.
when try to set points of polygon, i write code like that:
[color=blue]PhPoint_t pnts[4]={{50,50},{100,150},{150,100},{50,50}}
PtSetResource(widget,Pt_ARG_POINTS,pnts,5);
but how can i get all points of that polygon?
[color=red]int i;
PhPoint_t *pnts2[4];
PtGetResource(widget,Pt_ARG_POINTS,&pnts2,0);
for(i=0;i<4;i++)
{
printf(“point i pos is:%d,%d\n”,pnts[i]->x,pnts[i]->y);}
And the result turn out to be:
[color=green]
point 0 pos is:50,50
Memory fault(core dumped)
Can anyone help me to correct the program? Thx in advance!
Thx for your help.
In fact, that code doesn’t work well. Since pts is a pointer, how can i get each point of polygon?And when i printf count, its value is 13456023,
i change code like this:
[color=red]long *count;
for(i=0;i<*count;i++)
[color=blue]{???//how should I write code here?}
now the value of *count turn out to be 5.
But there’s still a problem: how to get each point of a pointer?
If you look at the docs for Pt_ARG_POINTS, you’ll see that its C type is given as “PhPoint_t*, short”. For array resources, the second type indicates what type to pass for the number of entries.