OpenVG- baremetal VG

Anything and everything about programming graphics with Ultibo
pik33
Posts: 608
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: OpenVG- baremetal VG

Postby pik33 » Wed Jul 05, 2017 7:17 am

Now - Bingo! - there are video scaler registers described there along with their addresses.
User avatar
Ultibo
Site Admin
Posts: 1549
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Wed Jul 05, 2017 8:18 am

Gavinmc42 wrote:Is this the best place to put it?

Thank you, I've added it to the Resources page on the Wiki as well.

I've seen it before but it is an easy one to overlook because it isn't referenced from many other places.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Wed Jul 05, 2017 10:55 am

Seen plenty of stuff before, I skip over it because it does not mean much at the time :oops:
I keep circling around to stuff I was thinking about last year, but this year I am one step closer.

Anyway, code is is working, thanks Garry.
IDENT0 - 2 all match

V3D_IDENT1 is interesting, never noticed but it gives the number of TMUs/QPUs etc.
12 QPU's ;)

Should make this one a register dump shell extension for remote debugging etc.

video scaler ?
glad is makes sense to you pik33 ;)
Automatic hardware display scaling?
pik33
Posts: 608
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: OpenVG- baremetal VG

Postby pik33 » Wed Jul 05, 2017 12:46 pm

I am searching for information about the video scaler unit after I read that this unit reads a list of rectangles, then rescales it and displays on the screen. Now imagine that these rectangles are windows. Hardware accelerated windows without even touching a QPU; HVS is independent unit. QPU can then draw 3D stuff on these windows.

In Raspbian you can start the omx player and it displays the movie as an overlay on top of X screen. I don't know if I think right, but then I think the omxplayer decodes the video using hardware x264 block, then gives the rectangle to HVS, which then resizes it and displays on top of X screen.
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Thu Jul 06, 2017 1:00 am

HVS- Hardware Vector Scaler?
Yep I can imagine why that would be useful now that you explained it.

If I find anything else I will stick it in another post.
Probably any VC4 hardware block should have it's own post subject.
Makes it easier to find.
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Fri Sep 22, 2017 11:03 am

Gerrit's Steel Series was the best JavaFX gauges I have come across and his new Medusa is even better
https://github.com/HanSolo/Medusa

With JavaFX losing support I had starting looking at SVG and have yet to find anything as good.

See OpenVG code posted in OpenGL by mistake
viewtopic.php?f=15&t=815
For my next trick I will attempt to emulate Gerrit's Medusa industrial clock
https://github.com/HanSolo/Medusa/blob/ ... ckSkin.png

Does anyone else find it strange in this digital world analog dials are still a round?

Collecting info for LCARS next :lol:
http://www.lcars47.com/
In web speak LCARS is a flat UI design, you now find this in latest phones as 3D UI's are now dated :o
Latest version Raspberry webpage , MS Metro Windows 8 etc

Strange how a UI from the 60's is regarded as modern.
Modern, Rich, Skeuomorph, did not know what that last one was called
https://en.wikipedia.org/wiki/Skeuomorph
But I am guilty of doing it :lol:
viewtopic.php?f=10&t=144&p=427&hilit=povray#p427

Anyway what does this mean?
Well Flat UI's' are regards as modern or timeless, they also happen to be simpler :D
Flat UI's are a perfect use for OpenVG :D

Wonder how long CBS can hold the copyright for LCARS/Tricorder?
PADD made with a Zero? http://memory-alpha.wikia.com/wiki/PADD
The kid's tablet is on it's last legs, suspected battery failing.
Time to design a Ultibo PADD with normal replaceable cells?
What video codec is youtube :lol:
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Fri Sep 22, 2017 1:50 pm

Still somethings to sort out.
How to do stroke round end caps on lines, this would round the minute and hours hands?

There does not seem to be a round option for the end capstyle?
Or is it set to default?

Code: Select all

procedure VGShapesStrokeWidth(width:VGfloat);
{StrokeWidth sets the stroke width}
begin
 {}
 vgSetf(VG_STROKE_LINE_WIDTH,width);
 vgSeti(VG_STROKE_CAP_STYLE,VG_CAP_BUTT);
 vgSeti(VG_STROKE_JOIN_STYLE,VG_JOIN_MITER);
end;



Code: Select all

program IndustrialClock;

