needs a little help.. lazarus / 31-LCL ---------------------------------------------------------------------- Flaze07 · 2017-07-03 14:37 hi so in order to make a gui app which option should I choose ?? when I try to Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses Graphics;  in simple programs; it errors ---------------------------------------------------------------------- Thaddy · 2017-07-03 14:47 You should simply start up lazarus and choose File|New|Application. You can also write GUI apps in FPC itself, but that is definitely not for beginners. You have to do everything by hand and it becomes very complex very quickly. With Lazarus it is as easy as the above. ---------------------------------------------------------------------- Handoko · 2017-07-03 14:57 These simple tutorials will be provide some good starts: http://wiki.lazarus.freepascal.org/Lazarus_Tutorial https://devstructor.com/index.php?page=tutorials For beginners who just started to learn Pascal: http://www.pascal-programming.info/index.php http://www.taoyue.com/tutorials/pascal/index.html Some cools Pascal tricks: http://lazplanet.blogspot.co.id/ Here has a list of tutorials with wide range of topics (graphics, database, printer, web, etc): http://wiki.freepascal.org/Lazarus_Documentation#Lazarus.2FFPC_.28Free _Pascal.29 Must bookmark: https://freepascal.org/docs-html/current/ref/ref.html ---------------------------------------------------------------------- RAW · 2017-07-03 14:59 Found this some time ago... (Windows only): Runs fine and fast...  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {  Copyright (c) 1996 by Charlie Calvert  Modifications by Florian Klaempfl   Standard Windows API application written in Object Pascal.  No VCL code included. This is all done on the Windows API  level.} {$APPTYPE GUI}{$MODE DELPHI}program WinHello; uses  Windows; const  AppName = 'WinHello'; function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;                    LParam: LPARAM): LRESULT; stdcall; export;   var     dc : hdc;     ps : paintstruct;     r : rect; begin  WindowProc := 0;   case AMessage of    wm_paint:      begin         dc:=BeginPaint(Window,@ps);         GetClientRect(Window,@r);         DrawText(dc,'Hello world by Free Pascal',-1,@r,           DT_SINGLELINE or DT_CENTER or DT_VCENTER);       EndPaint(Window,ps);         Exit;      end;    wm_Destroy:      begin         PostQuitMessage(0);         Exit;      end;  end;   WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);end;  { Register the Window Class }function WinRegister: Boolean;var  WindowClass: WndClass;begin  WindowClass.Style := cs_hRedraw or cs_vRedraw;  WindowClass.lpfnWndProc := WndProc(@WindowProc);  WindowClass.cbClsExtra := 0;  WindowClass.cbWndExtra := 0;  WindowClass.hInstance := system.MainInstance;  WindowClass.hIcon := LoadIcon(0, idi_Application);  WindowClass.hCursor := LoadCursor(0, idc_Arrow);  WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);  WindowClass.lpszMenuName := nil;  WindowClass.lpszClassName := AppName;   Result := RegisterClass(WindowClass) <> 0;end;  { Create the Window Class }function WinCreate: HWnd;var  hWindow: HWnd;begin  hWindow := CreateWindow(AppName, 'Hello world program',              ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,              cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);   if hWindow <> 0 then begin    ShowWindow(hWindow, CmdShow);    ShowWindow(hWindow, SW_SHOW);    UpdateWindow(hWindow);  end;   Result := hWindow;end; var  AMessage: Msg;  hWindow: HWnd; begin  if not WinRegister then begin    MessageBox(0, 'Register failed', nil, mb_Ok);    Exit;  end;  hWindow := WinCreate;  if longint(hWindow) = 0 then begin    MessageBox(0, 'WinCreate failed', nil, mb_Ok);    Exit;  end;   while GetMessage(@AMessage, 0, 0, 0) do begin    TranslateMessage(AMessage);    DispatchMessage(AMessage);  end;  Halt(AMessage.wParam);end. ---------------------------------------------------------------------- Thaddy · 2017-07-03 15:36 Yeah, we started off with that in TP7.... Charlie also wrote it in Pascal... Anyway if you positively absolutely have to you can "simply" do this with the fpc editor (DON'T DO THIS!) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program sanslazaruside;{$mode objfpc}{$H+}uses  Interfaces, Forms;  // no res file needed...type  TForm1 = class(TForm)  end; var  Form1: TForm1; begin  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Form1.Caption := 'GUI Application created from code';  Form1.SetBounds(100,100,700,500);  Application.Run;end. You have to set a lot of the correct paths, but it works. Plz just use lazarus, File|New|Application. You will be a lot happier.... And you need Lazarus units installed anyway. ---------------------------------------------------------------------- jc99 · 2017-07-03 16:42 Quote from: Thaddy on July 03, 2017, 05:36:50 pmPlz just use lazarus, File|New|Application. You will be a lot happier.... And you need Lazarus units installed anyway. Definitely +1 (more +10) a smaller start (assuming we're on windows) is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program PrjHelloWorld;{$apptype gui}uses windows;begin  MessageBox(0,'Hello World','Greetings',0);end.But that is just a Messagebox, no Application. As Thaddy said: Please use/start with Lazarus ... ---------------------------------------------------------------------- Thaddy · 2017-07-03 17:09 It is not even cross platform, this  is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program sanslazarus;{$mode objfpc}{$H+}uses Interfaces,Dialogs;begin ShowMessage('Hello, there');end. ---------------------------------------------------------------------- Flaze07 · 2017-07-03 17:11 Thank you for the advice  So pascal is the first programming language I understand (tried to learn C++ on the web, understood nothing) Anyways so Class is like Java's class (pointer )and Object is like C++'s class (no pointer), am I right ? And because I kinda dislike memory management (before I knew object I still do it , just afraid there might me memory leak ) should I use object ? P.S win api is awesome I made several console aplication game using it ---------------------------------------------------------------------- jc99 · 2017-07-03 17:23 Quote from: Thaddy on July 03, 2017, 07:09:34 pmIt is not even cross platform, this  is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program sanslazarus;{$mode objfpc}{$H+}uses Interfaces,Dialogs;begin ShowMessage('Hello, there');end. No, it has to look like : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program PrjHelloWorld3;{$mode objfpc}{$H+}uses Interfaces,Dialogs,forms;begin Application.Initialize; ShowMessage('Hello, there');end. And you have to import LCL, but you're right, that's cross platform ... otherwise you get : Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Failed to create win32 control, error: 1407 : Fensterklasse wurde nicht gefunden.[FORMS.PP] ExceptionOccurred  Sender=Exception  Exception=Failed to create win32 control, error: 1407 : Fensterklasse wurde nicht gefunden.  Stack trace:  $00000001001476F3  $000000010015D63C  $0000000100103FEE  $00000001000E269F  $00000001000E89A3  $00000001000E99CA  $00000001001036A1  $0000000100104C08  $00000001000F51C0  $000000010009AAB7  $000000010009A8CD  $000000010001801C  $0000000100017E86  $00000001000188F5  $0000000100024EF7  $00000001000DFD88  $00000001000A45BATApplication.HandleException Failed to create win32 control, error: 1407 : Fensterklasse wurde nicht gefunden.  Stack trace:  $00000001001476F3  $000000010015D63C  $0000000100103FEE  $00000001000E269F  $00000001000E89A3  $00000001000E99CA  $00000001001036A1  $0000000100104C08  $00000001000F51C0  $000000010009AAB7  $000000010009A8CD  $000000010001801C  $0000000100017E86  $00000001000188F5  $0000000100024EF7  $00000001000DFD88  $00000001000A45BAException at 00000001001476F3: Exception:Failed to create win32 control, error: 1407 : Fensterklasse wurde nicht gefunden. ---------------------------------------------------------------------- Thaddy · 2017-07-03 19:31 Probably only on Windows. Works like a charm on Linux. ---------------------------------------------------------------------- jc99 · 2017-07-03 19:37 Quote from: Thaddy on July 03, 2017, 09:31:38 pmProbably only on Windows. Works like a charm on Linux. So much on crossplatform ... What's the size of the bin on linux ? On windows its about 2.2M. BWT the win only has about 44K. ---------------------------------------------------------------------- RAW · 2017-07-03 23:44 QuoteBWT the win only has about 44K. Yes, really nice ... 43,5 k.. (x64: 1,5 MB RAM) BTW: compiles fine with {$MODE OBJFPC}{$H+}{$J-}... I'm curious who will win the RAM-Game: WIN-API, KOL, fpGUI, MSE-IDE, LLCL... Never really did that test.. nowadays nobody seems to care about that (of course), but it's interesting.. ---------------------------------------------------------------------- Flaze07 · 2017-07-04 05:21 I think I got it wrong so the lcl is a gui library... does that means it is unlike C++'s sfml ?? ---------------------------------------------------------------------- Flaze07 · 2017-07-04 07:27 so I need TCanvas to make something like C++'s sfml can make ? ---------------------------------------------------------------------- Ñuño_Martínez · 2017-07-04 07:49 Quote from: Flaze07 on July 03, 2017, 07:11:23 pmThank you for the advice  So pascal is the first programming language I understand (tried to learn C++ on the web, understood nothing) That's the point.  C++ is one of the worst languages to start with. Quote from: Flaze07 on July 03, 2017, 07:11:23 pmAnyways so Class is like Java's class (pointer )It is a simplification, but yes, it is. Quote from: Flaze07 on July 03, 2017, 07:11:23 pmand Object is like C++'s class (no pointer), am I right ?Again, it is a simplification, but yes, you are. Quote from: Flaze07 on July 03, 2017, 07:11:23 pmAnd because I kinda dislike memory management (before I knew object I still do it , just afraid there might me memory leak ) should I use object ?No, you shouldn't. OBJECT is only for backwards compatibility with (the very) old Turbo Pascal compilers.  You should use CLASS based objects instead.  I learned that recently. As I've said, CLASS objects are similar to pointers but it is a simplification.  Actually there are some compiler magic that makes memory management a bit more easy than in Java and C++ (not garbage manager).  It isn't too hard. You can read more about this in the CLASS vs. OBJECT and memory management discussion I had at Pascal Game Development forums. If you need automatic objects like in C++ you can use advanced records, but you must remember they're not objects (no inheritance, can't be used to implement TNotifyEvent responses, etc.). Anyway you should follow some of the tutorials to learn more. Quote from: Flaze07 on July 04, 2017, 09:27:08 amso I need TCanvas to make something like C++'s sfml can make ? Nope, you don't need TCanvas.  Please follow the tutorials to learn more. ---------------------------------------------------------------------- Thaddy · 2017-07-04 07:57 And, btw, it is possible to use sfml in Object Pascal by translating the C binding headers using h2paspp and h2pas and a little manual massaging. There may be even already a Pascal header out there...[edit] Yes there is: https://github.com/DJMaster/csfml-fpc ---------------------------------------------------------------------- Handoko · 2017-07-04 07:58 Quote from: Flaze07 on July 04, 2017, 09:27:08 amso I need TCanvas to make something like C++'s sfml can make ? It depends on what the 'something' you meant is. Quoted from Wiki: QuoteSimple and Fast Multimedia Library (SFML) is a cross-platform software development library designed to provide a simple application programming interface (API) to various multimedia components in computers. From the description above, we can know SFML is optimized for performance. TCanvas is slow. If your application does not perform a lot of screen drawing, TCanvas is okay. But if you want to do graphics, games or multimedia, you should choose other libraries: http://wiki.freepascal.org/Developing_with_Graphics http://wiki.lazarus.freepascal.org/Graphics_libraries I ever tried BGRABitmap, Allegro.pas, Castle Game Engine, all of them have good performance, should be enough to used for most cases. But if you want 'better' performance, you may try to use OpenGL to control the hardware directly: http://wiki.freepascal.org/OpenGL http://wiki.freepascal.org/OpenGL_Tutorial ---------------------------------------------------------------------- Thaddy · 2017-07-04 07:59 See here Handoko, looks nice https://github.com/DJMaster/csfml-fpc My edit crossed your last post again. This may be an optimal solution for OP since he seems familiar with it. ---------------------------------------------------------------------- Handoko · 2017-07-04 08:05 Great to know now SFML can be used on Free Pascal. It is very popular, I heard SFML a lot. Someone please add it in to the wiki page. ---------------------------------------------------------------------- Flaze07 · 2017-07-04 09:14 I see...thank you (there's actually 2 sfml pascal bindings) https://github.com/CWBudde/PasSFML Edit : I tested these 2 pascal bindings several months ago... the codes were ugly, furthermore those are made for C++ and not pascal so ...I am just gonna try ZenGL (which is not updated anymore but it is the most popular ones I have heard) ---------------------------------------------------------------------- Thaddy · 2017-07-04 10:49 Quote from: Flaze07 on July 04, 2017, 11:14:41 amI see...thank you (there's actually 2 sfml pascal bindings) https://github.com/CWBudde/PasSFML Christian Budde's version is based on the other one by Laurent Gomila. Christian usually writes extremely good code. QuoteEdit : I tested these 2 pascal bindings several months ago... the codes were ugly, furthermore those are made for C++ and not pascal so ...I am just gonna try ZenGL (which is not updated anymore but it is the most popular ones I have heard) The Pascal bindings are for Pascal use, not C++. Just the library is programmed and compiled in C++. ZenGL is a mess (and not popular for that reason, not only because it isn'tmaintained) but there seems to be one (1) person that advocates its use. That's something different from popular... Try the BGRABitmap stuff and the TOpenGlControl. Those are popular! maintained! and very, very good! ---------------------------------------------------------------------- Flaze07 · 2017-07-04 11:09 ahh I see....thank you ---------------------------------------------------------------------- DJMaster · 2017-09-10 08:01 More info about csfml-fpc can be found within this thread: https://forum.lazarus.freepascal.org/index.php/topic,33877.0.html Take a look at the attached examples. ---------------------------------------------------------------------- DJMaster · 2017-09-10 08:25 Quote from: Handoko on July 04, 2017, 10:05:44 amGreat to know now SFML can be used on Free Pascal. It is very popular, I heard SFML a lot. Someone please add it in to the wiki page. Done! http://wiki.freepascal.org/Multimedia_Programming ---------------------------------------------------------------------- Handoko · 2017-09-10 08:41 You should also add some info here: http://wiki.freepascal.org/Graphics_libraries Linux is not supported yet. I'm a Linux user. ---------------------------------------------------------------------- DJMaster · 2017-09-11 17:43 Quote from: Handoko on September 10, 2017, 10:41:03 am... Linux is not supported yet. I'm a Linux user. I'm a Windows user but Linux support is not a big deal: https://github.com/DJMaster/csfml- fpc/commit/2e9832451965927ff4defa6780be61abab896850 I've just tested the attached Colorful.pas example and it worked like a charm under bot x86_64-linux and i386-linux  BTW: can you explain why under Linux I have to call SetExceptionMask to avoid the exception "EInvalidOp: Invalid floating point operation"? ---------------------------------------------------------------------- Handoko · 2017-09-12 02:59 Thanks DJMaster for making it Linux compilable. I managed to compile Colorful.pas on my Linux64 GeForce 430, but I only got a blank window. I have libcfsml-dev 2.3 installed properly. I got no error but only 2 warnings when compiling. ---------------------------------------------------------------------- DJMaster · 2017-09-12 03:46 SFML 2.4.2 and CSFML 2.4 are required. Make them from source and install in the right order. FPC 3.0.2 is recommended. ---------------------------------------------------------------------- DJMaster · 2017-09-12 05:07 P.S.: shader loading has been modified in CSFML version 2.4 without backward compatibility: https://github.com/SFML/CSFML/issues/100 You can try the attached little Circle example, it should work out of the box. ---------------------------------------------------------------------- Handoko · 2017-09-12 18:00 Hooray, it worked!  Although just some circles, it gives me reasons to explore more. Can you tell me how to deploy programs that use SFML, especially on Windows? What dll files are required to copy to the users? ---------------------------------------------------------------------- DJMaster · 2017-09-12 18:23 On Windows you can deploy original CSFML dlls and OpenAL dll for i386-win32 (or x86_64-win64). CSFML dlls are available here: https://www.sfml- dev.org/download/csfml/ OpenAL dll is avaliable here (as installer): https://www.openal.org/downloads/ Alternatively you can build dlls yourself from sources under MSYS2 for both 32 and 64 bit Windows OSs. In this case you have to additionally deploy libgcc_s_dw2-1.dll (for win32) or libgcc_s_seh-1.dll (for win64) and libwinpthread-1.dll from the corresponding mingw32/mingw64 bin directories. I prefer this way when I use other dlls at the same time to be sure to use libraries built under the same environment. ---------------------------------------------------------------------- Handoko · 2017-09-12 18:39 Thank you for the information. I am currently a bit busy, I will try it when I have more time. ---------------------------------------------------------------------- DJMaster · 2017-09-12 18:43 You are welcome!  p.s.: what about the Colorful.pas example? Did you test it with CSFML 2.4.0? ---------------------------------------------------------------------- Handoko · 2017-09-12 19:02 I have not. I know I can build CSFM 2.4.0 or set Linux PPA manually, but prefer the easiest. The repository of my Ubuntu Mate 16.10 only shows CFSML 2.3 and SFML 2.4. I am not willing to change it, at least for now. Ubuntu (Mate) 17.10 is going to be released, maybe this month or next month. Then I will upgrade my Linux and see what CFSML version will be in the repository by default. Installing libraries in Linux is very easy, just some clicks. Below is the screenshot of Synaptic Package Manager, which I usually use for installing/removing applications and libraries.