[fpc-pascal] FPC Graphics options?

Brian vmst at golden.net
Fri May 12 00:56:42 CEST 2017


I have an older project (Virtual Pascal) using DPMI32 and writing to the
graphics card  , and had the same issue as you when deciding which graphics
library to use for Linux. In my case , part of the application is GUI and
part is very fast 2D pixel graphics (points lines , polygons etc.)

The first approach in porting to Linux was to write directly to the Linux
graphics frame buffer and bypassing X11 entirely. This is very fast but that
leaves you without many of the benefits of Linux.

The second approach was to write directly to X11 , but writing a lot of
pixel data to the X11 server will cause the X11 server to bog down and even
crash. X11 is a server so that approach was ruled out.

The chosen approach is to use SDL2.0+. If you are coming from pixel based
BGI graphics where everything is pixel based , SDL takes a bit of getting
used to , as everything (SDL 2.0) is based on textures. You write to a
texture and render it to the graphics card as and when or periodically.

In your case if you have a lot of pixel writing , SDL 2.0 has a very clever
mechanism where you can render to a software (CPU memory) frame buffer at
whatever rate you want and render (copy) that frame buffer to the graphics
card at say 60Hz frame rate which make things appear faster than the eye can
perceive.

Here is basically how to do it.

http://gigi.nullneuron.net/gigilabs/sdl2-pixel-drawing/

There is a nice Image  and TTF library with SDL 2.0

Brian




--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/FPC-Graphics-options-tp5728513p5728518.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list