User avatar
Paeryn
Posts: 2632
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: openvg (Paeryn, ajstarks)

Thu Jan 07, 2016 1:09 pm

Yes, installing is the same, no alterations to what files to include in your C code.

OpenVG uses the normal bottom-left origin with positive values going up-right view that is common in graphs. It's not going to change.
She who travels light — forgot something.

User avatar
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: openvg (Paeryn, ajstarks)

Fri Jan 08, 2016 1:07 am

I've added a tracking bug for adding the changes from Paeryn. Expect an update to the library soon.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Fri Jan 15, 2016 7:50 am

many thanks for your efforts from me to you, too!
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Sat Jan 16, 2016 1:12 pm

update:

I tried either way and compared both drawing rectangles over each line if needed (up to 10 lines over all),
and instead clearing the screen once completely before writing then all and everything anew.

Result: It does not make any visible speed difference to my observation.

So because it's more easy to clear the whole screen completely, I'll do it that way for my chart table, and in case there once will be an area which had to be protected (e.g., for graphic shapes), then I will paint 1 big black rectangle once over the whole chart area part.

I think that will do it as quick as it's almost possible at all, and the speed is actually really fine.

So again thanks for your input, Paeryn!
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 12:33 pm

hey,
I want to outsource the display things into a continuous loop in a pthread task by low task_priority and delays of (50) because it slows down the whole program flow too much.
(Hopefully I will be able to do all the openvg things in the dedicated display pthread task, if possible.)

So do I have to do those

Code: Select all

   
   InitWindowsize();
   init();
   Start(width, height);                   // Start the picture
   finish();                               // Graphics cleanup
in the main task or exclusively in the pthread display task?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Paeryn
Posts: 2632
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 3:02 pm

All the openvg (and hence libshapes) calls need to be done in the same thread. This is due to the drawing context being tied to a single thread at a time. Whilst it is possible to share an openvg context between threads it takes a bit of work to synchronise it all, and libshapes doesn't expose the required information.

So when you create your drawing thread, have it create the window and then sit in a loop doing the drawing.
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 3:14 pm

thanks -
done! :)

when aborting the program I currently do that by ctrl+c on my Raspi keyboard, later I will have a high prio emergency brake task (button hit watcher) which kills all tasks immediately.
In that case I'm not sure about how to process the graphic cleaning by finish():
in the pthread or in main nevertheless?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Paeryn
Posts: 2632
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 3:48 pm

davenull wrote:when aborting the program I currently do that by ctrl+c on my Raspi keyboard, later I will have a high prio emergency brake task (button hit watcher) which kills all tasks immediately.
In that case I'm not sure about how to process the graphic cleaning by finish():
in the pthread ar in main nevertheless?
When you press CTRL-C at the terminal what happens is that the foreground process gets sent a SIGINT signal. You can have your main thread catch that signal and exit cleanly. If you don't catch it yourself the usual behaviour is that the process just terminates and it's up to the OS to try and recover any resources that you had allocated. So if you aren't catching the signal now, then whatever is currently happening will (should) still happen.

If your future "emergency brake" forcibly stops processes with a SIGKILL then your program won't be able to catch it - so use SIGINT.
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 4:05 pm

as I'm very new to all that POSIX things and Linux:
how can I "catch a SIGINT"?
(I vaguely heard of catch events by Java - but by C I never heard of it, admittedly)
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Sun Jan 17, 2016 4:59 pm

update:

I added

Code: Select all

if (kbhit())
        {
            int c = getchar();
            if(c==27) sem_threadrun=0 ;
        }
and all tasks which run in infinite loops have

Code: Select all

while(sem_threadrun) {
I think that will do it for normal things, emergency stops somehow otherwise
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Paeryn
Posts: 2632
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: openvg (Paeryn, ajstarks)

Mon Jan 18, 2016 2:30 am

davenull wrote:as I'm very new to all that POSIX things and Linux:
how can I "catch a SIGINT"?
(I vaguely heard of catch events by Java - but by C I never heard of it, admittedly)
http://www.thegeekstuff.com/2012/03/cat ... le-c-code/

Note that if you set a new signal handler with signal() then the previous handler is no longer called. In case of setting SIGINT you need to do what you need to clean up and then exit (or call the original handler which should do the exit).
When signal() sets your handler it returns the previous one so you can save it and call it after you've done what you needed to do.
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: openvg (Paeryn, ajstarks)

Mon Jan 18, 2016 8:40 am

thank you, but this http://www.thegeekstuff.com/2012/03/cat ... le-c-code/ is unfortunately too hard to comprehend to me, because of both my programming and my English skills... :(
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “Graphics, sound and multimedia”