Does "sdlgraph" unit work? lazarus / 39-Graphics ---------------------------------------------------------------------- kveroneau · 2019-04-11 04:19 I was browsing through the FPC-3.0.4 source tree I have locally browsing for Retro TP units to see how they were implemented for use in MS-DOS/Go32 and how those units were ported over to run on modern systems.  While I am not planning on making a new program using the old Turbo Pascal legacy "graph" unit, it is still a curiosity.  Anyways, I noticed for modern systems that there is currently a working "ggigraph" unit, which is able to compile an old Turbo Pascal program, however when it comes to linking, the latest Debian does not include a libggi.  I then noticed that someone ported "graph" to SDL in the form of sdlgraph.  Sadly, this unit isn't available in the binary FPC 3.0.4 distribution for whatever reason.  So, I did what everyone else would try, I attempted to compile the sdlgraph.pp file.  For those curious, here is where you can find it in the FPC source: fpc-3.0.4/packages/graph/src/sdlgraph Anyways, it almost compiled, but it is now missing a unit called "sdlutils".  Which is odd, as this unit source is also in the source tree, but for whatever reason isn't in the binary distribution of FPC-3.0.4.  I feel like some Makefiles are missing these units during the current build process.  Unfortunately trying to compile the sdlutils unit is giving me 50 errors.  I have a feeling that sdlutils is something legacy, and that now all that functionality has been moved to the other SDL units.  The only procedure and functions used from sdlutils is SDL_GetPixel and SDL_PutPixel, and neither of these seem to be available in the other SDL units.  So...  I copied and pasted over the procedure and function into sdlgraph.pas, and removed the sdlutils from the uses clause.  Upon running the compile again, I ran into some errors.  These errors don't make much sense if sdlutils ever worked...  So, it first complained about this: bpp := SrcSurface.format.BytesPerPixel; This line is completely broken if you know the structure of the TSDL_Surface and TSDL_PixelFormat...  So, srcSurface is actually a pointer, and format is also a pointer.  So I needed to add the carets to signify that, and then the compile got passed this line.  However, more errors are found in SDL_GetPixel.  One of the easy ones was that it uses "Result:=" in the function call, but neither sdlutils.pas or sdlgraph.pas even has a {$MODE objfpc}, so this isn't supported...  So I added the mode compiler directive, and I have yet more errors to go through...  Thankfully all these errors are currently isolated to SDL_GetPixel and SDL_SetPixel.  Aren't these methods provided by the SDL library?  These are such primitive functions that'd I'd expect SDL to have them in it's own library.  I may just look into that next to get sdlgraph.pas working. Perhaps in the future, I will create a "toy project" which will be an LCL control that works like a graphics driver for the old school "graph" unit, so some retro TP graph unit programs can be drawn with minimal modifications onto a LCL control.  I must admit that I do love all things retro, which is why I am fascinated at getting "sdlgraph" to work. ---------------------------------------------------------------------- Thausand · 2019-04-11 08:15 hi hello kveroneau, sdlutils is package sdl. If binary freepascal then not have. can find source packages/sdl/src/sdlutils.pas (https://github.com/graemeg/freep ascal/blob/master/packages/sdl/src/sdlutils.pas) I try polytest.pas then i error link sdl. Code: [Select]Free Pascal Compiler version 3.0.4-r37149 [2019/03/13] for arm Copyright (c) 1993-2017 by Florian Klaempfl and others Target OS: Linux for ARMHF Compiling polytest.pas Assembling polytest Linking polytest /usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/bin/ld: cannot find -lSDL polytest.pas(79,39) Error: Error while linking polytest.pas(79,39) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: $HOME/bin/fpc/3.0.4/bin/arm-linux/ppcarm returned an error exitcode Compilation failed. I sudo apt-get install libsdl1.2debian, same error  I think have look configuration directory. I think i tell first you that can work then try find error ---------------------------------------------------------------------- marcov · 2019-04-11 08:16 Install sdl devel or dev package. ---------------------------------------------------------------------- Thausand · 2019-04-11 08:33 Quote from: marcov on April 11, 2019, 10:16:15 amInstall sdl devel or dev package. hi hello marcov, i write Code: [Select]sudo apt-get install libsdl1.2-dev now can work. Not more link error  Code: [Select]Free Pascal Compiler version 3.0.4-r37149 [2019/03/13] for arm Copyright (c) 1993-2017 by Florian Klaempfl and others Target OS: Linux for ARMHF Compiling polytest.pas Assembling polytest Linking polytest /usr/bin/ld: warning: link.res contains output sections; did you forget -T? 83 lines compiled, 4.6 sec 2 hint(s) issued Compilation finished successfully. Thanksy marcov  Have program error polytest. I think not error sdl maybe Code: [Select]./polytest An unhandled exception occurred at $00051320: EAccessViolation: Access violation   $00051320   $00047E44   $00048070   $0003CC24   $0003EF8C   $0003F2E4   $000111BC   $00011308 I try example other or find error polytest ---------------------------------------------------------------------- Thaddy · 2019-04-11 08:37 For libggi in stretch: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo apt install libggi2 libggi2-devAlso contains ggi1. ---------------------------------------------------------------------- Thausand · 2019-04-11 08:59 Quote from: Thaddy on April 11, 2019, 10:37:49 amAlso contains ggi1. Many thanksy user Thaddy  I not see ggi1. Alone ggi2. I not know ggi2 have ggi1. Is problem solve ---------------------------------------------------------------------- Thaddy · 2019-04-11 09:31 Note the sdlgraph units seem to rely on https://github.com/ev1313/Pascal-SDL-2-Headers which differ from the headers in the official fpc distribution,. (sdl_events and so on...) ---------------------------------------------------------------------- Thausand · 2019-04-11 10:17 OK thanksy Thaddy. Maybe that why not work sdlgraph. I SDL1. I try SDL2. I problem ggigraph. I try polytest make error fix good ? 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 PolyTest;uses  ggigraph;  // graph;  and 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 var  GraphDriver, GraphMode: Integer;begin  GraphDriver := Detect; //  GraphDriver := VGA;  GraphMode := 0; //  GraphMode := VGAHi;  InitGraph(GraphDriver, GraphMode, '');  if GraphResult <> grok then   begin    WriteLn('GraphResult give error');    halt;  end;  SetFillStyle(SolidFill, 9);  Tralala;  CloseGraph;end.  ./polytest > polytest.001 2>&1 Then have polytest.out Code: [Select]K for mode 33 : S320x200[GT_32BIT] OK for mode 34 : S640x480[GT_32BIT] OK for mode 35 : S800x600[GT_32BIT] OK for mode 36 : S1024x768[GT_32BIT] OK for mode 43 : S1152x864[GT_32BIT] then polytest.001 Code: [Select]LibGGI: No explicit target specified. LibGGI: Try to use display-x... OK for mode 33 : S320x200[GT_32BIT] OK for mode 34 : S640x480[GT_32BIT] OK for mode 35 : S800x600[GT_32BIT] OK for mode 36 : S1024x768[GT_32BIT] OK for mode 43 : S1152x864[GT_32BIT] GraphResult give error Failed to kill(6927,27) (error 3). Failed to kill(6927,27) (error 3). Failed to kill(6927,27) (error 3). Failed to kill(6927,27) (error 3). Have many "Failed to kill(6927,27) (error 3)" . No can close terminal  and polytst.001 big and more big I not sure how work unit graph. I need fix "No explicit target specified." ? then how can fix ? Other (no same) error my confuse when compile -glh polytest Code: [Select]ggigraph.pp(176,18) Hint: Local type "TGGIResource" is not used ggigraph.pp(185,14) Hint: Local type "PGGIClut" is not used ggigraph.pp(191,14) Hint: Local type "TGGIAttr" is not used ggigraph.pp(335,13) Hint: Local type "PBitmap" is not used Assembling ggigraph Assembling polytest Linking polytest /usr/bin/ld: warning: link.res contains output sections; did you forget -T? /usr/bin/ld: $HOME/bin/fpc/3.0.4/units/arm-linux/rtl/heaptrc.o: undefined reference to symbol '_end' //usr/lib/arm-linux-gnueabihf/libXxf86dga.so.1: error adding symbols: DSO missing from command line polytest.pas(87,37) Error: Error while linking polytest.pas(87,37) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted Error: $HOME/bin/fpc/3.0.4/bin/arm-linux/ppcarm returned an error exitcode Compilation failed. I not know why no compile good -glh. Maybe some know ? ---------------------------------------------------------------------- Thausand · 2019-04-11 12:37 Ok, can make work ptcpas. Not example polytest.pas use polytest.txt but polytst2.txt. ptcpas is error not compatible 100% graph unit fillpoly. If use polytst2.txt sdlgraph better work. Then also access violation. I think more compatible problem sdlgraph not alone fillpoly(). ---------------------------------------------------------------------- kveroneau · 2019-04-11 14:43 Quote from: Thaddy on April 11, 2019, 10:37:49 amFor libggi in stretch: Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i sudo apt install libggi2 libggi2-devAlso contains ggi1. My Debian Stretch doesn't appear to have that package.   Today after work, I'll take a look at that SDL git repository and maybe get sdlgraph to compile.  Here's my output when trying to install: 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 root@sys3:~# apt-get install libggi2 libggi2-devReading package lists... DoneBuilding dependency tree       Reading state information... DonePackage libggi2-dev is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another source E: Unable to locate package libggi2E: Package 'libggi2-dev' has no installation candidateroot@sys3:~# cat /etc/debian_version9.8  Yes, I am one of those people who don't believe in sudo, not using sudo and forcing separate root password enforces privilege separation and also adds another layer for a potential hacker to get through. ---------------------------------------------------------------------- Thaddy · 2019-04-11 16:34 That's strange because I only installed it because of the question. My platform is Debian-stretch -armhf. ( Raspbian.) Stretch has these libraries in APT I double checked that it is in the repositories. Also for other platforms. ---------------------------------------------------------------------- kveroneau · 2019-04-11 20:34 Do you have any additional repositories enabled perhaps?  I searched in the official Debian packages and I don't see it available in any suite or for any architecture: https://packages.debian.org/search?suite=all§ion=all&arch=any&sear chon=names&keywords=libggi ---------------------------------------------------------------------- Thausand · 2019-04-11 20:58 hi hello kveroneau package old. i raspbian virgin repository. Code: [Select]$ apt search libggi2 Sorting... Done Full Text Search... Done libggi2/stable,now 1:2.2.2-5.1 armhf [installed]   General Graphics Interface runtime libraries libggi2-dev/stable,now 1:2.2.2-5.1 armhf [installed]   General Graphics Interface development package $ cat /etc/debian_version 9.8 package find here https://tracker.debian.org/pkg/libggi (sorry i no can link direct libggi2 (!?). See left) ---------------------------------------------------------------------- Thaddy · 2019-04-12 05:23 Indeed it must be libggi2 (which also contains ggi1) and is most definitely in the default Debian packages. I believe I already wrote that.