Recent

Author Topic: SDL vs OpenGL  (Read 55823 times)

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: SDL vs OpenGL
« Reply #75 on: February 03, 2017, 05:54:54 pm »
Strange thing is, all the SDL (v1 and v2) with OpenGL usage examples I have seen are pretty horribly written. All procedurely written with near zero code reuse.

I heard SDL is often used to complement OpenGL, which I think you don't need SDL if you just want to write things related with OpenGL only.

Perhaps you may want to try ZenGL. If I have to choose SDL or ZenGL, I will choose ZenGL. It has 3 big advantages:
-  FreePascal are officially supported: 2.6.x & 2.4.x. and checked with Delphi 7 & XE2
- Can be static compiled with the application
- It optimized with OpenGL, OpenGL ES 1.x and Direct3D

More info:
http://wiki.freepascal.org/Graphics_libraries
http://www.zengl.org/wiki/doku.php?id=compilation:basics
http://wiki.freepascal.org/ZenGL_Tutorial

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: SDL vs OpenGL
« Reply #76 on: February 03, 2017, 06:31:12 pm »
Thanks Handoko. I’ll take a look at ZenGL.

Incidentally I also looked at Allegro before I started, but the latest version of Allegro (v5.x if I remember correctly) is not support on FreeBSD (my development workstation). The latest versions of SDL2+OpenGL however are both supported on FreeBSD. The reason I included SDL2 in the mix is because I need it for game input, sound and text. I heard that OpenGL has a new “helper library” to accomplish the same, but I couldn’t find Object Pascal header translations for them. So SDL2 + OpenGL it is for now. :)
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: SDL vs OpenGL
« Reply #77 on: February 03, 2017, 07:16:48 pm »
The reason I included SDL2 in the mix is because I need it for game input, sound and text. I heard that OpenGL has a new “helper library” to accomplish the same, but I couldn’t find Object Pascal header translations for them. So SDL2 + OpenGL it is for now. :)
Game Input is supported in native SDL2, no helper libraries required.

2 Handoko, SDL2 supports DirectX, OpenGL, OpenGLES as well.

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: SDL vs OpenGL
« Reply #78 on: February 03, 2017, 07:42:10 pm »
I've recommended this in another thread, but it's worth repeating: you might want to try out the Castle Game Engine. It's written 100% in FPC, is very cross-platform (Windows, Linux,  OSX, iOS, Android), has built in support for pretty much anything you could want to do in a game (as well as an advanced OpenGL renderering system), and has no dependencies on any external libraries. It also includes an optional set of LCL components (but again, has no overall dependencies on Lazaus or the LCL whatsoever.)

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
Re: SDL vs OpenGL
« Reply #79 on: February 03, 2017, 11:32:15 pm »
Yes, Castle Game Engine is really a good game engine that worth to have a look. I ever tried it although I never learn it seriously. I notice these notable features:

- Plenty of 3D features
- Scene manager
- It has a build tool to make Android games
- Good support on their forum and many demo examples
« Last Edit: February 03, 2017, 11:40:39 pm by Handoko »

Paul_

  • Full Member
  • ***
  • Posts: 143
Re: SDL vs OpenGL
« Reply #80 on: April 16, 2017, 01:28:08 pm »
- ZenGL is dead, but structure is very interesting and code is good for learning
- SDL seems unnecessarily complicated

For 2D and Windows here is also SFML:
http://forum.lazarus.freepascal.org/index.php/topic,33877

It have community, support, lot of features, shaders, it's simple.

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: SDL vs OpenGL
« Reply #81 on: April 16, 2017, 02:11:21 pm »
PaulG, I don't know why you say SDL is unnecessary complicated - could you elaborate? I was totally new to SDL and OpenGL 2 months ago. Yet using SDL2 to set up my OpenGL window was really simple. After that I'm using OpenGL API calls directly to do the rest of my rendering, including using shaders.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Carver413

  • Full Member
  • ***
  • Posts: 119
Re: SDL vs OpenGL
« Reply #82 on: April 16, 2017, 07:16:05 pm »
PaulG, I don't know why you say SDL is unnecessary complicated - could you elaborate? I was totally new to SDL and OpenGL 2 months ago. Yet using SDL2 to set up my OpenGL window was really simple. After that I'm using OpenGL API calls directly to do the rest of my rendering, including using shaders.
I dont think any of these frameworks are overly difficult to learn but really none offer an optimal solution. I am using Sdl2 + Opengl, I chose to use Sdl for better support of other Os's but that really doesn't work because Opengl isn't supported equally on all targets. so now my code could only work on two systems provided there graphic cards are up to par. lately I've been trying to seperate these dependencies so that my code would be more adaptable to other frameworks. my first approach was to put all dependences into a separate framework but this only creates new dependences  that would be tied to my framework. so now I'm looking at advanced records as a solution. they have come a long way since I started using them, I see now they support Initialize and finalize witch would be perfect for closing up buffers and such. by using records we can avoid having to adapt to someone else's framework unless we choose to do so. we could even go as far as dropping these hi level frameworks all together by targeting individual Os's. you and I could share the same X code without me having to adapt fpGui or you having to adapt the explorer.     

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: SDL vs OpenGL
« Reply #83 on: April 18, 2017, 10:30:53 am »
I am using Sdl2 + Opengl, I chose to use Sdl for better support of other Os's but that really doesn't work because Opengl isn't supported equally on all targets. so now my code could only work on two systems provided there graphic cards are up to par.
Again, I'm not sure that is any fault of SDL's. OpenGL abilities are based on the GPU and the graphics drivers you have installed. The most popular graphics systems probably being NVIDIA, AMD, and they both support up to OpenGL 4 very well. Based on my own SDL2+OpenGL code, I can't see why my program would only be supported on select platforms. If those platforms have OpenGL 4 support (which is the API I'm targeting) via their graphics drivers, everything should work just fine. Note that OpenGL 4 has been around for years.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: SDL vs OpenGL
« Reply #84 on: April 18, 2017, 10:35:40 am »
Oh, well,

