Recent

Author Topic: Looking for lightweight GUI  (Read 1148 times)

Paul_

  • Full Member
  • ***
  • Posts: 127
Looking for lightweight GUI
« on: June 14, 2019, 11:29:02 am »
I can't find any usefull Pascal GUI for games:

- simple structure, expandable

- the ability to easily overwrite the rendering function (e.g. for OpenGL)

- basic components set


sash

  • Sr. Member
  • ****
  • Posts: 252
Re: Looking for lightweight GUI
« Reply #1 on: June 14, 2019, 11:57:40 pm »
the ability to easily overwrite the rendering function (e.g. for OpenGL)

I fear this is near to impossible (to do it in optimal way).

Most GUI systems exists in context of particular rendering engine, because it is not simply "render rectangles to somewhere".
GUI depends on underlying infrastructure of base types and conventions, input, messages, resources, font rendering and again, rendering techniques.

So you'll end with your "independent GUI library" would be either very basic or will result of duplication of said infrastructure independently existing in engine/application.

I'd rather consider a use of complete engine with GUI.
Lazarus 2.0.2 FPC 3.0.4 x86_64-linux-gtk2 -- Ubuntu 19.04 XFCE

User137

  • Hero Member
  • *****
  • Posts: 1790
    • Nxpascal home
Re: Looking for lightweight GUI
« Reply #2 on: June 15, 2019, 12:38:33 pm »
Yeah a UI library shouldn't be directly calling graphics API such as OpenGL but a more higher level implementation of it. nxPascal has some kind of UI but it is a little tricky to link your own code to button clicks and other events. Because the editor is in no way linked to the actual app that uses it source code you can't directly assign the events in it, and it has to be done by code. But there is an example in the UITester\
https://github.com/Zaflis/nxpascal/tree/master/tools
Editor is in same place, and you can check what components are currently included by checking source code:
https://github.com/Zaflis/nxpascal/blob/master/src/nxUI.pas
It goes as far as letting you drag windows with mouse, and you can completely customize them with any images you like, even partially transparent pngs and possible custom after-effects. Scaling with form size, keeping pixel perfectness with fonts and so on are taken care of. I still only considered it work-in-progress, although you can do a whole lot with it already it want to.

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Looking for lightweight GUI
« Reply #3 on: June 16, 2019, 03:38:07 am »
Great games build with FPC?

julkas

  • Full Member
  • ***
  • Posts: 160
  • KISS principle
Re: Looking for lightweight GUI
« Reply #4 on: June 16, 2019, 03:27:03 pm »
Good question.
My own experience with games - DOOM  port for i3micro STB (C code  :D).
Lazarus 2.0.0 / FPC 3.0.4
----------------------------
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 907
    • Burdjia
Re: Looking for lightweight GUI
« Reply #5 on: June 18, 2019, 11:23:40 am »
Great games build with FPC?
Not sure they're great, but there are a few. Also, a few of us are trying to improve and expand this section*. :)
_______________________

* Unfortunatelly for me, I have not much time so I'm working too slowly.  :(
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Paul_

  • Full Member
  • ***
  • Posts: 127
Re: Looking for lightweight GUI
« Reply #6 on: June 19, 2019, 10:23:55 am »
Yeah a UI library shouldn't be directly calling graphics API such as OpenGL but a more higher level implementation of it. nxPascal has some kind of UI but it is a little tricky to link your own code to button clicks and other events. Because the editor is in no way linked to the actual app that uses it source code you can't directly assign the events in it, and it has to be done by code.

All what I need is some good OOP structure, in case of GUI it can be bit problematic and complex. Yes, events must be hardcoded, but I suppose it's normal for games.

I have done it "simply" in the current code - pointer to procedure:

Code: Pascal  [Select]
  1.   TGUI_Element = class
  2.     private
  3.       OnClick_proc        : procedure;
  4.  
  5.     public
  6.       procedure RegisterOnClick(p: pointer);
  7.  
  8.       procedure OnClick; virtual; abstract;
  9.   end;  
  10.  
  11. procedure TGUI_Element.RegisterOnClick(p: pointer);
  12. begin
  13.   pointer(onClick_proc) := p;
  14. end;
  15.  
  16. ..
  17.  
  18. TGUI_Button = class ( TGUI_Element )
  19. public
  20.   procedure onClick; override;  
  21.  
  22.   pressed     : Boolean;
  23. end;            
  24.  
  25. procedure TGUI_Button.onClick;
  26. begin
  27.   if assigned( onClick_proc ) and pressed then onClick_proc;
  28. end;  
  29.  
  30. ..
  31.  
  32. // In program
  33.  
  34. Var
  35.   Button : TGUI_Element;
  36.  
  37. procedure SomeProcedure;
  38. begin
  39.   Writeln('Test');
  40. end.
  41.  
  42. begin
  43.   Button.RegisterOnClick( @SomeProcedure );
  44. ..
  45.  

Although it is clear that clarity is gradually decreasing.

Paul_

  • Full Member
  • ***
  • Posts: 127
Re: Looking for lightweight GUI
« Reply #7 on: June 19, 2019, 10:25:19 am »
Great games build with FPC?

My game will be "great" :)

furious programming

  • Sr. Member
  • ****
  • Posts: 349
  • I click a little.
Re: Looking for lightweight GUI
« Reply #8 on: June 19, 2019, 11:00:09 am »
Don't forget about my Deep Platformer — it is still under development! 8)
Lazarus 2.0.2 with FPC 3.0.4, Windows XP (all 32-bit)

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 907
    • Burdjia
Re: Looking for lightweight GUI
« Reply #9 on: June 19, 2019, 11:01:12 am »
I forgot: my MinGRo game engine has a semi-complex GUI system.  The engine is still in alpha but the GUI is quite stable and I doubt it will change a lot.  I'm using Allegro (not WinAPI/XWindow) but you can see how it works and compare with your ideas.

You can take a peek here, at SVN (was rewritten from scratch since the last release so do not download the package), the files that start with "mnggui...".  You have the example here, and an actual use in the map editor.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

lainz

  • Hero Member
  • *****
  • Posts: 3139
    • Lainz
Re: Looking for lightweight GUI
« Reply #10 on: June 20, 2019, 06:29:04 pm »
I as well did games with Lazarus, small ones but I learned the basics of tilemap and tileset with it, and basic physics.
https://github.com/bgrabitmap/bgragames

Unfortunately none of these has GUI, so is not usefull for the original question.
« Last Edit: June 20, 2019, 06:31:44 pm by Lainz »