Recent

Author Topic: First Version Vector Toolkit in OpenGL  (Read 2524 times)

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
First Version Vector Toolkit in OpenGL
« on: October 31, 2021, 11:21:10 am »
If any of you read the fpc mailing lists you might have seen my message to that group regarding the announcement of a vector graphics and physics library I've been writing for FPC.

In a soon to published first release, I am taking a stab at designing a new user interface toolkit from scratch based on the vector graphics library rendered purely in OpenGL. Below is a video of my first test of this toolkit and I thought I'd share. Perhaps some of you may have some suggestions.

https://streamable.com/n42kll

Please bear in mind, this is meant to be a VERY minimal toolkit for the purpose of configuring or inputting settings in either game like programs or physics simulation programs. It includes a limited set of controls: windows, panels, sliders, push buttons, glyph buttons, check boxes, text entry, labels, image, and one custom paint control where you can draw whatever you want.

That said, everything is fully themeable and you can write or switch to different themes. The theme system manages the size of each control element, their visual representation, and the fonts and colors. It operates completely independent of the controls.

Layout is handled for you automatically by the container controls, window or panel, where children can be tiled horizontally, or vertically and placed near, center or far. Each control can have custom margins and containers can have custom size borders (space between controls and their four edges).

As mentioned before, this library will be released to a git repository soon with a FOSS license. It will be able to run on Windows, Mac, Linux, and Pi including the new Pi Zero 2 W.

If you're interested here are  a few more videos of the vector graphics system I am writing:

Text Paint
https://streamable.com/m4e4qn

Curtains
https://streamable.com/6o5y5o

Regarding the widget system, here is a snippet that may help you understand how it's meant to be used:

Code: Pascal  [Select][+][-]
  1.   // Create out widget system using a main widget with a theme
  2.   FWidget := TMainWidget.Create(DefaultTheme);
  3.   with FWidget.Add<TWindow>('about') do
  4.   begin
  5.     // You can change the theme anytime by assigning a different theme
  6.     // For example ... FWidget.Theme := OtherTheme
  7.     X := 10;
  8.     Y := 10;
  9.     Text := 'About';
  10.     // Window and panel have Fade properties to control their background
  11.     // surface opacity independent of child widget opacity
  12.     Fade := 0.25;
  13.     with This.Add<TGlyphImage>('icon') do
  14.       Text := '';
  15.     // Child widgets are arranged automatically by their container
  16.     with This.Add<TButton>('close') do
  17.     begin
  18.       Text := 'Close';
  19.       OnClick := CloseClick;
  20.     end;
  21.     // Widgets can be recalled later using FWidget.Find<Tlabel>('mouse')
  22.     with This.Add<Tlabel>('mouse') do
  23.       Text := 'Mouse move coordinates appear here';
  24.     // Widgets automatically grow to hold their content
  25.     with This.Add<TCheckBox>('option') do
  26.       Text := 'Use this option';


AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: First Version Vector Toolkit in OpenGL
« Reply #1 on: October 31, 2021, 11:58:42 am »
Looks interesting, congratulations.
A note: your code shows <TCheckbox>, <TLabel> and I hope these are not LCL Checkbox, Label.
Better add a prefix like "TVector".

sysrpl

  • Sr. Member
  • ****
  • Posts: 315
    • Get Lazarus
Re: First Version Vector Toolkit in OpenGL
« Reply #2 on: October 31, 2021, 12:24:41 pm »
@Alextp

This library, like my previous game library, is a minimal system based on SDL2 and OpenGL graphics. As such, there is no LCL Forms, Controls, or even classes unit. For this library I define my own system unit with a dotted namespace called:

Tiny.System

Other also included units with dotted namespaces are:

Tiny.Application, Tiny.Graphics, Tiny.Physics, Tiny.Widgets, and Tiny.Widgets.Themes

A program unit looks like this:

Code: Pascal  [Select][+][-]
  1. program Simulation;
  2.  
  3. uses
  4.   Tiny.Application;
  5.  
  6. begin
  7.   Application.Run(TScene);
  8. end.
  9.  

Where you can replace TScene with whatever scene, simulation, or game type your write. You will not be using LCL form or control units with this library, and as such there will not be a conflict or collision with LCL control names.

https://cache.getlazarus.org/videos/physics-joints.mp4

 

TinyPortal © 2005-2018