OpenGL

Anything and everything about programming graphics with Ultibo
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

OpenGL

Postby Gavinmc42 » Thu Sep 07, 2017 12:27 pm

Interesting things and possibilities?
ttps://www.raspberrypi.org/forums/viewt ... 2&t=192440
User avatar
Ultibo
Site Admin
Posts: 2079
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenGL

Postby Ultibo » Thu Sep 07, 2017 11:55 pm

Gavinmc42 wrote:Interesting things and possibilities?

Careful, it's a long road from drawing a triangle (which has been done by many others) to implementing anything useful for creating real applications ;)
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Fri Sep 08, 2017 2:26 am

Huge step up from drawing triangles.
Mostly linked this here to see if LdB gets any further than triangles and quads and to keep track of his progress.

Someone who really knows what they are doing might get more OpenGL type capability.
But that won't be me at my current rate of progress, not in my lifetime and I don't see the point anyway.
Just that I don't think it is not impossible now, just a low probability ;)

I suppose a big company could throw a lot of money and people at it if they thought it made good business sense.
Then things like this happen
https://eltechs.com/product/exagear-desktop/
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Thu Sep 14, 2017 8:49 am

LdB is getting close to baremetal 3D acceleration.
https://www.raspberrypi.org/forums/view ... 0&start=25

Should be interesting as there is only a few files it could be done via Zero USB booting :D
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Thu Sep 21, 2017 12:39 pm

Some of the stuff I do on Pi's has dial/gauges.
This is my first OpenVG program ever ;)
I will not embarrass myself by telling you how long it took to do something similar in Netbeans/JavaFX :oops:
Laz/FPC/Ultibo is fast to develop with, two hours with interruptions :lol: .
Time to rest the brain and do some light bedtime reading - OpenGL Game Programming ;)

Code: Select all

program Clock;

{$mode objfpc}{$H+}

{ VideoCore IV example - modified 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;

 OffsetX:VGfloat;
 OffsetY:VGfloat;

 SecOffsetX:VGfloat;
 SecOffsetY:VGfloat;

 Dotsize:VGfloat;

 Count:Integer;
 Seconds: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');
 
 {Initialize OpenVG and the VGShapes unit}
 VGShapesInit(Width,Height);

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

 Dotsize:=20;

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

 for Seconds:= 0 to 60 do
    begin
     {Circle}
     VGShapesStrokeWidth(3);
     VGShapesStroke(0,0,0,1);
     VGShapesFill(200,200,240,1);
     VGShapesCircle(CenterX,CenterY,Dialsize);

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

     {Draw labels for the name of each shape first}
     VGShapesFill(0,0,0,1);
     for Count:= 0 to 11 do
      begin

       OffsetX:= Dialsize / 2.3 * sin((Count * 30) * pi / 180 + pi / 6);
       OffsetY:= Dialsize / 2.3 * cos((Count * 30) * pi / 180 + pi / 6 ) - 10 ;

       VGShapesTextMid(CenterX + OffsetX, CenterY + OffsetY ,Dialnames[Count],VGShapesSansTypeface,Fontsize);
      end;
 
        {Line (Diagonal)}
         VGShapesStrokeWidth(1);
         VGShapesStroke(200,0,0,1);

         SecOffsetX:= Dialsize / 2.3 * sin((Seconds * 6) * pi / 180 );
         SecOffsetY:= Dialsize / 2.3 * cos((Seconds * 6) * pi / 180 );
         VGShapesLine(CenterX,CenterY,CenterX + SecOffsetX, CenterY + SecOffsetY);
         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: 2079
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenGL

Postby Ultibo » Fri Sep 22, 2017 12:03 am

Gavinmc42 wrote:This is my first OpenVG program ever ;)

Nice, I see you found the diagonal lines!
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Fri Sep 22, 2017 12:20 am

Yep, diagonal lines plus text at any size and as bonus I got circles and rounded rects :lol:

It is not the 3D dial overlays on video I can get with Netbeans and JavaFX yet.
Any idea how to overlay this stuff on the videos? Dispmanx?
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Fri Sep 22, 2017 12:41 am

AJ seems to have done some VG plotting in Go.
https://github.com/ajstarks/openvg/blob ... /vgplot.go

UI's and plotting just got much faster :D

Wonder if there is a way to use HTML/CSS/SVG tools to make UI/OpenVG and/or web pages.
That way local HDMI UI screens on Pi's look and are coded the same as the Web UI version?
Hmm that might be a way to do WebGL type viewing on Pi browsers?

Remote data viewers are things we have around the place.
I am using Raspbian and Chromium just to view temperature plots remotely over the network, massive overkill.
Just sending the changed OpenVG data will speed things up. Hmm socket based?

That could be handy for EV instrument clusters, using two wire Ethernet?
Well, that is my next few years of coding mapped out ;)
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Fri Sep 22, 2017 10:09 am

Must have been late this code should have gone in the OpenVG post :oops:
Gavinmc42
Posts: 1420
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenGL

Postby Gavinmc42 » Wed Jun 13, 2018 6:51 am

Been down with the flu for weeks so not much been going on coding wise.

Some OpenGLES stuff on a Pi post was interesting.
https://www.raspberrypi.org/forums/view ... 8&t=214695
Got me interested in figuring it out and it finally clicked.

https://www.raspberrypi.org/forums/view ... 4&t=188448
Someone more observant might have noticed that Gentoo64 screenshot has the mesa 3D glxgears demo running.
Just typing ./glxgears will run it, a find shows there is also glxinfo, eg2info etc.

Got a copy of latest mesa3d stuff and followed the introductions, guess what, it worked :D
https://www.mesa3d.org/install.html

One of the demos is a 3D terrain map fly around that seems to be Procedurally Generated?
Could be of use for the Ultibo Game posts ;)

What is interesting is this is Aarch64 bit 3D OpenGL code running on a Pi3B+.
That means there is a way Aarch64 ARMs can talk to the 32bit VC4.
Lucky these examples are in C which I know better than C++.

Converting to Pascal, 32bit on Raspbian, 64bit on Gentoo is now somewhere for me to start 3Ding.
So underneath everything there must be some VC4 OpenGL interface code?

Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 0 guests