{$mode objfpc}{$H+}

{ VideoCore IV example - OpenVG Shapes Demo                                           }

uses
  RaspberryPi, {Include RaspberryPi2 to make sure all standard functions are included}
  GlobalConst,
  GlobalTypes,
  Threads,
  Console,
  SysUtils,
  OpenVG,       {Include the OpenVG unit so we can use the various types and structures}
  VGShapes,     {Include the VGShapes unit to give us access to all the functions}
  VC4;          {Include the VC4 unit to enable access to the GPU}

var
 Width:Integer;  {A few variables used by our shapes example}
 Height:Integer;

 CenterX:VGfloat;
 CenterY:VGfloat;
 Dialsize:VGfloat;

 startickX:VGfloat;
 startickY:VGfloat;
 stoptickX:VGfloat;
 stoptickY:VGfloat;

 min5stroke:VGfloat;
 minstroke:VGfloat;

 handOffsetX:VGfloat;
 handOffsetY:VGfloat;
 secOffsetX:VGfloat;
 secOffsetY:VGfloat;

 secDotsize:VGfloat;
 minDotsize:VGfloat;

 sechandwidth:VGfloat;
 minhandwidth:VGfloat;
 hourhandwidth:VGfloat;

 Count:Integer;
 Countmin:Integer;

 clkHours:Integer;
 clkMinutes:Integer;
 clkSeconds:Integer;

 Fontsize:Integer;
 
 WindowHandle:TWindowHandle;
 
const
 {The names of dial text}
 Dialnames:array[0..11] of String = (
  '1',
  '2',
  '3',
  '4',
  '5',
  '6',
  '7',
  '8',
  '9',
  '10',
  '11',
  '12');
 

