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

[resolved:] HDMI: font sizes, simple graphics by g++ C

Thu Oct 22, 2015 7:40 am

hello,
for my Raspi B+ I'm using HDMI screens (11-12") and for programming I'm using C/C++ by Geany on Raspbian Linux (latest download).

What will be the most simple and most convenient way to #include and use C libs to have
text output by different font sizes,
write at (x,y) position for tables/charts,
and simple graphics like e.g., put pixels, lines, triangles, rectangles, circles, by border or fillshapes,
and all by different colors?

just sort of things which are shown in this video for an Arduino display which I am already using currently:
(but of course the question is NOT about this Arduino-SPI thing, but about similar features for my Raspi HDMI screens):

https://www.youtube.com/watch?v=vnEwzN14BsU

I just have started with Raspberry Pi, having only very fragmentary knowledge about Linux, just some experience on Arduino C/C++ (Sketch/Wiring) so far. So simple installation procedures and intuitive API functions would be appreciated.
Last edited by davenull on Sun Oct 25, 2015 2:10 pm, edited 3 times in total.
#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(;;);}

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 3:35 pm

• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

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

Re: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 3:48 pm

thank you for the links!

about installation:

1st,
I already once tried the command
git clone...
for a different issue but that didn't work on my Raspi.
Is there a different way to install all the required libs?

please remember, I am completely new to Linux.

2nd,
do I have to use both links or just one of them? I don't understand quite what they are actually designed for
#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(;;);}

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 4:04 pm

I posted the second link for a direct jump to the instructions. Both links point at the same thing , as you've guessed.

Install git and try the instructions again :

Code: Select all

sudo apt-get update
sudo apt-get install git
ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

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

Re: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 4:18 pm

try again...
I missed 1 step, and a typo...:

[email protected] ~ $ sudo apt-get install libjpeg8-dev indent libfreetype6-dev ttf-dejavu-core

Next, build the library and test:

[email protected] ~ $ git clone git://github.com/ajstarks/openvg
[email protected] ~ $ cd openvg
[email protected] ~/openvg $ make
g++ -I/usr/include/freetype2 fontutil/font2openvg.cpp -o font2openvg -lfreetype
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf DejaVuSans.inc DejaVuSans
224 glyphs written
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf DejaVuSansMono.inc DejaVuSansMono
224 glyphs written
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf DejaVuSerif.inc DejaVuSerif
224 glyphs written
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c libshapes.c
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c oglinit.c
[email protected] ~/openvg/client $ cd client
[email protected] ~/openvg/client $ make test
cc -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -o shapedemo shapedemo.c ../libshapes.o ../oglinit.o -L/opt/vc/lib -lGLESv2 -ljpeg
./shapedemo demo 5
Last edited by davenull on Thu Oct 22, 2015 8:40 pm, edited 2 times in total.
#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: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 5:11 pm

command does not work:

[email protected] ~/openvg/client $ cd ~/openvg
[email protected] ~/openvg $ make library
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c libshapes.c
gcc -L/opt/vc/lib -lGLESv2 -lEGL -ljpeg -shared -o libshapes.so oglinit.o libshapes.o
[email protected] ~/openvg $ sudo make install
install -m 755 -p font2openvg /usr/bin/
install -m 755 -p libshapes.so /usr/lib/libshapes.so.1.0.0
strip --strip-unneeded /usr/lib/libshapes.so.1.0.0
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so.1
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so.1.0
install -m 644 -p shapes.h /usr/include/
install -m 644 -p fontinfo.h /usr/include/

[email protected] ~/openvg $ gcc -I/opt/vc/include anysource.c -o anysource -lshapes

gcc: error: anysource.c: Datei oder Verzeichnis nicht gefunden (== no such file or directory)



Code: Select all

// first OpenVG program
// Anthony Starks ([email protected])
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"

