Recent

Author Topic: A basic windows program shell?  (Read 879 times)

TBMan

  • Jr. Member
  • **
  • Posts: 69
A basic windows program shell?
« on: February 09, 2025, 05:44:37 pm »
I think I'm ready to start digging into using Windows more instead of ptcgraph. Is there a basic shell that I can use just to have an empty screen to do a simple "Hello World" then go on to using bitmaps for sprites? Thanks.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1199
    • Burdjia
Re: A basic windows program shell?
« Reply #1 on: February 12, 2025, 01:29:08 pm »
Both WriteLn and ReadLn works on Windows cmd and PowerShell.

Anyway, if you're going to do games you should try a Game framework or a Game Engine.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

TRon

  • Hero Member
  • *****
  • Posts: 4133
Re: A basic windows program shell?
« Reply #2 on: February 12, 2025, 02:36:43 pm »
The link to game-framework went a bit wrong try here.
Today is tomorrow's yesterday.

TBMan

  • Jr. Member
  • **
  • Posts: 69
Re: A basic windows program shell?
« Reply #3 on: February 12, 2025, 04:00:08 pm »
The link to game-framework went a bit wrong try here.

There has to be a way to do a plain empty window and load bitmaps, display them, set pixels, draw lines and circles etc. add a menu, etc without using the form designer.  I just need an example, and a reference manual and I'll be good. 

TRon

  • Hero Member
  • *****
  • Posts: 4133
Re: A basic windows program shell?
« Reply #4 on: February 12, 2025, 04:09:25 pm »
Yes, there are but there are many to choose from which is something you would have to decide for yourself.

One framework is better suited than another based on (your (game)) requirements.

Back in my day there was only one solution (or actually 2). a) use SDL or b) write your own graphics engine.

These days there is much to choose from. I am pretty impressed by raylib but that is because I haven't used any oldschool coding for quite some while now. SDL3 looks promising as well (is still a work in progress just seem to have had their first release).

Both can be used from FPC command-line, I honestly dunno about the others that are listed. Even BGRABitmap is capable of running with NoGUI (but that is focused on graphics only).

I would recommend to get yourself at least a little familiar with some of the mentioned engines, look at their website/examples and in case there is anything that peeks your interest investigate if it has everything on-board that you would like to use for your development (think audio, video playback, support for controllers, graphical GUI, support for GL etc). In case not sure ask questions if framework x supports feature y in case you really need it.

Use at least an engine/library that has good support and many examples that you are able to learn from.

PS: in case a library/engine is pro dominantly c then don't let yourself be put off by that, it is usually a 1:1 translation only the language differs (SDL and raylib are both a good example of that).
« Last Edit: February 12, 2025, 04:14:26 pm by TRon »
Today is tomorrow's yesterday.

Roland57

  • Hero Member
  • *****
  • Posts: 503
    • msegui.net
Re: A basic windows program shell?
« Reply #5 on: February 12, 2025, 04:41:07 pm »
Hello!

Not exactly what you asked for, but here is a Minesweeper clone using Windows unit, that I translated from a C source. And a Four-in-a-row, using Windows and Cairo.

You could learn many things from the WinGraph unit.
« Last Edit: February 12, 2025, 05:17:57 pm by Roland57 »
My projects are on Gitlab and on Codeberg.

440bx

  • Hero Member
  • *****
  • Posts: 5068
Re: A basic windows program shell?
« Reply #6 on: February 12, 2025, 04:47:59 pm »
I think I'm ready to start digging into using Windows more instead of ptcgraph. Is there a basic shell that I can use just to have an empty screen to do a simple "Hello World" then go on to using bitmaps for sprites? Thanks.

Excuse me for a little tooting of my own horn, here is an index of Windows API examples, the majority are simple, easy to understand and with an explanation of how they work.

https://forum.lazarus.freepascal.org/index.php/topic,52984.msg391444.html#msg391444

The index is incomplete (I have to update it and I always forget), additional entries which are missing are:

https://forum.lazarus.freepascal.org/index.php/topic,52984.msg391444.html#msg391444
https://forum.lazarus.freepascal.org/index.php/topic,53690.msg397423.html#msg397423
https://forum.lazarus.freepascal.org/index.php/topic,53791.msg398393.html#msg398393

That last one has the most basic bitmap handling.  I emphasize "basic". 

Also, if you don't mind reading C code, the ReactOS project re-implemented all (?) the games that were in WinXP.  Have a look at those for bitmap handling that goes beyond the basics.

HTH.


ETA:

Adding the index which I forgot to paste in the OP.
« Last Edit: February 12, 2025, 04:50:17 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8790
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: A basic windows program shell?
« Reply #7 on: February 12, 2025, 05:08:41 pm »
My suggestion is to go with GLFW, the empty "shell" program is just:
Code: Pascal  [Select][+][-]
  1. uses
  2.   glfw;
  3. var
  4.   LWindow: PGLFWwindow;
  5. begin
  6.   if glfwInit() = 0 then begin
  7.     Halt(1);
  8.   end;
  9.  
  10.   LWindow := glfwCreateWindow(640, 480, 'My Title', nil, nil);
  11.   if not Assigned(LWindow) then begin
  12.     glfwTerminate();
  13.     Halt(1);
  14.   end;
  15.  
  16.   while glfwWindowShouldClose(LWindow) = 0 do begin
  17.     glfwPollEvents();
  18.   end;
  19.  
  20.   glfwDestroyWindow(LWindow);
  21.   glfwTerminate();
  22. end.
  23.  
  24.  

TRon

  • Hero Member
  • *****
  • Posts: 4133
Re: A basic windows program shell?
« Reply #8 on: February 12, 2025, 05:22:31 pm »
You could learn many things from the WinGraph unit.
You are hopefully aware that wingraph (and friends) is a replacement for units crt, graph and keyboard (which is exactly the same as ptcgraph, ptccrt and ptckeyboard with the exception that the PTC units are cross-platform compatible and thus superseeds all these windows specific oldschool units) ?

Not to put down your answer but that is exactly what OP wants to move away from.
« Last Edit: February 12, 2025, 05:35:19 pm by TRon »
Today is tomorrow's yesterday.

Roland57

  • Hero Member
  • *****
  • Posts: 503
    • msegui.net
Re: A basic windows program shell?
« Reply #9 on: February 12, 2025, 06:28:27 pm »
@TRon

Yes, I know. I intended to say that the OP could take inspiration from the source code of the WinGraph unit, in order to make whatever he wants using Windows API (which is his goal, if I correctly understood).
My projects are on Gitlab and on Codeberg.

TBMan

  • Jr. Member
  • **
  • Posts: 69
Re: A basic windows program shell?
« Reply #10 on: February 12, 2025, 07:18:25 pm »
Hello!

Not exactly what you asked for, but here is a Minesweeper clone using Windows unit, that I translated from a C source. And a Four-in-a-row, using Windows and Cairo.

You could learn many things from the WinGraph unit.

Wingraph is good. I can learn a lot from it, thank you.




TRon

  • Hero Member
  • *****
  • Posts: 4133
Re: A basic windows program shell?
« Reply #11 on: February 12, 2025, 08:46:24 pm »
@roland57:
Fair enough. I thought you perhaps did not know. In that case please ignore my remark.
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018