Sign in to follow this  
xyuri

SDL or DirectX for beginner?

Recommended Posts

I have started learning C++ with the goal of making games, obviously :-) I have done one and a half games (One I didnt finish) in console box, but really now should be the time I start learning a little about graphics and looking ahead into which graphics library I will master. A couple days ago I showed off my tic tac toe game on the forums and someone mentioned that I should write it using the SDL library, so since then I have been fiddling with a little SDL, drew some graphics for a mario type platform game, and have been reading on how to calculate velocity and gravity (etc...) of objects, which I found to be very interesting and easy to understand. On the other hand, at work I have access to a huuge online library of books and have been browsing through some of the DirectX pages to (hopefully) get a bit of a feel for it. Same applies for OpenGL btw. So I know SDL is easier and rather quick to get into and get something onto the screen and handles events for you (Which I love! :-D). And DirectX is platform specific btu feature rich, and 3D, same with OpenGL, but Former is M$ only and latter is Cross Platform and a tad easier. Now, my question (yep, I babble a little, sorry): Is it worthwhile mastering SDL now and learning DirectX/OpenGL later? Or should I trudge through DirectX/OpenGL now and lose my hair at a young age?

Share this post


Link to post
Share on other sites
well first you have to understand that if you are programming in 2D these are your choices: DirectDraw (DX 7.0), Direct3D (DX 8.0-9.0c), OpenGL, SDL, Allegro. for ease of use and the fact that it's being updated i'd use Allegro.

now for 3D graphics, you'll have no choice but OpenGL or Direct3D. you can integrate them with SDL or Allegro but you'll need to use OGL or D3D ir you want any 3D capabiliities.

Share this post


Link to post
Share on other sites
my recommendation is that you learn SDL or Allegro, then later combine them with OGL(it can be done, but with Allegro you need to use AllegroGL, plain SDL works with OGL though). SDL/Allegro+OpenGL has all the features of DirectX, and it's (IMHO) easier to learn/use and it's crossplatform

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
well first you have to understand that if you are programming in 2D these are your choices: DirectDraw (DX 7.0), Direct3D (DX 8.0-9.0c), OpenGL, SDL, Allegro. for ease of use and the fact that it's being updated i'd use Allegro.

now for 3D graphics, you'll have no choice but OpenGL or Direct3D. you can integrate them with SDL or Allegro but you'll need to use OGL or D3D ir you want any 3D capabiliities.


Is it common (or recommended) to go into 2D then 3D, or to start with basic 3D and move into more complex 3D? I think I'm going into 3D ;-) IMHO I dont think 2D will take you very far nowdays.

Share this post


Link to post
Share on other sites
Quote:
Original post by Roboguy
my recommendation is that you learn SDL or Allegro, then later combine them with OGL(it can be done, but with Allegro you need to use AllegroGL, plain SDL works with OGL though). SDL/Allegro+OpenGL has all the features of DirectX, and it's (IMHO) easier to learn/use and it's crossplatform


I have seen that SDL has some OGL elements but have never known exactly why/how. Is the OGL in SDL capable of any 3D?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Learn both OGL and D3D and if you can learn them at the same time do that.

Allegro and SDL simply tries to do too much for you and you need to trust it unless you want to look inside the ever growing backend of these wrappers.

Personally I do not like wrappers. They introduce a level of code which bloats your programs. Remember that OGL and D3D already serves to insulate you from the graphics card already. Having another layer of Allegro or SDL on top of that makes you all the more "not in direct control" of your hardware.

Share this post


Link to post
Share on other sites
The GL commands you see in SDL are simply replacements for actions you would normally perform yourself when setting up opengl, but since sdl sets up your windows & does all the dirty os calls, it makes sense to have sdl handle those aswell.
To use opengl with sdl you have to link to opengl as well in your application, then you just use the standard gl commands to produce whatever you want once sdl has set it up for you. those sdl gl commands you see are just for initializing it

///
Edit: In response to the last. Not everyone wants control. I am a control freak, I can't even stand to use std anymore & atm am writing my own compiler. But this is all very extreme. Some people just want to make games. & for that sdl is a very quick reliable way of doing that & takes alot of weight off of your shoulders. I don't really recommend learning d3d @ the same time. Prehaps later when you've got a grasp of gl & have moved forward with games etc it might be worth just to get a fuller view on how to put a 3d engine together, but for practicality sdl & opengl are a lovely match
///

Share this post


Link to post
Share on other sites
Firstly I wouldn't worry too much about it :P Really the best thing you can do to learn programming is to practise, so go with whatever you think will hold you interest. I personally love useing SDL for my window setup and then OpenGL for the 3D stuff - its extremely easy, its cross platform and SDL is an industry quality lib (some of the UT games linux ports were build with it, as well as some others). To use OpenGL with SDL I think its just one flag you have to pass into SDL_Init() and you away - too easy :D

2D stuff is a good place to start and learn the basics of events, input and game logic befor having to deal with the complicated stuff that 3D games bring. If you start with SDL for the 2D stuff its very easy to switch over to 3D stuff when your ready. But again if you like the look of DX or something else go with that - I just personally like the way SDL sets things out and I think OpenGL has a more intuitive set of calls than DX but feel free to pick something else!