int main() {
    int width, height;
    char s[3];

    init(&width, &height);                  // Graphics initialization

    Start(width, height);                   // Start the picture
    Background(0, 0, 0);                    // Black background
    Fill(44, 77, 232, 1);                   // Big blue marble
    Circle(width / 2, 0, width);            // The "world"
    Fill(255, 255, 255, 1);                 // White text
    TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);  // Greetings 
    End();                                  // End the picture

    fgets(s, 2, stdin);                     // look at the pic, end with [RETURN]
    finish();                               // Graphics cleanup
    exit(0);
}
compiler error:
g++ -Wall -c "openvg_helloworld.c" -lpthread -lpigpio -lrt -lwiringPi (im Verzeichnis: /home/pi/programs/openvg)[email protected] ~/openvg/client $ cd ~/openvg
[email protected] ~/openvg $ make library
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c libshapes.c
gcc -L/opt/vc/lib -lGLESv2 -lEGL -ljpeg -shared -o libshapes.so oglinit.o libshapes.o
[email protected] ~/openvg $ sudo make install
install -m 755 -p font2openvg /usr/bin/
install -m 755 -p libshapes.so /usr/lib/libshapes.so.1.0.0
strip --strip-unneeded /usr/lib/libshapes.so.1.0.0
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so.1
ln -f -s /usr/lib/libshapes.so.1.0.0 /usr/lib/libshapes.so.1.0
install -m 644 -p shapes.h /usr/include/
install -m 644 -p fontinfo.h /usr/include/
[email protected] ~/openvg $ gcc -I/opt/vc/include anysource.c -o anysource -lshapes
gcc: error: anysource.c: Datei oder Verzeichnis nicht gefunden

openvg_helloworld.c:6:23: fatal error: VG/openvg.h: Datei oder Verzeichnis nicht gefunden (== no such file or directory)
#include "VG/openvg.h"
^
compilation terminated.
Kompilierung fehlgeschlagen.

what's wrong with the VG folder?

(I don't understand all those commands and those ~ $ ./ stuff, sure there were lots of typos...)
Last edited by davenull on Thu Oct 22, 2015 9:39 pm, edited 3 times in total.
#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: HDMI: font sizes, simple graphics by C

Thu Oct 22, 2015 8:57 pm

edit:
I also added the line
-I/opt/vc/include anysource.c -o anysource -lshapes
additionally to Geany parameter settings for compile and make, nevertheless the error is

g++ -Wall -c "openvg_helloworld.c" -lpthread -lpigpio -lrt -lwiringPi -l/opt/vc/include anysource.c -o anysource -lshapes
(im Verzeichnis: /home/pi/programs/openvg)
Compilation terminated
g++: error: anysourve.c: no such file or directory.


what's wrong?
what did I miss?
who can help?
#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: HDMI: font sizes, simple graphics by C

Fri Oct 23, 2015 10:29 am

where can I find or how can I generate this missing anysource.c file ?
#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(;;);}

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: HDMI: font sizes, simple graphics by C

Fri Oct 23, 2015 11:21 am

anysource.c is a placeholder filename for code you have to write yourself.

Create anysource.c with a text editor (Geany) and put the example code in it.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

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

Re: HDMI: font sizes, simple graphics by C

Fri Oct 23, 2015 12:30 pm

so, for g++ call how will the makefile commands then be?

filename is openvg_helloworld.c

normally my parameters are for compile:
g++ -Wall -c "%f" -lpthread -lrt -lwiringPi

for make:
g++ -Wall -o "%e" "%f" -lpthread -lrt -lwiringPi

now additionally
-l/opt/vc/include -o -lshapes ?
(I have no clue what these parameters actually mean or do)

g++ -Wall -c "openvg_helloworld.c" -lpthread -lpigpio -lrt -lwiringPi -l/opt/vc/include -o -lshapes ?

I tried that with the helloworld-Example and got:
g++ -Wall -c "openvg_helloworld.c" -lpthread -lpigpio -lrt -lwiringPi -l/opt/vc/include -o -lshapes (im Verzeichnis: /home/pi/programs/openvg)
openvg_helloworld.c:6:23: fatal error: VG/openvg.h: Datei oder Verzeichnis nicht gefunden (no such file or directory)
#include "VG/openvg.h"

^
compilation terminated.
Kompilierung fehlgeschlagen.
why doesn't it find the lib VG/openvg.h? As you may see, I followed all the installation instructions... or not ?

Code: Select all

    // first OpenVG program
    // Anthony Starks ([email protected])
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include "VG/openvg.h"
    #include "VG/vgu.h"
    #include "fontinfo.h"
    #include "shapes.h"

    int main() {
        int width, height;
        char s[3];

        init(&width, &height);                  // Graphics initialization

        Start(width, height);                   // Start the picture
        Background(0, 0, 0);                    // Black background
        Fill(44, 77, 232, 1);                   // Big blue marble
        Circle(width / 2, 0, width);            // The "world"
        Fill(255, 255, 255, 1);                 // White text
        TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);  // Greetings
        End();                                  // End the picture

        fgets(s, 2, stdin);                     // look at the pic, end with [RETURN]
        finish();                               // Graphics cleanup
        exit(0);
    }
(hell, how I hate this Linux!)
Last edited by davenull on Sat Oct 24, 2015 7:15 am, edited 1 time in total.
#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: HDMI: font sizes, simple graphics by C

