Archived

This topic is now archived and is closed to further replies.

sdlprorammer

OpenGL Vs SDL

Recommended Posts

1)Which one is better, and which one is harder to learn? 2)I ''ve heard that OpenGL is for 3D graphics, and SDL for 2D. But this doesn''t make too much sense too me.. What does OpenGl support that SDL doesn''t? 3D graphics aren''t just many 2D shapes? Then how is it possible that SDL doesn''t support 3D graphics? It''s all about painting in the screen, isn''t it? thanks in advance

Share this post


Link to post
Share on other sites
There is no ''better'', they both do a different job.

SDL is a platform independant library consiting of various routines to make it possible to make game without worrying about the OS under it, with things like networking, window creation and such like.

OpenGL on the other hand is a 3D Graphics API, designed to allow people to create 3D graphics via a standard interface.

Now, you can use SDL to create a window and then have OpenGL drawing to it, which is how many people use it.
You can ofcourse do it without using OpenGL, however iirc it wont be as fast as its not using hardware accelertion to perform operations.

SDL does support 3D via OpenGL to use hardware accerlated functions, however yes you could probably write a 3D engine without OpenGL in SDL, just dont expect it to go very fast, thats all as it will all be software driven.

Really, you should go read up on what SDL and OpenGL do properly, thats just really a quick overview of how it works.

Share this post


Link to post
Share on other sites
thanks for the help
so after i have a decent understanding on SDL ( just decent ), i could go to the "opengGL part" of SDL and learn how to use 3D graphics, whithout neccesarily understanding all about OpenGL? I mean, i could easily learn only that part of OpenGl for 3d graphics and be able to use it behinh SDL?
thanks...

Share this post


Link to post
Share on other sites
SDL does a lot for you, but you''ll still have to learn OpenGl for programming 3d games.

When you use SDL as OpenGl framework then most of what you know about creating 2D applications will be irrelevant.
There are better toolkits for setting up / working with OpenGl IMO.

Maybe you should read existing threads and articles to get an idea of what the difference between 2d applications and 3d applications is ...

Share this post


Link to post
Share on other sites
quote:
Original post by sdlprorammer
thanks for the help
so after i have a decent understanding on SDL ( just decent ), i could go to the "opengGL part" of SDL and learn how to use 3D graphics, whithout neccesarily understanding all about OpenGL? I mean, i could easily learn only that part of OpenGl for 3d graphics and be able to use it behinh SDL?
thanks...

Yes.

Share this post


Link to post
Share on other sites
1) If you want to do 3D, OpenGL is IMHO much easier to learn than Direct3D, the next leading API. Plus, OpenGL is cross-platform as well.

For my own programming experiments, I use only a few functions from SDL (window creating, input handling and texture loading) and the rest is done in OpenGL. So, in fact, I know nothing about SDL but that few functions I found in the docs. The graphics itself uses OpenGL.

2) Doing 3D in 2D is very difficult, since you have to write such things as triangle rastetizers, projections, transformations, blending, ... on your own. Nowadays, almost every computer has some sort of 3D acceleration to do this job for you. You only tell the computer how to render what triangles. This is the job of OpenGL, not SDL.

On the other hand, doing 2D in 3D via OpenGL or other API is much easier and even faster because it benefits from the acceleration. I heard that Direct3D 8 and newer doesn''t even have any support of 2D graphics, all is done using 3D.

Share this post


Link to post
Share on other sites
I am confused

But now that i think about it, Xerxes idea is pretty good. Window creating, and input handling ( i don''t know what texture loading is.. ) ( input handling from mouse and keybord ) is done pretty easily in SDL, so i guess it would be nice to use them.

So do you think, i should start reading the tutorials from nehe.gamedev, but to start from lesson 2 since i won''t need to care about creating the window?

Share this post


Link to post
Share on other sites
No, because they''re 2 very different ways of handling the application. SDL has its own loop, whereas normal Windows applications have a different sort of loop. You need to understand the difference before proceeding with a tutorial, as you will have to adapt the code to suit what you''re using. If you want to use OpenGL and SDL together it''s probably better to find some tutorials that are dedicated to that combination.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
if you want the absolute easiest way to start learning OpenGL, don''t use SDL, use glut. As simple as SDL is to set up a window and some surfaces real quick, glut is easier still. But I don''t think anyone is quite sure of what your goals are with using SDL or OpenGL. What are they?

