Recent

Author Topic: SDL2 - Examples, how to start, etc  (Read 3562 times)

vico

  • New Member
  • *
  • Posts: 16
SDL2 - Examples, how to start, etc
« on: June 27, 2023, 01:05:18 am »
I'm looking for guides about how to use SDL with Free Pascal (not Lazarus), how to setup basic things, make a simple 2d (and maybe 3d) scene, etc...

I found this repository but seems like no examples were still added to the repo.

Handoko

  • Hero Member
  • *****
  • Posts: 5376
  • My goal: build my own game engine using Lazarus
Re: SDL2 - Examples, how to start, etc
« Reply #1 on: June 27, 2023, 05:16:42 am »

Seenkao

  • Hero Member
  • *****
  • Posts: 610
    • New ZenGL.
Re: SDL2 - Examples, how to start, etc
« Reply #2 on: June 27, 2023, 06:10:57 am »
Извиняюсь за рекламу!
Могу я вам посоветовать ZenGL? Для 2D, реализовано немало, да и самих функций для ZenGL реализовано не мало. Знать OpenGL не обязательно, если использовать только 2D. Есть демонстрационные примеры использования, которые достаточно просто запустить. Единственная проблема с запуском может быть только под Android. Там нужно установить кросс-компилятор, либо необходимый вам, либо несколько кросс-компиляторов.

Необходимые средства под разработку под Android (на этой странице немного расписал как мне точно указать адрес моего поста?

Так же, под настольные ПК, можно создавать 3D-приложения с помощью ZenGL, практически не заботясь о создании окна. ZenGL уже имеет встроенные функции создания окна, вам надо будет указать лишь его размеры. Но для создания 3D приложений вам надо знать OpenGL. В ZenGL уже встроены заголовки OpenGL.
... но их надо уметь настраивать конфигурационный файл... я не создал на данное время ни какого туториала для этого.


Google translate:
Sorry for the ad!
Can I recommend ZenGL? For 2D, a lot has been implemented, and the functions themselves for ZenGL have been implemented quite a lot. It is not necessary to know OpenGL , if only 2D is used. There are use demos that are easy enough to run. The only problem with the launch can only be under Android. There you need to install a cross compiler, either the one you need, or several cross compilers.

Necessary tools for Android development (on this page painted a bit how do I accurately specify the address of my post?

Also, for desktop PCs, you can create 3D applications using ZenGL, with little or no concern about creating a window. ZenGL already has built-in functions for creating a window, you only need to specify its dimensions. But to create 3D applications, you need to know OpenGL. ZenGL already has OpenGL headers built in.
... but they need to be able to customize the configuration file ... I have not created any tutorial for this at the moment.
 :-[
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: SDL2 - Examples, how to start, etc
« Reply #3 on: June 27, 2023, 09:11:47 am »
At the bottom of the page that Handoko mentioned is a link to https://www.freepascal-meets-sdl.net/ which introduces you to the concepts of SDL(2).
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

flowCRANE

  • Hero Member
  • *****
  • Posts: 885
Re: SDL2 - Examples, how to start, etc
« Reply #4 on: June 27, 2023, 12:41:23 pm »
I'm looking for guides about how to use SDL with Free Pascal (not Lazarus) [...]

Why not Lazarus? Do you like wasting time with plain text editors and compiling from the terminal?

Quote
[...] how to setup basic things, make a simple 2d (and maybe 3d) scene, etc...

Any SDL2 tutorial will suffice, especially those for C. I read this one myself — https://lazyfoo.net/tutorials/SDL/index.php

Quote
I found this repository but seems like no examples were still added to the repo.

These are the headers you should download to use the functions from the SDL2 libraries. Download them, put them in the source directory of the project and add their path to Other unit files (-Fu), then download the .dll files for SDL2 and place them next to the project executable. All available libraries can be found here:

SDL — https://github.com/libsdl-org/SDL
SDL_Image — https://github.com/libsdl-org/SDL_image
SDL_Mixer — https://github.com/libsdl-org/SDL_mixer
SDL_Net — https://github.com/libsdl-org/SDL_net
SDL_TTF — https://github.com/libsdl-org/SDL_ttf
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL.

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: SDL2 - Examples, how to start, etc
« Reply #5 on: June 27, 2023, 02:56:22 pm »
@vico

See here, and GoTo "For how it's done, take a Look at that MediaPlayer's BasicStructure (Projectname: 'FFPlay4Laz')".

The two Links contain FPC-Codes for ...
• SDL-Timer, SDL-Audio, SDL-Video
• SDL-Threads, -Mutexes and -ConditionVariables and
• an EventLoop with SDL-Events for Screen-, Mouse- and KeyEvents,
for SDL1 and for SDL2.
« Last Edit: June 27, 2023, 05:44:03 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

YiannisKam

  • Full Member
  • ***
  • Posts: 119
Re: SDL2 - Examples, how to start, etc
« Reply #6 on: June 27, 2023, 05:58:49 pm »
Hello, may I suggest these tutorials? https://lazyfoo.net/tutorials/SDL/index.php
They can be converted to Pascal. At least this is what I do because I like Pascal's syntax so much. I'm half way through and I really enjoy the process.
Windows 10 - 64bit
Lazarus version: 3.99
FPC       version: 3.3.1

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: SDL2 - Examples, how to start, etc
« Reply #7 on: June 27, 2023, 06:29:03 pm »
@YiannisKam

The Link You've mentioned is in the same Post;)
GoTo "SDL-Tutorials for C-Programming by 'Lazy Foo' Productions' (= more detailed, but C only)",
for SDL1 and for SDL2.
« Last Edit: June 27, 2023, 06:38:10 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

Roland57

  • Sr. Member
  • ****
  • Posts: 475
    • msegui.net
Re: SDL2 - Examples, how to start, etc
« Reply #8 on: June 28, 2023, 07:05:00 am »
My projects are on Gitlab and on Codeberg.

metis

  • Sr. Member
  • ****
  • Posts: 300
Re: SDL2 - Examples, how to start, etc
« Reply #9 on: June 29, 2023, 11:36:57 am »
Just looked at the Page mentioned by Roland57 in the previous Post ...

@YiannisKam
Quote
They can be converted to Pascal. ... I'm half way through and I really enjoy the process.
For most Lazy Foo Chapters this has already been done on that Site, see Folder [lazyfoo.net].
« Last Edit: June 29, 2023, 12:30:26 pm by metis »
Life could be so easy, if there weren't those f*** Details.
My FFmpeg4Lazarus = FFPlay4Laz + FFGrab4Laz + FFInfo4Laz

 

TinyPortal © 2005-2018