Fri Oct 23, 2015 4:39 pm

as this OpenVG lib seems to be faulty and/or all the instructions are completely ambiguous and misleadingl:

is there a different graphic + font lib which is working correctly from the start?
#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: HDMI: font sizes, simple graphics by C

Sat Oct 24, 2015 5:30 am

no idea what''s missing or faulty ?

no alternative operational graph lib?
#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
buja
Posts: 507
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: HDMI: font sizes, simple graphics by C

Sat Oct 24, 2015 6:43 am

There is nothing wrong with OpenVG, I managed to compile and run the examples in the client subdirectory.

But before you start to compile anything, you must install some other software:

Code: Select all

sudo apt-get install libjpeg8-dev indent libfreetype6-dev ttf-dejavu-core
It's all in the file READ.me and on the Github website under the header Build and Run: https://github.com/ajstarks/openvg#build-and-run

(reading back I see that ghans gave the same info)

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

Re: HDMI: font sizes, simple graphics by C

Sat Oct 24, 2015 7:09 am

sorry, I don't understand (my English is very poor).

my working dirctories differ, all is in
home/pi/programs/.../...
home/pi/C_projects/.../...

finally all libs have to be accessable from either directory on the Pi..
so first,
how have the Geany compiler and make file settings to be changed to make them work with openVG graphs and fonts everywhere, on every different local directory?
normally my parameters are for compile:
g++ -Wall -c "%f" -lpthread -lrt -lwiringPi

for make:
g++ -Wall -o "%e" "%f" -lpthread -lrt -lwiringPi

BTW, as you see:
I'm using g++, not gcc - does that matter?

edit:
about

Code: Select all

sudo apt-get install libjpeg8-dev indent libfreetype6-dev ttf-dejavu-core
I already have the latest version installed !
I did all this:

Code: Select all

[email protected] ~ $ sudo apt-get install libjpeg8-dev indent libfreetype6-dev ttf-dejavu-core

[email protected] ~ $ git clone git://github.com/ajstarks/openvg
[email protected] ~ $ cd openvg
[email protected] ~/openvg $ make
g++ -I/usr/include/freetype2 fontutil/font2openvg.cpp -o font2openvg -lfreetype
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf DejaVuSans.inc DejaVuSans
224 glyphs written
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf DejaVuSansMono.inc DejaVuSansMono
224 glyphs written
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf DejaVuSerif.inc DejaVuSerif
224 glyphs written
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c libshapes.c
gcc -O2 -Wall -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads -c oglinit.c
[email protected] ~/openvg/client $ cd client
[email protected] ~/openvg/client $ make test
cc -Wall -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -o shapedemo shapedemo.c ../libshapes.o ../oglinit.o -L/opt/vc/lib -lGLESv2 -ljpeg
./shapedemo demo 5
#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
buja
Posts: 507
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: HDMI: font sizes, simple graphics by C

Sat Oct 24, 2015 8:21 am