Share this post


Link to post
Share on other sites
thanks for the replies

Eerr.. my goals is to write non-commercial games for fun. I don''t know if i will do something more commercial or something like a programming career on this though. Chances are that i won''t.

But i don''t see where SDL is better than OpenGL. And it seems that OpengGls is pretty easy too. I don''t know..

I wanna here opinions..

thanks..

Share this post


Link to post
Share on other sites
You still seem to have some confusion with regards to SDL. SDL is in no way a substitute for OpenGL, and vice versa. Typically, when people use SDL and OpenGL together, SDL is used to simplify creation of a window and surfaces for OpenGL to render to, because OpenGL doesn''t supply routines to do those things. Another utility library exists to simplify the window creation process(among other things), it''s called glut. Regardless, if you want to learn OpenGL, just head over to nehe.gamedev.net. And trust me, you will very doubtfully use SDL alone to make a video game.

Share this post


Link to post
Share on other sites
SDL is optimized for 2D. OpenGl is not.
You have to worry about a lot of different things that SDL does for you.

There are hundreds of "2d in a 3d api" threads because it is not simple.
But you are right: it is possible.

Glut often has to be hacked ... for example if you want to use your own game loop.
I prefer GLFW. It gives you more control.

[edited by - Clueless on May 27, 2004 12:58:24 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Clueless
SDL is optimized for 2D. OpenGl is not.
You have to worry about a lot of different things that SDL does for you.

There are hundreds of "2d in a 3d api" threads because it is not simple.
But you are right: it is possible.

Glut often has to be hacked ... for example if you want to use your own game loop.
I prefer GLFW. It gives you more control.

[edited by - Clueless on May 27, 2004 12:58:24 PM]


If you look at some of sdlprorammers posts you''ll see that he''s asked about more than 2d.

Share this post


Link to post
Share on other sites
Well.. if i am not going to use 3D i am not going to have to learn OpenGl ( at least not now ). So i guess the question is, what 3D graphics are? If rotating a shape is considered to be 3D, then what is not? After all, someone could use a picture which is 3D, and just blit it to the screen. is that 3D? I think you get my point...

thanks

Share this post


Link to post
Share on other sites
If you do all 2d stuff, especially just displaying bitmap data, then no you don''t need OpenGL. But in OpenGL/Direct3D etc., the process of turning a 3D primitive(lines, points, etc.) into a 2D one is the whole goal, and it isn''t something that SDL can do. There is a lot of math involved in turning 3D scenes into 2D scenes, there is considerably less involved in moving around 2D data on a screen.

Share this post


Link to post
Share on other sites
quote:
Original post by sdlprorammer
Well.. if i am not going to use 3D i am not going to have to learn OpenGl ( at least not now ). So i guess the question is, what 3D graphics are? If rotating a shape is considered to be 3D, then what is not? After all, someone could use a picture which is 3D, and just blit it to the screen. is that 3D? I think you get my point...

thanks


3D graphics means that the data is actually in 3d space, the points on the screen arn''t x,y they''re x,y,z. 3D graphics is used in a LOT of things, but by no means is it the only way to get a cool game. Just look at things Ambrosia has made, like EV:Nova.
As for the original question, SDL is a very cool, very easy way to set up EVERYTHING you need to play with your computer and make games. Its easy to learn. One of the reasons it''s so cool is that it allows you to access all the 3D graphics stuff that OpenGL does, but still make it nice and simple to set up.
Having said that, don''t try to say "I want SDL, but not OpenGL, or I want OpenGL but SDL sucks!" Use SDL to get to OpenGL, then smile at how cool you are!
Have fun dude!

--------------------------------------------------------
Life would be so much easier if we could just get the source code.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
3d graphics deal with 3d space and 3d ideas like vectors and other three dimensional theories. For instance, the Z-buffer is "free" - you only have to tell openGL that one object is behind another, and it does all the clipping and distance drawing and (yadda yadda yadda) for you.

2d space deals with relatively simple concepts like two dimensional planes. There is no Z buffer. You have to handle the Z-order of your objects yourself, for instance.

You spelled your name wrong, by the way.

Share this post


Link to post
Share on other sites