Page 1 of 1

Recommendation for an alternative to OpenVG for RP4

Posted: Fri Aug 02, 2019 3:53 am
by rainier
Hi All,

Anyone have a recommendation for an alternative to OpenVG? I heard it is no longer supported on RP4.

I'm looking for a library which takes over the frame buffer for 2G graphics on the RP4?

Kind regards,

--andrew

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Wed Aug 07, 2019 1:11 pm
by blackshard83
It is really not supported? It should be supported as long as the broadcom proprietary EGL/OpenGLES/OpenVG libraries are still supported. Look that the proprietary libraries don't work in X, they are supposed to work exclusively on a dispmanx layer.

If you're using the opensource OpenGL driver (thus you have X acceleration), you don't get OpenVG.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Wed Aug 07, 2019 1:36 pm
by jamesh
On the Pi4, the only 3D that works is the new Mesa driver. So even in legacy mode, I don't think you get OpenVG (since that is closely related), but will need to check.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Wed Aug 07, 2019 2:18 pm
by 6by9
jamesh wrote:
Wed Aug 07, 2019 1:36 pm
On the Pi4, the only 3D that works is the new Mesa driver. So even in legacy mode, I don't think you get OpenVG (since that is closely related), but will need to check.
You don't.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Wed Aug 07, 2019 9:04 pm
by jdonald
Answering the OP's question: SDL2 might do it, specifically the SDL2_gfx API. Install libgbm-dev and configure SDL2 with --enable-video-kmsdrm --disable-video-x11 --disable-video-rpi. Not full-fledged vector graphics but may have all the primitives sufficient for your use-case.

I am guessing SDL2_gfx's curves aren't GPU-accelerated. If you require such then the obvious option is libgbm + GLES.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Thu Aug 08, 2019 1:53 am
by Gavinmc42
Use something like this?
https://www.amanithvg.com/

Is there an open source equivalent?

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Thu Aug 08, 2019 2:41 am
by Gavinmc42
Don't have my Pi4 here.
In the mesa-demos-8.4.0 src folder is an egl folder, in there is oes_vg and openvg folders.
Might be worth looking at them.
I will be now that I found them :D

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Thu Aug 08, 2019 7:29 pm
by jdonald
Gavinmc42 wrote:
Thu Aug 08, 2019 2:41 am
In the mesa-demos-8.4.0 src folder is an egl folder, in there is oes_vg and openvg folders.
According to GitHub those examples haven't been updated in 8+ years, so would likely fail to account for OpenVG getting stripped from Mesa in 2015.
Gavinmc42 wrote:
Thu Aug 08, 2019 1:53 am
https://www.amanithvg.com/ Is there an open source equivalent?
incognitum pointed out these two incomplete implementations in an earlier topic:
LGPL licensed on top of standard OpenGL: https://github.com/ileben/ShivaVG
BSD licensed on top of OpenGL ES: https://github.com/micahpearlman/MonkVG

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Fri Aug 09, 2019 3:06 am
by Gavinmc42
Yep I had run into Shiva and Monk but with Ultibo and OpenVG I had no need for them.
But I have no idea how Ultibo and AJStarks do that OpenVG magic either.

Now how do I do OpenVG on a Pi4?

Without a VC6 manual I cannot check to see if the VG primitives still exist?
Control codes ID 41, 42.
I'm pretty sure GL and NV exist, not sure if VG mode does.
I can barely understand a few pages of the VC4 manual anyway ;)

If they are still there then OpenVG is still usable?
Lots still to learn

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Sat Aug 10, 2019 4:47 pm
by aire39
nanovg. This seems to be a nice library that is similar to openvg but uses opengles 2 or 3 for its rendering backend and actually got it to work.

I'm still messing with it as I'm not sure what actually limitations it might have. The project isn't being maintained anymore as well but last bit of activity was about 11 months ago before which is fine for me.

I could see this as potential replacements alongside the ones mentioned above:
cairo-gl - where it can use opengl as it's render backend (supposedly works but can't find a decent example).

I also looked at blend2d but that seems to be a pure cpu solution and and focuses on desktop cpus to be able use avx and sse3. It could potentially support arm neon instruction eventually but it's still and beta and doesn't seem to be a focus at the moment.

I plan to try my luck with nanovg.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Sun Aug 11, 2019 12:23 am
by Gavinmc42
Nice find.
Looks like OpenGL and GLES so it should run on all Pi's.
Can that be used without X11?

Even old stuff can still be relevant for OpenVG as it's old too ;)

After seeing what can be done with shader code on Pi4 perhaps OpenVG done by shaders?
Crazy or possible?

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Mon Aug 12, 2019 4:42 am
by aire39
Gavinmc42 wrote:

Looks like OpenGL and GLES so it should run on all Pi's.
Can that be used without X11?

It seems like nanovg may be able to work with all pi though I would probably use a pi 2 and up. It also works fine without X11. I'm using it now to create an overlay without using X11.
Gavinmc42 wrote:

After seeing what can be done with shader code on Pi4 perhaps OpenVG done by shaders?

Nanovg uses a shader that was coded into the source code as a string that's used to render all the shapes. You can find that shader under the src/nanovg_gl.h file line 503.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Mon Aug 12, 2019 5:17 am
by Gavinmc42
Nanovg uses a shader that was coded into the source code as a string that's used to render all the shapes.
That's cool, but another language to learn ;)

OpenCL is supposed to work now and someone said there are compute shaders.
Probably many ways to skin this cat.

Just ordered my second Pi4 so I can code on one, test on the other.

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Fri Aug 16, 2019 3:24 pm
by rainier
Hi All,

Thanks for the all the information.

Great if nanovg actually works. Has anyone tested this out on the RP4 multiple displays? Also can someone confirm they have actually got this really working on a RP4 & Buster? And even better record the runes to get it to work?

This information would reduce lots of duplication of effort.

Kind regards,

--andrew

Re: Recommendation for an alternative to OpenVG for RP4

Posted: Tue Aug 20, 2019 7:55 pm
by aire39
rainer wrote:

Great if nanovg actually works. Has anyone tested this out on the RP4 multiple displays? Also can someone confirm they have actually got this really working on a RP4 & Buster? And even better record the runes to get it to work?

Yes, nanovg works. I'm using it in my own project to draw overlays. I found that premake4.lua didn't work for me. I did initially compile it manually with gcc and ar and eventually decided to created a cmakelists.txt file to generate the lib file instead.

I didn't create a cmakelists.txt file for the examples and instead compiled them manually using gcc after creating the nanovg lib file. It was just to make sure it worked.

This was all done on a pi 4 using buster.

Code: Select all

#CMakeLists.txt : located in nanovg root directory
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

project("nanovg")

# add include paths
include_directories(${PROJECT_SOURCE_DIR})

# set nanovg sources
set (NANOVG_SOURCE
     src/nanovg.c)

add_library (nanovg STATIC
             ${NANOVG_SOURCE})

target_include_directories(nanovg PUBLIC
                           ${CMAKE_CURRENT_SOURCE_DIR}/src)

Code: Select all

#build_examples.sh : located in nanovg root directory
mkdir -p build/examples && cd build/examples

for entry in `ls ../../example/*.c`; do
    entry_name=`echo "$entry" | awk -F"/" '{print substr($0, length($0)+1-length($NF))}' | rev | awk -F"." '{print substr($0,length($0)+1-length($NF))}' | rev`
    #echo "$entry_name"
    gcc "$entry" ../../example/demo.c ../../example/perf.c -I../../example -I../../src -L../../ -L.. -lnanovg -lm -lEGL -lGL -lglfw -o "$entry_name"
done