Can you run the hellovg example program (it's in openvg/client)?

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

Re: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 8:42 am

no, I can't, I think it's mainly because of the command line parameters of geany -
how can I fix them ?

Code: Select all

// first OpenVG program
// Anthony Starks ([email protected]om)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "VG/openvg.h"
#include "VG/vgu.h"
#include "fontinfo.h"
#include "shapes.h"

int main() {
    int width, height;
    char s[3];

    init(&width, &height);                  // Graphics initialization

    Start(width, height);                   // Start the picture
    Background(0, 0, 0);                    // Black background
    Fill(44, 77, 232, 1);                   // Big blue marble
    Circle(width / 2, 0, width);            // The "world"
    Fill(255, 255, 255, 1);                 // White text
    TextMid(width / 2, height / 2, "hello, world", SerifTypeface, width / 10);  // Greetings
    End();                                  // End the picture

    fgets(s, 2, stdin);                     // look at the pic, end with [RETURN]
    finish();                               // Graphics cleanup
    exit(0);
}
g++ -Wall -o "openvg_helloworld.c" -lpthread -lrt -lwiringPi (im Verzeichnis: /home/pi/openvg/client)
Kompilierung fehlgeschlagen.
/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../arm-linux-gnueabihf/crt1.o: In function `_start':
/build/glibc-IRmfEu/glibc-2.19/csu/../ports/sysdeps/arm/start.S:119: undefined reference to `main'
collect2: error: ld returned 1 exit status
#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
buja
Posts: 507
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 10:25 am

Forget about Geany, gcc and g++ for now, first let's make the example programs work.
  1. goto the OpenVG directory (for me that's /home/pi/openvg, so my command would be cd ~/openvg)
  2. type make. This will make the libraries to run the examples.
  3. type cd client
  4. type make hellovg (or make test to make all test programs)
Now you should have a running example program, try ./hellovg to make sure (press enter to end the program).
If it works, you can go to the next step (see below).
If it does not work, delete the OpenVG directory completely and repeat all the steps from the Build & Run instructions exactly, from installing the extra libraries and cloning the git repository to running the hellovg example program.

The next step (if it works) is to change the hellovg program and recompile (make hellovg) and run it to see if your change works. By using the Makefile gcc will find every header file and library it needs.

To install the libraries system-wide follow the instructions in the READ.me file exactly.
After that you can set up Geany to include the header files and libraries you need to write your own programs.

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

Re: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 10:45 am

the example showing different shapes and figuers worked.

and I am 100% sure it will work in the way you described it by your command line make instructions.

ps, tested, yes the commandline make hellovg worked!
but after opening hellovg by Geany and compiling by F8 the reported compile errors happen.

Nevertheless, I need to have it working by Geany and g++ as I only work with this IDE,
never command line, never makefile,
never,
never,
never !

so what are the complete compile/make parameters and settings for Geany (all this -l mess and the correct #includes) ?

(about how to install the libraries system-wide I don't understand the instructions at all.)
Last edited by davenull on Sat Oct 24, 2015 11:51 am, edited 1 time in total.
#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
buja
Posts: 507
Joined: Wed Dec 31, 2014 8:21 am
Location: Netherlands

Re: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 12:08 pm

Everything you need to know about setting up OpenVG correctly is in the READ.me file and the website. Look for the commands make library and sudo make install.

Setting up Geany is another matter. If you understand how it works on the command line it will be simple. Geany is nothing more than an editor with some extra features to generate the proper command line.

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

Re: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 12:12 pm

I did all that what was described in the instructions.

It works until
[email protected] ~/openvg $ make
[email protected] ~/openvg/client $ cd client
[email protected] ~/openvg/client $ make test

make hellovg
./hellovg

but after this the following is not understandable and nothing worked , starting by
The openvg shapes library can now be used in C code by including shapes.h and fontinfo.h and linking with libshapes.so // WHAT ???
:
#include <shapes.h>
#include <fontinfo.h>
[email protected] ~/openvg $ gcc -I/opt/vc/include anysource.c -o anysource -lshapes // WHAT ???
and also the settings for Geany are completely obscured and Geany doesn't work with the openvg libs.
(Nevertheless, different other C++ programs work absolutely fine with Geany!)


Please, who can make it work with Geany ?
#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: HDMI: font sizes, simple graphics by g++ C

Sat Oct 24, 2015 4:08 pm

I think I have to give up with this lib - don't know what to do to make it work with Geany.

any different libs which work with Geany out of the box?
#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
ajstarks
Posts: 129
Joined: Fri Jun 22, 2012 2:14 am

Re: HDMI: font sizes, simple graphics by g++ C

Sun Oct 25, 2015 1:23 am

After building and installing the library, you must specify these paths to build your own code outside of the tree:


gcc -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads anysource.c -o anysource -lshapes

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

Re: HDMI: font sizes, simple graphics by g++ C

Sun Oct 25, 2015 8:54 am

for this parameters it works already, no problem:

for compile:
g++ -Wall -c "%f" -lpthread -lrt -lwiringPi

for make:
g++ -Wall -o "%e" "%f" -lpthread -lrt -lwiringPi

so what do I have to add exactly specify the paths?

-I/opt/vc/include -o -lshapes

(Please recall that I am COMPLETELY new to Raspi, I just used C by Arduino Sketch so far where I didn't need to care about the compile and link or make settings!)
#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(;;);}

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: HDMI: font sizes, simple graphics by g++ C

Sun Oct 25, 2015 10:23 am

Where are those commandlines from ? Why are you linking with WiringPi ?

Humor us and copy the the commandline posted by ajstarks letter by letter. Of course you need example code anysource.c in the same directory.

Furthermore have a look at those links :

https://www3.ntu.edu.sg/home/ehchua/pro ... _make.html
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
http://stackoverflow.com/questions/5853 ... nd-g-gcc-c

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

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

Re: HDMI: font sizes, simple graphics by g++ C

Sun Oct 25, 2015 10:25 am

I'm already linking with wiringPi and all the other parameters because I always use them for each of my projects so far.
They already work on either directory.

They now have to be expanded to work additionally for graphic screens (e.g., by openvg), too.
I need to have access to all libs from either different working or project directory, even temporary ones.
#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 “C/C++”