OpenVG
オープンな2Dベクター描画の仕様。いくつも実装があるっぽい。
ajstarks/openvg
の実装が良いみたい。
前提としてRaspberryPiのGPU RAM設定が64MB以上になっている必要がある(デフォルト設定値は64MB)
1.インストールからコンパイルまで
git が入っているならリポジトリをクローンする。
$ git clone git://github.com/ajstarks/openvg
なければwgetでとってくる。
$ wget https://github.com/ajstarks/openvg/archive/master.zip $ unzip master.zip
以下、openvg-masterに解凍されたことを前提にする。
コインパイルにlibjpg8-devが必要なので予めインストールする。
$ sudo apt-get install libjpeg8-dev
コンパイルする。エラーが出ても、libshapes.o oglinit.oが生成されてればOK。
$ cd openvg-master $ make
付属のサンプルをコンパイルして実行。
$ cd client $ make test
幾つかの描画サンプルが表示される。なかなか描画が速い。
2.サンプル作ってビルドする
適当なフォルダに適当なソースを作る。
$ cd ~ $ mkdir test $ cd test $ vi test_vg.c
"hello, world"のソース。
// 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); }
コンパイルする。パス関係に注意。 .oファイル指定はフルパスじゃないとだめっぽい。
$ gcc -o test test_vg.c ~/openvg-master/libshapes.o ~/openvg-master/oglinit.o -I/opt/vc/include/ -I/opt/vc/include/interface/vcos/pthreads -I../openvg-master -L/opt/vg/lib/ -lGLESv2 -ljpeg
実行
~/test$ ./test
資料
View forum - OpenVG | Raspberry Pi
Raspberry Pi でUSBカメラ & 2D描画 OpenVG を使ってみる
日本語フォントの出力には苦労しそう。












