Jump to content
  • Advertisement
Sign in to follow this  
RunBerserk

how to chose open_gl libary?

This topic is 868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

how should I chose an open_gl library?

 

What I would like to do is an small 2D game C++ to learn open_gl again (I have some expirence with Java3D and C++)

something like space invaders/ asteroids...later extended to free moving and scrolling the world and more complexitity,buying weapons,skills,pathfinding,ai...

 

the game should works on cross platform(win,linux,raspi...if possible)

editor would be code::blocks I think, because it is lightweight

 

at the moment I read something about GLFW,SDL,SFML,GLUT

did some stuff with QT and OpenTK(C#) tutorials

 

what would be "the best" library? I would try GLFW for the next step

my goal with this game is to learn as much as possible about gl,mainloop,gamenegine from the scrath and switch later to udk or unity for other games

 

thx

Edited by RunBerserk

Share this post


Link to post
Share on other sites
Advertisement

You didn't really explain what you expect the library to do for you, especially if you want to learn about all this "from scratch". If that's your goal, I would truly do it from zero without any libraries. That said, I quite like SDL 2.x for handling windowing/input functionality across systems.

Edited by Promit

Share this post


Link to post
Share on other sites

My latest OpenGL project, where I did all the graphics from scratch, used:

 

https://www.libsdl.org/ - SDL for window and input

https://github.com/nothings/stb - stb_image to save png files

http://glm.g-truc.net/0.9.7/index.html - glm library for math

http://glew.sourceforge.net/ - glew for loading the OpenGL version

 

I've had no problems with Windows, Linux, or Mac so far.  These things work well, but get out of your way and let you code.

 

As you learn more, you can replace these libraries with your own code if you really want to understand everything, but it's just too hard to start from scratch when you've never done this before.

Share this post


Link to post
Share on other sites

I usually choose GLEW for handling opengl extensions, and glfw for the basic window / user input handling. Both of them are simple and stable APIs. If you want a more complete experience, SFML is also a good choice for windowing / input handling, and it works well together with glew.

 

I don't think using code::blocks is a good idea, if your primary development platform is windows, visual studio could be your main tool, and you can use visual studio code for the other platforms if you need to do some quick work there. (or atom, or sublime, whatever is your taste) Also check out cmake, waf or scons for building your application.

Share this post


Link to post
Share on other sites

For window management the most commonly used libraries are GLFW and SDL.

SDL offers a full-featured experience while GLFW is only for window and input.

http://www.libsdl.org

http://www.glfw.org

 

For OpenGL, the most widely used library is for sure GLEW, which I recommend, since loading OpenGL on your own takes a lot of effort.

http://glew.sourceforge.net

 

For image loading you can use SDL itself or stb_image, but if you want to learn everything you can use a lower level library like libpng and other libraries.

https://github.com/nothings/stb

 

For models, it seems that ASSIMP is really used, but I don't like it too much, their build system is messed up, however it can be a starting point (writing your own OBJ loader is a breeze and lets you learn a lot).

http://assimp.org

 

For math calculations, usually beginners go for GLM, which is header only and so slows down compile time a lot, but is straight-forward to setup.

It is not optimized really much but can get you great results, however you can try implementing common functions, it will help you learn linear algebra applied to videogames.

http://glm.g-truc.net

 

Writing your own modules can take a lot of time, but if you have a little team and you want to really understand everything, try writing some of the libraries you need, it will be worth the effort.

Share this post


Link to post
Share on other sites

Throw a coin.

 

EDIT: Omg I downvoted GlassKnife by mistake, sorry!  :unsure:

Edited by TheChubu

Share this post


Link to post
Share on other sites

I think I should start without any library with a bit 2D stuff, 'till I know what I need

and test 1-2 more common libraries a bit

at the moment I would choose SDL

Edited by RunBerserk

Share this post


Link to post
Share on other sites

I think I should start without any library with a bit 2D stuff, 'till I know what I need

and test 1-2 more common libraries a bit

at the moment I would choose SDL

 

Bad idea if you are a beginner.

 

You need an OS library (like GLFW), you need an extensions library (like GLEW), you need a math library (like GLM), and you need an image library (like STB), at a minimum. You're welcome to substitute SDL or any other library for any of these, but you need a minimum of 4 libraries starting out. This is going to be rough enough as it is without digging into the minutia.

 

I learned DirectX 11 by writing everything from scratch and it's not for the feint of heart. I already had a pretty good background for it. And it's a lot different than OGL, For example, you don't even have the concept of extensions in DX and the math library is built in. It only has rudimentary image support in DX and so I just conformed to what it wanted to be fed rather than trying to write an image library.

 

Writing an image library sounds like a multi-year project to me, especially if you know little to nothing about it going in.

 

I've never been big on writing your own math functions. Every platform out there has a math library of some type. Starting out, I'm not sure it's that helpful to write the math code. It's probably much more helpful to go read a book on the actual underlying math. Whether you can code it is largely irrelevant. Whether you understand it is what matters. I would take the 6 months you were going to spend coding a math library and read a book. Granted, you don't really get into this math much until you jump from 2D to 3D, but even in 2D you should learn to use vectors and trigonometry. (Taking a formal trigonometry class is probably the best way to learn the math. It won't cover matrices, but it will cover vectors and the math behind vectors albeit probably a bit too briefly.)

 

I did eventually write my own LookAt function to build a view matrix, and that was very educational. I then promptly went back to using the math library.

 

As for the OS, one of the main reasons people use OGL is that it is cross platform. In DX, I had to do all that OS stuff myself for Windows and it requires you to take a detour from game programming and everything else and learn Win32 (at least pre Win8 anyway). It's a pretty big thing if you've never done Win32 programming(I had actually written a few Win32 programs in C++ before and so it was all old hat for me since it doesn't get all that deep into Win32. You just ask for a process and declare a window to draw in.), and that's hard coding you to one OS. Get into multi-platform support and you've got a nightmare trying to learn the ins and outs of calling every OS you support. And get outside of the Windows world and no one does this. They all run straight for GLFW because they want cross platform compatibility, and don't want to spend years learning OS programming.

 

I haven't tried wrangling the extensions myself, but it sounds rather complicated to the point that everyone out there seems to go straight for GLEW. There doesn't seem to be much point in re-inventing the wheel and doing this yourself.

 

SDL probably can cover some of the ground of a couple of these libraries. There's nothing wrong with that. It sounds to me like a really good choice if you want to do 2D. My point is that you need libraries to cover those 4 things regardless of which libraries you choose. SDL doesn't do 3D, and I only do 3D, which is the reason I didn't go with SDL. You could probably use SDL with OGL 3D to handle windowing and such, but I just went with GLFW. I don't have enough OGL experience to tell you which libraries are the best, but I do know you need libraries to cover those 4 areas minimum regardless of what libraries you use.

 

I guess my point is that re-writing this libraries would be an academic exercise, best left for game programmers who are at least at the intermediate level. Beginners should just load up these libraries and be done with it. Then you can focus on game programming rather than on stuff that has little to nothing to do with game programming, but is necessary, like loading an image file.

Edited by BBeck

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!