Quote:
Original post by xyuri
I have seen that SDL has some OGL elements but have never known exactly why/how. Is the OGL in SDL capable of any 3D?


Yes! Once you have the right window setup with SDL you can use OpenGL commands normally just like if you'd setup the window yourself - the advantage of having SDL do it is that its (a) cross platform and (b) much simpler than doing it with straing Win32 calls. I personally use none of the SDL graphics features I only use plain OpenGL for rendering, but SDL helps with the window setup and events.

Share this post


Link to post
Share on other sites
Thank you very much for your advice guys :-) I find this BBS to have very helpfull and cheerfull members.

I think I'll get comfortable with SDL at the moment, because I'm a little established with it already and am still learning the C++ language itself (Still got miles to go).

Thank you :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by xyuri
Quote:
Original post by Alpha_ProgDes
well first you have to understand that if you are programming in 2D these are your choices: DirectDraw (DX 7.0), Direct3D (DX 8.0-9.0c), OpenGL, SDL, Allegro. for ease of use and the fact that it's being updated i'd use Allegro.

now for 3D graphics, you'll have no choice but OpenGL or Direct3D. you can integrate them with SDL or Allegro but you'll need to use OGL or D3D ir you want any 3D capabiliities.


Is it common (or recommended) to go into 2D then 3D, or to start with basic 3D and move into more complex 3D? I think I'm going into 3D ;-) IMHO I dont think 2D will take you very far nowdays.

it all depends on what market you're targeting. for instance, mobile games and handheld use alot 2D graphics. though we are now getting into the era of mini-3D games (Metroid Hunters and half of the PSP games), 2D still has its place. sometimes you have to justify whether a game needs 3D graphics before you using. but that's just me. [happy]

Share this post


Link to post
Share on other sites
I have actually been thinking about targeting handheld devices (But not mobile phones, theyre sad excuses for a gaming platform). I have had a brief read over some of the tutorials for GBA over at GBAdev but found it a little overwhelming.

Share this post


Link to post
Share on other sites
I'd go with SDL as it's much easier to jump into. It also nicely introduces some concepts that are used in both OpenGL and Direct3D. I just made a tutorial on how to set it up with Dev-C++, you could tell me what you think once you have gone through it.

My SDL Introduction Tutorial... What do you think?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Rob Loach
My SDL Introduction Tutorial... What do you think?


I mever knew you could download SDL related stuff through that web updates function! :-) The tutorial is good in its approach in that is simplifies actually getting and SDL app compiles and running as easily as possible.

Share this post


Link to post
Share on other sites
Three letters.... S D L.

I havn't got much experience from directx, but wasting 200 lines of code to get a window open and some pixels drawn is just plain waste of time. A little increase in performance is not really worth it.

And what comes to Direct3D and OpenGL, I prefer OpenGL (surprise), but I think that OpenGL extensions and such are a bit awkward. OpenGL isn't good, but Direct3D is worse.

You asked about "the opengl in SDL". There is no special OpenGL in SDL. It's just the same OpenGL that is with Windows or Linux, it's just that SDL brings a common interface to both, Windows GL (WGL) and Linux's (and others') GL for X (GLX). Actually the version of OpenGL you're using depends on the graphics adapter you (or perhaps the player of your game) is using.

And a few words of advice. You _can't_ go 3D before you know 2D. You need to know the basic aspects of game programming. 2D games are mostly the same as 3D games, BUT, going 3D puts you through a lot of maths, programming, in addition to input/sound/gameplay programming. If you jump directly to 3D, you will probably end up with a damn ugly game with a gameplay that sucks ass. You have plenty of time to learn 3D. I sincerely hope that you believe me, too many game programmers want to do Half-Life 3 before they can do Pong 2.

-Richardo

Share this post


Link to post
Share on other sites
I'm starting with 2D using just SDL. I've recently read a fairly good little document explaining the calculation of basic motion with speed/velocity and stuff :-) I love it.

Share this post


Link to post
Share on other sites
Quote:
Original post by xyuri
I'm starting with 2D using just SDL. I've recently read a fairly good little document explaining the calculation of basic motion with speed/velocity and stuff :-) I love it.

Any link? Your high school math book is also a good resource. Any basic trig is all you really need for 2D math.

Share this post


Link to post
Share on other sites
Quote:
Original post by Rob Loach
Quote:
Original post by xyuri
I'm starting with 2D using just SDL. I've recently read a fairly good little document explaining the calculation of basic motion with speed/velocity and stuff :-) I love it.

Any link? Your high school math book is also a good resource. Any basic trig is all you really need for 2D math.


We didnt get to keep our highschool books, theyre borrowed from their library, and education here in australia is pretty weak compared to most other countries.

DOCUMENT

Share this post


Link to post
Share on other sites
Quote:
We didnt get to keep our highschool books, theyre borrowed from their library.


We didn't get to keep our math books here, either. Luckily, the first math class I took in college ( ITT. not really college, but w/e) used a really good book that covered Algebra in painful detail, as well as some basic trig concepts. I also went out and bought a couple of the "demystified" books for College Algebra, Geometry, Trig, and Calculus. Those books helped me out in later classes more than any book I bought from school. Anyway, I'm just babbling. Math is FUN!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this