Recent

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

Paul_

  • Full Member
  • ***
  • Posts: 143
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: 366
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.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

User137

  • Hero Member
  • *****
  • Posts: 1791
    • 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: 4449
    • https://lainz.github.io/
Re: Looking for lightweight GUI
« Reply #3 on: June 16, 2019, 03:38:07 am »
Great games build with FPC?

julkas

  • Guest
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).

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • 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: 143
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: 143
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

  • Hero Member
  • *****
  • Posts: 836
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 3.2 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on an acrade, action/adventure game in retro style (pixelart), programming the engine and shell from scratch, using Free Pascal and SDL. Release planned in 2026.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • 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: 4449
    • https://lainz.github.io/
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 »

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Looking for lightweight GUI
« Reply #11 on: August 19, 2019, 09:03:47 pm »
BTW I occasionally found that ImGui library have Pascal bindings.

https://github.com/ocornut/imgui/wiki/Bindings
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

Paul_

  • Full Member
  • ***
  • Posts: 143
Re: Looking for lightweight GUI
« Reply #12 on: August 20, 2019, 01:53:49 am »
ImGui is great, but it's designed rather for editors, tools and debug than for game purposes like menus, indicators, buttons with graphics and such things.

I checked some of code and later started writing my own GUI unit + LCL editor, probably the easiest solution. It's done in simple way, +- similar style as User137 code (NX).

From Pascal world is most advanced probably ZenGUI, what I found. With full exporter for events code (it generates unit).

« Last Edit: August 20, 2019, 02:00:36 am by Paul_ »

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: Looking for lightweight GUI
« Reply #13 on: August 20, 2019, 11:17:54 am »
ImGui is great, but it's designed rather for editors, tools and debug than for game purposes like menus, indicators, buttons with graphics and such things.
My (limited) knowledge about ImGui tells me you could use/write custom widgets for that purpose, but this will require C/C++.

Well, it's pity to admit game development world is not very Pascal-friendly.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

Paul_

  • Full Member
  • ***
  • Posts: 143
Re: Looking for lightweight GUI
« Reply #14 on: August 20, 2019, 05:33:09 pm »
My (limited) knowledge about ImGui tells me you could use/write custom widgets for that purpose, but this will require C/C++.

Maybe you're right. I saw only few skins for menu's. What especially discourageds me from ImGUI is that such libraries are native C++, then someone made C bindings and DLL's and after that someone made Pascal headers :) I'm enjoying this with SFML yet, can't debug DLL code.

Would be easier to use at least the C library like https://github.com/vurtun/nuklear and only translate headers. But it's funny because header have 26 000 lines of code or something like that.

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

If we return to this issue, how it's done in Lazarus IDE that it creates "event interface" code for components directly into the code in editor?
« Last Edit: August 20, 2019, 05:36:51 pm by Paul_ »

 

TinyPortal © 2005-2018