OpenGL made game source?

OpenGL made game source?

Postby truceey » 10 Jul 2019, 13:48

Hi all,
was wondering if anyone knows where I can get some source code for a fully functioning OpenGL game?
I just wanted to flick through some code to see how people tackle certain issues as I’m deciding whether to use OpenGL for a big project soon or use a commercial game engine instead (i’d prefer opengl). Any game will do!
truceey
 
Posts: 2
Joined: 10 Jul 2019, 13:41

Re: OpenGL made game source?

Postby dulsi » 11 Jul 2019, 13:00

ID has released the source code to old Doom/Quake games. SuperTuxKart and Minetest use OpenGL. SDL2 uses OpenGL for it's 2D graphics so technically a lot of games meet your criteria but I suspect you want a 3D engine. I believe Ogre and Cube use OpenGL.
dulsi
 
Posts: 298
Joined: 18 Feb 2016, 15:24

Re: OpenGL made game source?

Postby fluffrabbit » 11 Jul 2019, 13:39

More precisely, the Darkplaces engine and the Cube2 engine have their own OpenGL renderers targeting OpenGL 2.0+. The vast majority of games use somebody else's abstracted stuff so are not valuable to learn from. Sauerbraten (the Cube2 game) is probably one of the best places to look for a from-the-ground-up OpenGL game, though the author of the engine is a pretty hardcore software engineer so it's probably not great tutorial code.

I'm using my own OpenGL engine for several unfinished games, so although I understand OpenGL I can't say I understand game design. General best practices are to read as much as you can, target OpenGL 3.3 with the "core profile", and avoid GLUT like the plague. I'm assuming you've already found learnopengl.com, which provides a pretty good set of tutorials as well as a PDF version of the site.

However, if your computer supports it, why not give Vulkan a shot instead?
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby smcameron » 11 Jul 2019, 14:19