OpenGL is already an abstraction, DirectWhatever is an abstraction, SDL is an abstraction ON TOP OF THOSE.
That does not mean any negative or positive. It only means a lot of you have to learn a lot about architecture.

For the simple minds (and advanced X platform programmers) SDL is the easiest to learn. But both lower level ones are almost just as easy or difficult.
In the end it is always: I want to write a game but I know jack sh*t about matrices or basic collision detection math (isn't even in opengl) and I don't want to learn it. Won't go...

The basics is simply a vector x,y,z,l,r.f.b,u,d That's a nine vector matrix.(81 square) It's simple. Not counting gravity...  O:-) and some other... O:-)

Positive is if you can solve matrices, you can solve game programming.

Sigh.
« Last Edit: April 18, 2017, 10:48:09 am by Thaddy »
Specialize a type, not a var.

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: SDL vs OpenGL
« Reply #85 on: April 18, 2017, 01:13:34 pm »
OpenGL is directly accessing the GPU, same as DirectX is. They are not at all referring to each other in any way. SDL is also quite direct at what it does, but it is only optional.

Now that you mention matrix math, i can show some code  :)  https://github.com/Zaflis/nxpascal/blob/master/src/nxMath3D.pas  Someone once said that time is better spent at making games, not at making engines. There are a few around there that have figured out most of this for you. What's left is to apply your ideas in simple ways, such as:
Code: Pascal  [Select][+][-]
  1. var a, b, c: TMatrix; // Common 4x4 matrix
  2. begin
  3.   c:=a * b; // Matrix multiplication
  4. end;
  5.  

Paul_

  • Full Member
  • ***
  • Posts: 143
Re: SDL vs OpenGL
« Reply #86 on: April 20, 2017, 05:35:16 pm »
I don't know why you say SDL is unnecessary complicated - could you elaborate?.

It's about structure and ergonomy. I have some experience with SDL 1.x it was reallly chaotic and difficult to use.
If you look how e.g. ZenGL is done it makes big difference in coding, how you use functions, it's very compact and so.
Maybe in SDL 2 it's better but if you look at Wiki pages, documentation.. I'm not sure.

Of course it depends on what you will do, if you need only OpenGL window so it's not big deal.



Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: SDL vs OpenGL
« Reply #87 on: May 12, 2017, 04:31:46 am »
I don't know why you say SDL is unnecessary complicated - could you elaborate?.

It's about structure and ergonomy. I have some experience with SDL 1.x it was reallly chaotic and difficult to use.
If you look how e.g. ZenGL is done it makes big difference in coding, how you use functions, it's very compact and so.
Maybe in SDL 2 it's better but if you look at Wiki pages, documentation.. I'm not sure.

Of course it depends on what you will do, if you need only OpenGL window so it's not big deal.

IMO neither ZenGL alone or SDL with "OpenGL on top" are the way to go these days. ZenGL is not only entirely constructed from deprecated, slow functionality, but also is barely object oriented at all and seems to have been pretty obviously written by someone who spent most of their life writing C89 code and not Object Pascal. (Nothing wrong with that on its own, but it's not what you want with a game engine.) SDL/SDL2 on the other hand boil down to simplistic window management functionality and certainly aren't "engines" of any kind. So yeah, if you're looking to write OpenGL applications that will stand the test of time in Object Pascal, I would definitely recommend you use something like Castle or TERRA that is actually actively maintained and written "with the future in mind".

FPK

  • Full Member
  • ***
  • Posts: 118
Re: SDL vs OpenGL
« Reply #88 on: May 13, 2017, 11:57:57 am »
As the topic came up on fpc-pascal I will answer here. I had a look at it (I used the code posted here: http://forum.lazarus.freepascal.org/index.php/topic,35555.msg235937.html#msg235937). First of all, there is a big difference between i386 and x86-64. All JIT based languages probably use x86-64. So please, compare only the x86-64 results. FPC generates at certain places not perfect code, in trunk I will fix a few of these things.

 

TinyPortal © 2005-2018