begin
 {Create a console window as usual}
 WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);

 ConsoleWindowWriteLn(WindowHandle,'Starting VGShapes Demo');


 {We have ported the libShapes library created by A J Starks to Ultibo so you can easily use
  all of the functionality it provides. You can find out more about libShapes and what it can
  do by visiting the GitHub repository at:
 
  https://github.com/ajstarks/openvg

  Industrial Clock from Hansolo Medusa
  https://github.com/HanSolo/Medusa

  To get you started this example and the previous one show some of the basics}
 
 {Initialize OpenVG and the VGShapes unit}
 VGShapesInit(Width,Height);

 {Calculate some default values based on the size of the screen, remember that
  OpenVG coordinates put 0,0 at the bottom left NOT the top left like most other
  things}

 CenterX:=Width / 2;
 CenterY:=Height / 2;
 Dialsize:=Height / 3;

 min5stroke:= 8;
 minstroke:= 4;

 secDotsize:=3;
 minDotsize:=15;

 sechandwidth:=4;
 minhandwidth:=10;
 hourhandwidth:=10;

 Fontsize:=Trunc(Height * 0.02);
 
 {Start a picture the full width and height of the screen}
 VGShapesStart(Width,Height);

 {Make the background black}
 VGShapesBackground(153,204,255);

 for clkSeconds:= 0 to 60 do
    begin
     {Circle}
     VGShapesStrokeWidth(7);
     VGShapesStroke(0,0,0,1);
     VGShapesFill(255,255,255,1);
     VGShapesCircle(CenterX,CenterY,Dialsize);

     VGShapesFill(0,0,0,1);
     VGShapesStroke(0,0,0,1);
     VGShapesStrokeWidth(minstroke);

     for Countmin:= 0 to 60 do
      begin

       startickX:= Dialsize / 2.4 * sin((Countmin * 6) * pi / 180 + pi / 6);
       startickY:= Dialsize / 2.4 * cos((Countmin * 6) * pi / 180 + pi / 6 ) ;

       stoptickX:= Dialsize / 2.1 * sin((Countmin * 6) * pi / 180 + pi / 6);
       stoptickY:= Dialsize / 2.1 * cos((Countmin * 6) * pi / 180 + pi / 6 ) ;

       VGShapesLine(CenterX  + startickX, CenterY + startickY,CenterX + stoptickX, CenterY + stoptickY);

      end;


     for Count:= 0 to 11 do
      begin

       startickX:= Dialsize / 2.8 * sin((Count * 30) * pi / 180 + pi / 6);
       startickY:= Dialsize / 2.8 * cos((Count * 30) * pi / 180 + pi / 6 ) ;
       stoptickX:= Dialsize / 2.1 * sin((Count * 30) * pi / 180 + pi / 6);
       stoptickY:= Dialsize / 2.1 * cos((Count * 30) * pi / 180 + pi / 6 ) ;

       VGShapesStrokeWidth(min5stroke);
       VGShapesLine(CenterX  + startickX, CenterY + startickY,CenterX + stoptickX , CenterY + stoptickY);

      end;

     VGShapesStroke(0,0,0,1);
     VGShapesFill(0,0,0,1);
     VGShapesCircle(CenterX,CenterY,minDotsize);

     //hours
     clkHours:= 1;
     VGShapesStrokeWidth(hourhandwidth);
     VGShapesStroke(0,0,0,1);
     handOffsetX:= Dialsize / 4 * sin((clkHours * 30) * pi / 180 );
     handOffsetY:= Dialsize / 4 * cos((clkHours * 30) * pi / 180 );
     VGShapesLine(CenterX , CenterY, CenterX + handOffsetX, CenterY + handOffsetY);

     //minutes
     clkMinutes:= 1;
     VGShapesStrokeWidth(minhandwidth);
     VGShapesStroke(0,0,0,1);
     handOffsetX:= Dialsize / 3 * sin((clkMinutes * 6) * pi / 180 );
     handOffsetY:= Dialsize / 3 * cos((clkMinutes * 6) * pi / 180 );
     VGShapesLine(CenterX , CenterY, CenterX + handOffsetX, CenterY + handOffsetY);

     //Seconds:= 0 ;

     VGShapesStroke(200,0,0,1);
     VGShapesFill(200,0,0,1);
     VGShapesCircle(CenterX,CenterY,secDotsize);

     VGShapesStrokeWidth(sechandwidth);

     secOffsetX:= Dialsize / 3 * sin((clkSeconds * 6) * pi / 180 );
     secOffsetY:= Dialsize / 3 * cos((clkSeconds * 6) * pi / 180 );
     handOffsetX:= Dialsize / 12 * sin((clkSeconds * 6) * pi / 180 );
     handOffsetY:= Dialsize / 12 * cos((clkSeconds * 6) * pi / 180 );

     VGShapesLine(CenterX , CenterY, CenterX + secOffsetX, CenterY + secOffsetY);
     VGShapesLine(CenterX, CenterY, CenterX - handOffsetX, CenterY - handOffsetY);

     Sleep(1000);


 {End our picture and render it to the screen}
 VGShapesEnd;
 end;

 {Sleep for 10 seconds}
 Sleep(20000);
 
 {Clear our screen, cleanup OpenVG and deinitialize VGShapes}
 VGShapesFinish;
 
 {VGShapes calls BCMHostInit during initialization, we should also call BCMHostDeinit to cleanup}
 BCMHostDeinit;
 
 ConsoleWindowWriteLn(WindowHandle,'Completed VGShapes Demo');
 
 {Halt the main thread here}
 ThreadHalt(0);
end.
User avatar
Ultibo
Site Admin
Posts: 1549
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Mon Sep 25, 2017 1:41 am

Gavinmc42 wrote:There does not seem to be a round option for the end capstyle?
Or is it set to default?

By my reading of OpenVG.pas the VG_CAP_ROUND option would seem to be exactly what you want,

Code: Select all

 vgSeti(VG_STROKE_CAP_STYLE,VG_CAP_ROUND);

I haven't tried it so maybe there is some reason why it is not supported but it seems to be intended for that purpose.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Sep 25, 2017 2:20 am

Yep, that is what I thought too, I tried something like.
I might have had the syntax wrong but when I tried it nothing happened :(
It did compile so it could not have been too wrong, close but no cigar?
Will try your version.
Gavinmc42
Posts: 1053
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Sep 25, 2017 7:48 am

Looking at Videocore manual endcaps not supported.
So it must be up a layer in OpenVG, implemented in software?
AJ got it wrong and it is not supported?
Khronos Quick Ref Card shows VG_CAP_BUTT is default.
Probably a way to change parameters, google time

Looking at the Tiger example, the cap and join styles are changed on the fly.
Important for the other stuff that needs to change, dash patterns etc.
Might try some dashed lines to see if that works.

Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 1 guest