Space Nerds in Space uses OpenGL, but it is probably far from what would be considered exemplary. (it's linux only, missing shadow mapping and dynamic loading of assets, and written in C, for a start.) Edit, oh yeah, there is something like a guide to the code, although it doesn't touch on the renderer very much, it's more concerned with how all the various larger pieces fit together.
smcameron
 
Posts: 296
Joined: 29 Oct 2010, 23:44

Re: OpenGL made game source?

Postby Lyberta » 11 Jul 2019, 15:06

In 2019 I'd say consider Vulkan first, then OpenGL. Also I'd say that game engine is so much more than graphics API. It takes several years of full time work and a lot of experience to write a good game engine.

I was foolish and started to write my own engine in 2010. It's 2019 and I don't have a playable game yet. Sure, I learned a lot. But if you actually want to make a game I'd suggest going with someone else's engine.
⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧
User avatar
Lyberta
 
Posts: 591
Joined: 19 Jun 2013, 10:45

Re: OpenGL made game source?

Postby fluffrabbit » 11 Jul 2019, 16:44

I was foolish and started to write my own engine in 2010. It's 2019 and I don't have a playable game yet.

And I thought I was slow!

Generally, a high-level graphics engine like Ogre is a quicker start than a low-level graphics API like OpenGL or Vulkan. Panda3D is definitely worth checking out at a new-ish Ogre alternative. With those engines you can write GLSL shaders just as you would with a lower-level API, so you gain similar experience but with less fuss. Of course you miss out on a lot of important computer science concepts that way (memory management, client/server function calls, how inter-processor connections limit your speed) but I think most folks will still be impressed if you use Ogre or Panda, certainly moreso than with Unity.
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby drummyfish » 12 Jul 2019, 17:43

As others say, very often projects use a higher-level engine, which often allow to choose the back-end, which can be OpenGL but also Direct3D (booo) or even a software renderer.

OpenSceneGraph is a great engine built on top of OpenGL. I used to work with it when contributing to OpenMW -- take a look at that project, it is open source and since OSG is built on top of OpenGL, they have GLSL (OpenGL) shaders etc. Other engines you might want to check out include Irrlicht, Ogre or Panda3D.

If you want just the OpenGL games, libregamewiki has a category of such games (https://libregamewiki.org/Category:OpenGL_games), but there is only a few games actually. Let me find some other ones:

OpenRW: https://github.com/rwengine/openrw/tree ... src/render
Neverball: https://github.com/Neverball/neverball
BlackVoxel: https://github.com/Blackvoxel/Blackvoxe ... master/src
0 A.D.: https://svn.wildfiregames.com/public/ps ... /renderer/
socialist anarcho-pacifist
Abolish all IP laws. Use CC0.
http://www.tastyfish.cz
User avatar
drummyfish
 
Posts: 205
Joined: 29 Jul 2018, 20:30
Location: Moravia

Re: OpenGL made game source?

Postby fluffrabbit » 13 Jul 2019, 01:28

Don't use Irrlicht. It doesn't play well with window managers.

Pands3D and OGRE are both valid choices. OSG is just kinda...I dunno. I looked into it in the past but it doesn't seem geared towards commercial games. A hierarchical scene tree is a trivial recursive function with matrix multiplication, so having "scene graph" as part of the name implies OSG does very little for the bloat it adds. Commercial games need a lower cost-benefit ratio. If it's just some random hobby project though, use whatever.
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby dulsi » 13 Jul 2019, 02:07

fluffrabbit {l Wrote}:Don't use Irrlicht. It doesn't play well with window managers.

Minetest and SuperTuxKart use Irrlicht. I haven't had any problem with them.
dulsi
 
Posts: 298
Joined: 18 Feb 2016, 15:24

Re: OpenGL made game source?

Postby fluffrabbit » 13 Jul 2019, 05:00

dulsi {l Wrote}:
fluffrabbit {l Wrote}:Don't use Irrlicht. It doesn't play well with window managers.

Minetest and SuperTuxKart use Irrlicht. I haven't had any problem with them.

SuperTuxKart uses its own renderer forked from Irrlicht and Minetest runs windowed rather than fullscreen. If you straight up ported an FPS from Panda, Ogre, or OSG to Irrlicht, it would be significantly worse user experience.
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby Lyberta » 13 Jul 2019, 07:24

Minetest can run fullscreen but it forces 60 Hz so I run windowed.
⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧⚧
User avatar
Lyberta
 
Posts: 591
Joined: 19 Jun 2013, 10:45

Re: OpenGL made game source?

Postby fluffrabbit » 13 Jul 2019, 09:25

Lyberta {l Wrote}:Minetest can run fullscreen but it forces 60 Hz so I run windowed.

Not in 0.4.16. Anyways I can't say the refresh rate issue surprises me.
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby drummyfish » 13 Jul 2019, 22:03

fluffrabbit {l Wrote}:A hierarchical scene tree is a trivial recursive function with matrix multiplication, so having "scene graph" as part of the name implies OSG does very little for the bloat it adds.


Don't forget that scene graph isn't just a hierarchy of transformations -- that really is the trivial stuff -- it's many other things like culling, inheritance of rendering attributes etc. These are non-trivial, because you e.g. have to group the nodes before rendering to minimize switching between states etc. It is kind of bloated... as most things written in C++... but it's still better than many other engines and good if you can really benefit from the scene graph. It's true though that a lot of people use it when a simpler engine would be more appropriate.

Irrlicht is a bit awkward with a lot of shortcomings, a lot of times it serves as a base for a custom fork rather than a complete solution (e.g. STK engine as you say). The main advantage of it is that it's pretty beginner friendly, but that is not what OP is looking for.
socialist anarcho-pacifist
Abolish all IP laws. Use CC0.
http://www.tastyfish.cz
User avatar
drummyfish
 
Posts: 205
Joined: 29 Jul 2018, 20:30
Location: Moravia

Re: OpenGL made game source?

Postby fluffrabbit » 14 Jul 2019, 01:21

While OSG does optimize the rendering, sometimes it is desirable to construct the rendering order manually to pull off certain effects in a forward pipeline, which OSG hides. If you're doing water, glass, particles, and compound models that combine all of these things, OSG's preferred rendering order may not be your preferred rendering order. If you construct the scene tree renderer yourself you have control over all of those things.

Panda3D is pretty much a total replacement for Irrlicht these days, though I have yet to play with it.
fluffrabbit
 
Posts: 482
Joined: 11 Apr 2019, 11:17

Re: OpenGL made game source?

Postby drummyfish » 15 Jul 2019, 16:55

OSG's rendering order can be customized by using render bins:

http://www.vis-sim.com/osg/osg_faq_2.htm#f74

it's really a pretty advanced library. The only downside is really just the bloat, limitation to (and of) OpenGL, and occasional bugs and performance issues in some extensions I think, but that's mostly in some pretty specific cases (I remember OpenMW forked OSG to optimize its performance for the project).
socialist anarcho-pacifist
Abolish all IP laws. Use CC0.
http://www.tastyfish.cz
User avatar
drummyfish
 
Posts: 205
Joined: 29 Jul 2018, 20:30
Location: Moravia

Who is online

Users browsing this forum: dulsi and 1 guest