Join 119,059 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,437 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!
Many people say I should learn SDL, but I now wonder if it is possible to create the graphics in games with "plain" OpenGL. Without libraries like SDL.
Everyone I ask do not say anything about this only that I should learn how to use SDL but I prefer not to. I want to learn how to use OpenGL without third-party libraries. So if anyone have knowledge of OpenGL please answer my question.
Instead of creating two threads I ask another question here To create a multilayer tile engine does "plain" 2D works then? Or should I use 3D in a "2D-way"?
My developing machine can't handle all 3D at the moment due to that my graphic card is damaged. Some 3D it can handle some it don't render correctly. So I prefer to know before I embark on my journey to learn to use a API.
Depending on what you want to do in the way of making games i would suggest you learn as much as you can, and learn what speeds up the development process, SDL can be a real asset as it is a library created for programs such as games, whereas OpenGL is just for graphics. Even if you learned a lot about OpenGL your still going to at some point have to wrap that all up into something usable and interesting.
For example I recently created a game using OpenGL for graphics but I still had to understand all the fundamentals of collision detection and create something seperate to OpenGL to keep track of this. OpenGL as the name suggests is still a graphics library it is just a lot more low level than purpose built engines such as DarkGDK and Irrlicht. Using SDL for your window creation and other things such as event handling is a hell of a lot easier than writing your own way of doing these things, trust me.
So OpenGL will get your lovely 3D graphics on screen (albeit with the help of GLUT or SDL) but you wont be able to actually make them do anything without understanding a lot of other things.
Read gabehabes tutorials on creating a small game in SDL ,then once you understand how SDL works it shouldnt be all that difficult for you to learn some OpenGL and use this knowledge in SDL programs.
sorry if that was hard to understand, just ask if theres something your not sure on good luck
Hi thanks for the reply. I read at the SDL page and it say "Simple DirectMedia Layer is a cross- platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer."
But the main functions I want to have is Keyboard, mouse and use 2D graphics with support for multiply layers. GLUT have support for keyboard functions and OGL to draw tiles and sprites.
So if we don't talk about the graphics but things like creating a Window. I have winmain and it's possible to create and draw a window with OGL.
So it should be possible to use only OGL and C++? Or am I wrong?
I would recommend, first fixing your graphical problems, if your video card/computer has rendering problems, it will be a head ache developing anything.
But once you have your video card working. Think about were you would like to go for game devolopment in the future. OpenGL is extremely easy to start off with in C++ (Im proof, if i can get the hang of it anyone can). maybe spend some time in the basics of DirectX aswell. There are pro's and con's to both, but either way there both great.
If you dont really consider yourself making 3d games in the future, why not just stick to SDL. the only problem with openGL is finding a way to handle sound, and such. but thats not really a problem (IMO) as i prefer to learn each aspect of devolopment seperately.
But either way, fix your computer first. Indulge a lil, you only live once. whats a new video card gonna hurt? Plus once you invest money into your projects it helps to modivate to continue.
Well yes it is entirely possible to create something using just OpenGL and C++ except you will need some sound libraries eventually and i would recommend using GLUT for your window creation and keyboard functions.
I just wonder do you really want to make this design choice?
if you decide against using SDL and want to use winmain for your window creation, you have already decided that your game is windows only. Do you think SDL is cheating somehow?
If your learning C++ then SDL is relatively easy to learn, cross platform and can be used to develop commercial products without a charge, its win, win, win and the help available for it is excellent.
If this is the way you want to code your game then don't let anyone stop you, but think your options through don't limit yourself from the start
OpenGL does not handle window management or user input. That means for example, in Linux with X11 you have to use GLX to create/manage windows.
Edit: Sorry, just realized that you seem to already understand this.
What you're probably more interested in is GLUT, which is a crossplatform extension to OpenGL which handles all of the above.
OpenGL and GLUT pretty much take care of user input and graphics.
For sound I recommend OpenAL.
You'll have to write your own code for things like collision detection (unless you want to bring in more outside dependencies).
If you're just a beginner, all of this might be a little overwhelming. You may want to stick with SDL, or possibly even something a little higher level.
Edit: While I'm not saying you HAVE to write crossplatform code, I highly recommend trying to. It's not that hard, and you won't be kicking yourself in the butt later when you decide you want to port it.
This post has been edited by Tom9729: 5 Aug, 2008 - 10:39 AM
No no to create a window is possible with GLUT too, so winmain is not my only choice. I guess I don't need a NASA windows handler to get a game up and running =P
CODE
#include <GL/gl.h> //include the gl header file #include <GL/glut.h> //include the glut header file
The reason I do not want to learn SDL is that I do not think professional companies uses SDL. Either they have something else or something they self has developed (if they use OGL).
So I prefer to learn how to cope with OGL without third-party libraries. It has nothing to do with cheating.
Feel free to tell me if I am wrong about SDL in the professional business. I am learning this due to that I will go study at the University. So I want to have a bit more flesh on the bones ("Lite mer kött på benen") A expression here. So I don't wanna waste time learning stuff that will be obsolete at the university. I hope you see my point =P
Oh by the way, at the moment I will not use sound or network support yet. And for this project I planning now will not use sound.
This post has been edited by FrozenSnake: 5 Aug, 2008 - 11:08 AM
The reason I do not want to learn SDL is that I do not think professional companies uses SDL. Either they have something else or something they self has developed (if they use OGL).
So I prefer to learn how to cope with OGL without third-party libraries. It has nothing to do with cheating.
Feel free to tell me if I am wrong about SDL in the professional business. I am learning this due to that I will go study at the University. So I want to have a bit more flesh on the bones ("Lite mer kött på benen") A expression here. So I don't wanna waste time learning stuff that will be obsolete at the university. I hope you see my point =P
Tom9729: Guess I can take a look at least. Then I ask you this, If we just look at the "what I can see" stuff In a game (not collision detection etc) Do I need SDL for that? Whats the pro's and con's not for a new programmer but for a professional.
bobjob: I have no interest at the moment in learn how to develop 3D so I do not see why I need to have a functional 3D card. I don't understand how ppl can't understand that <.< nothing personal but I always hear about "why don't you wanna do 3D?" I wanna develop a 2D not because it's "easier". But I want to do just that. A 2D game not 3D.
Tom9729: Guess I can take a look at least. Then I ask you this, If we just look at the "what I can see" stuff In a game (not collision detection etc) Do I need SDL for that? Whats the pro's and con's not for a new programmer but for a professional.
You don't "need" SDL for anything. It just helps simplify the development process.
The only reason I wouldn't go with something like SDL would be if I was trying to avoid dependencies on other libraries, or if it was a learning experience.
Basically if you go with plain OpenGL, you're going to be writing a lot of your own functions to do things like load textures and render the scene.
In OpenGL, "drawing" is done by rendering what are called primitives. In a 3d application, you would probably want to make the models (called "meshes") in a specialized program like 3d Studio Max or Maya, and then load them into your program. Even a complex mesh can be broken down into primitives (ie. triangles/squares).
OpenGL is for 3d graphics. You can do 2d graphics in it by simply ignoring the depth dimension. You would probably want to disable lighting too, or write your own lighting system (OpenGL has one built in). You could probably render "sprites" as textures on quads, maybe with some kind of alpha blending.
As "a professional" I would probably go with something like SDL, because (presumably) I would already know how much of the lower level stuff works, and would want to save time by not having to re-code all of it.
Edit: Just thought I'd add this, but SDL appears to have a system for 2d graphics built-in.
This post has been edited by Tom9729: 5 Aug, 2008 - 11:55 AM
I didnt mean 3d was important, nun the less openGL is optimised for 3D. The reason you should get your card fixed, is because openGL renders 2D in a very similar way (if not the same way) as it would render 3D. so if you card has problems rendering openGL on a 3D applications, expect there to be problems with a 2D openGL game.
just a side question: Have you got the latest video card drivers?
Tom9729: The reason I do not want to use other libraries is that I want to learn to work with OpenGL and maybe even create my own library one day. And not to be dependent on others. So basically its for the learning experience.
One thing I for sure want to do is to create my own 2D engine. Even if it is a looooong time before I have the necessary skills and knowledge
Bobjob: I have problem with some 3D games not all. EverQuest2, WoW, EVE Online is a few games I have problem with. Second Life is a game that works perfect. I checked what they use and I saw that SL used OpenGL. And my guess is that the others uses DirectX. Yes I have upgraded, downgraded and reinstalled (both drivers and OS).
The 2D type of game I want to do is either a "From the Top in a 45 degree angle" or sidescroller. The game I play now works perfekt on my computer so the development should be without problem with the graphics. At least if it renders correctly (not look like a mixed carrot x] )
This post has been edited by FrozenSnake: 6 Aug, 2008 - 06:33 AM