Recent

Author Topic: Choosing SDL2 or BGRABitmap  (Read 322 times)

damieiro

  • Full Member
  • ***
  • Posts: 104
Choosing SDL2 or BGRABitmap
« on: December 11, 2019, 01:15:12 pm »
Hello:

I'm going to practice making a little game (a simple space shooter) and with this training to do bigger things.
I do not need and i don't want the part of VCL-like facilities (no visual programming of these)

I was reading a lot and testing SDL2. This is my very first impresion:

PROS
- Good support and will be supported
- helpers: Loadimage, fonts.. Not many, but functional.
- full multimedia support: audio, and input/output
- seems portable with little efford.
- does the work.
- 2d hardware acceleration

CONS:
- portability is not straightforward (not like a TCanvas, for example).
- use of C external code (well, this is a personal choice) with need of use headers and wrappers
- very bad primitives (only lines, points and rectangles). It's bitblitzing oriented.
- no 3d, but i do not need it just now.

Then i'm reading now (but not using) BGRAbitmap library, and i need help about their pros and cons from SDL2

In a first read it seems that
PROS:
- Good primitive support (curves, beziers, etc..).
- Pascal native and object oriented and free code
- Good pixel access
- Seems less efford to port between platforms.

CONS:
- Only a graphical library, but i'm testing only this part, i could think i could use other audio libraries and input/output libraries to complete this

DON'T Know:
- Seems visual programming oriented (use Tform or thing like that to make the window, but i see it accepts a GL context, i want to use it without using forms and LCL, like a console-like program )
- How accelerate or performs in 2D vs SDL2 and how BGRA performs in GL context (SDL2, in fact, uses Open GL internally)
- Fonts and their treatment..
- What are the future plans and actual support (it seems supported).
- Android support.
- Other pixel formats (for example, in future it we have a 64 bit pixel and not a 32 one)

Well, in first impression, i saw BGRA a good candidate and i like the work there, but i never used it and i see it's used mostly like a fast replacement of actual lazarus components but i think it can be used for fast paced shooter as well and without SDL2 oddities

Could you help me with your experience on SDL2 and/or BGRA?
« Last Edit: December 11, 2019, 05:37:48 pm by damieiro »

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: Choosing SDL2 or BGRABitmap
« Reply #1 on: December 11, 2019, 06:45:52 pm »
Hello,

Indeed BGRABitmap is only graphical.

It is true that it was designed in the first place to be used with a GUI, though you can do without it. Note that if you want full-screen, you can use a form without border and maximized.

There is OpenGL support. You can load textures directly or create them with TBGLBitmap (similar to TBGRABitmap except it can be used in OpenGL), see for example:
https://github.com/bgrabitmap/bgrabitmap/tree/master/test/test4lcl_opengl

The package BGLControls provide an easy to use surface (you can have multiple surfaces on a form so multiple contexts if you like). Otherwise there is the a BGLCanvas variable provided by the BGRAOpenGL unit for use with the current GL context.

If you want no GUI at all, you might be interested by the examples with ZenGL:
https://github.com/bgrabitmap/bgrabitmap/tree/master/test/test4other/zengl

Regarding 3D, there is some support for software rendering and OpenGL rendering:
https://github.com/bgrabitmap/bgrabitmap/tree/master/test/bgratutorial3d

For pixel formats, there is some support for various pixel formats. TExpandedBitmap (of unit ExpandedBitmap) provides 16-bit per channel linear RGBA, so 64-bit per pixel. Not everything is available, though if you need something in particular, feel free to ask.
https://github.com/bgrabitmap/bgrabitmap/tree/master/test/colorspace

Regards
Conscience is the debugger of the mind

damieiro

  • Full Member
  • ***
  • Posts: 104
Re: Choosing SDL2 or BGRABitmap
« Reply #2 on: December 13, 2019, 08:32:13 am »
thanks for your complete response.

I see you are the main developer of BGRABitmap. Good work :)

I am also reading about modern OpenGL and SDL -> https://www.freepascal-meets-sdl.net/chapter-10-sdl-modern-opengl/

I would try it too.

I have seen (first read) this part of the GL code on BGRAbitmap-> https://github.com/bgrabitmap/bgrabitmap/blob/master/bgrabitmap/bgraopengl.pas

Are you using GL3.0+?. It seems legacy open GL in the unit, but i have diagonal read (not deep read now).

circular

  • Hero Member
  • *****
  • Posts: 3111
    • Personal webpage
Re: Choosing SDL2 or BGRABitmap
« Reply #3 on: December 14, 2019, 10:30:02 am »
That’s indeed legacy OpenGL. That may be slower especially for complex 3D stuff. But for 2D sprites that’s ok I suppose.
Conscience is the debugger of the mind