Recent

Author Topic: getting started with basic graphics programming on Ubuntu  (Read 1126 times)

flowerhaze-zendream

  • Newbie
  • Posts: 1
getting started with basic graphics programming on Ubuntu
« on: April 22, 2022, 10:51:58 pm »
Hello friends -- after many decades away I would like to return to some graphics programming, and just wondering about  graphics libraries -- what to use? How to install?

I don't think i'm interested in Lazarus or an IDE as far as I can tell. I can now write a helloworld.pas that compiles and runs. All I'd like to be able to to get started is to write a hellographics.pas that does something like MoveTo(x1,y1) LineTo (x2,y2).

I'm on an Ubuntu derivative and have installed the compiler using apt.

Are there the equivalent of header files and libraries I need to install?

Thank you!

BlueIcaro

  • Hero Member
  • *****
  • Posts: 792
    • Blog personal
Re: getting started with basic graphics programming on Ubuntu
« Reply #1 on: April 23, 2022, 11:04:09 am »
Hello, in a Form you can check canvas method. take a look
https://wiki.lazarus.freepascal.org/Drawing_with_canvas

/BlueIcaro

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: getting started with basic graphics programming on Ubuntu
« Reply #2 on: April 23, 2022, 11:38:47 am »
Hello, in a Form you can check canvas method. take a look
https://wiki.lazarus.freepascal.org/Drawing_with_canvas

I didn't want to be the first commenter since my graphics experience is limited. However somebody else in effect asked a similar question a few days ago, the bottom line is that svgalib has been dropped by Debian hence by most if not all of its derivatives, so there is little alternative to using a canvas as provided by X11 etc.

This implies using the LCL and probably Lazarus as the development IDE: while there's other possibilities that's certainly the combination which will get the most help around here.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: getting started with basic graphics programming on Ubuntu
« Reply #3 on: April 23, 2022, 03:47:05 pm »
... just wondering about  graphics libraries -- what to use? How to install?

You can do it the hard way or you can choose to do it the easy way. I know some users are 'alergic' to use Lazarus. If you do not want use Lazarus IDE, you can skip all this post.


Short answer:
Use Lazarus


Long answer:

Instal Lazarus. There, when you start a new application project, Lazarus will automatically configure all the basic things you need to do simple graphics. The easiest is TCanvas (and TBitmap). It is in the Graphics unit, which will be added into your uses clauses by the IDE automatically, so you can start doing graphics right away.

Sooner or later you will know TCanvas is slow, not suitable for real graphics projects or games. For serious usage, you should consider the others:
https://wiki.freepascal.org/Graphics_libraries
https://wiki.freepascal.org/Developing_with_Graphics#See_also

BGRABitmap is very feature-rich, it has properly written tutorials. It has a few 3D features, which are hardware accelerated as far as I know. But most of the other functions are as slow as TCanvas/TBitmap.

For general purpose non-3D graphics, I recommend Graphics32. It is many times faster, this is the quote from Wikipedia:
Quote
Graphics32 provides fast operations for pixels and graphic primitives and is almost a hundred times faster in per-pixel and about 2–5 times faster in drawing lines access than the standard components by Embarcadero which are wrappers for the Windows GDI. Additionally, it provides alpha blending, anti-aliasing as well as filters for resampling and deforming bitmaps.

Do you want to write games? If yes, you really should consider these:
https://wiki.freepascal.org/Game_Engine

For game programming, I recommend Castle Game Engine and ZenGL. I ever tried Castle Game Engine, it is actively developed and the support is good. ZenGL is not actively developed anymore but the maintainer can be found here in this forum.

GLScene is an interesting project. Unfortunately it has some minor issues on Linux because the main development is on Windows.

If performance is important and you like doing something challenging, try OpenGL or DirectX. You will get the maximum performance the hardware can offer.

I really recommend using Lazarus. Because Lazarus has Online Package Manager, which will help you install other packages easily. Some beginners have problem installing third party packages or libraries. Using Online Package Manager, you can do it easily:
Lazarus main menu > Packages > Online Package Manager

Also after Lazarus default installation, you will get plenty of graphics related components: TCanvas, TBitmap, TPicture, TJPEGImage, TPortableNetworkGraphic, TFont, TShape, TPaintBox, TOpenGLControl (not enabled by default). All the recently mentioned graphics components won't work by simply putting their unit names on the uses clause, if you use FPC only. Here, you need Lazarus to do the 'magic' for you.

You still can do graphics using FPC without Lazarus, but you're doing it the hard way.
« Last Edit: April 23, 2022, 05:38:03 pm by Handoko »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: getting started with basic graphics programming on Ubuntu
« Reply #4 on: April 23, 2022, 04:33:07 pm »
You still can do graphics using FPC without Lazarus, but you're doing it the hard way.

And trying full-screen graphics on the assumption that direct hardware access still works is doing things the /very/ hard way :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: getting started with basic graphics programming on Ubuntu
« Reply #5 on: April 23, 2022, 04:39:34 pm »
I believe it should work, if DosBox is installed.

 

TinyPortal © 2005-2018