Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL Vs Monogame

Started by MyLastGamble Nov 20, 2014 at 6:22 AM 13 replies 15.2k views
Original Post
MyLastGamble
MyLastGamble

So after much thought and a few posts on this site, as well as watching the MicrosoftVirtualAcademy course where they show you Construct 2, Gamemaker and Unity, I decided the best thing for me at this moment is to take a step back and just use a framework to start learning some game development so I can get as much C# experience as I can as I really enjoy the hands on experience.

Now, upon further research, it appears that OpenGL and Monogame are similar, and I think I read that Monogame actually uses OpenGL? Is there a benefit to one or the other?

I have acquired two books on this subject, one uses OpenGL called C# Game Programming for Serious Game Design and the other uses Monogame, called Learn 2D Game Development with C#. Which should I start out in as a beginner game developer, OpenGL or Monogame and is there a better resource out there? It appears both books cover things like game math and physics pretty well, but the one using OpenGL may be a little more detailed, I've just browsed both books and haven't looked into it fully.

Thanks for any help!

Ashaman73
Ashaman73

They are different APIs/Frameworks. Monogame is based on Mono, the crossplattform version of the .NET framework. It might contain some 2d graphics capability, but to utilize 3d graphics capability you would need one of the 3d graphics APIs. Microsofts perferred way would be DirectX for .NET, but with Mono being crossplattform, OpenGL is the way to go for 3d graphics (DirectX is not crossplattform).

So, you might use Monogame to start coding your game, and it might be sufficient for 2d games, but once you want 3d, it seems you need OpenGL too.

Hodgman
Hodgman
OpenGL is an API for sending commands to the GPU.

MonoGame is basically a simplistic game engine -- a collection of APIs that deal with graphics, audio, asset loading, user input, etc...
Inside MonoGame's graphics components, it will use OpenGL to send commands to the GPU in order to draw things.
(n.b. Different platforms have different APIs for controlling the GPU, so actually, it will use OpenGL, OpenGL|ES, D3D11 via SharpDX or GNM depending on which platform you're using it on!)

OpenGL deals with low-level commands, like sending texture data to GPU memory, binding shaders, drawing triangles and projecting vertices.
MonoGame deals with high-level commands, like load this 3D model from disc, draw this 3D model to the screen.

If you want to learn how to control a GPU, then use OpenGL.
If you want to learn how to make games, use MonoGame.

DirectX is not crossplattform

Just to be pedantic tongue.png
D3D runs on: 3 game consoles (5 on DC, 9 on Xb360, 11 on XbOne), Windows Phones, and PCs (via Windows/Linux+Wine).
OpenGL runs on: only PCs (via Windows/Mac/Linux) and it's sister GL|ES runs on Android/iOS.
There's also emulation layers to run GL|ES on PC via D3D, and to run D3D on Mac/Linux/PS4 via GL/GNM.
So it depends on how you define cross-platform - depending on your target platforms, either could be more cross-platform than the other laugh.png
Mobile/PC devs will get most reuse by writing a shared GL & GL|ES engine (with ifdef's around the differences) and porting to consoles as a 2ndary concern.
Console/PC devs will get most reuse by writing a shared D3D engine (and porting to Sony) and porting to Mac/Linux/mobile as a 2ndary concern.
phil_t
phil_t

So, you might use Monogame to start coding your game, and it might be sufficient for 2d games, but once you want 3d, it seems you need OpenGL too.

Monogame is a full implementation of XNA on Mono, and as such includes all the 3d graphics APIs that are in XNA. These are wrappers over OpenGL or DirectX (depending on the platform).

sgt_barnes
sgt_barnes

D3D runs on: 3 game consoles, Windows Phones, and PCs (via Windows/Linux+Wine).

OpenGL runs on: only PCs (via Windows/Mac/Linux).

Oh! I never realized that!

This "OpenGL ES" thingy that I see on 90+% of all mobile phones and tablets is actually based on D3D and not OpenGL, then? ;-)

*SCNR*

BitMaster
BitMaster
No. OpenGL ES runs 'natively' on mobiles. A very common way to emulate OpenGL ES on desktop systems is to use ANGLE (which offers an OpenGL ES interface but renders internally using DirectX). The advantage is that you need less platform-specific code if you work on both desktop. Additionally some OpenGL drivers on desktop are horribly bad (especially when you move towards older cards on extremely casual gamer systems) and using ANGLE can work around that problem.
21st Century Moose
21st Century Moose

(sgt_barnes was joking)

The response was valid though....

A lot of folks say "cross-platform" when what they really mean is "Unix, Unix and more Unix".

One also needs to consider software platforms vs hardware platforms.

We can accept that OpenGL has better compatibility across software platforms (bearing in mind the caveats in Hodgman's post above).

But we must also accept that D3D has better compatibility across hardware platforms.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
MyLastGamble
MyLastGamble




Monogame is based on Mono, the crossplattform version of the .NET framework. It might contain some 2d graphics capability, but to utilize 3d graphics capability you would need one of the 3d graphics APIs. Microsofts perferred way would be DirectX for .NET, but with Mono being crossplattform, OpenGL is the way to go for 3d graphics

So if I want to make a 2D game, should I stick with Mono? Or can OpenGL be used for 2D graphics as well as 3D graphics?




MonoGame is basically a simplistic game engine -- a collection of APIs that deal with graphics, audio, asset loading, user input, etc...

I'm not sure I want to use even a simplistic game engine. I thought the game engine was the way for me to go, but after really looking into it I found them to be too much point and click and not enough actual coding. I really want to have full access to program user input, save states, collisions, etc on my own. While I know C# syntax I'm still trying to get use to all the useful classes and combining syntax to do certain things. I want as much hands on as possible when I make my games to give myself as much practice as possible, then in the future I can always move over to an engine of choice.

noodleBowl
noodleBowl

So if I want to make a 2D game, should I stick with Mono? Or can OpenGL be used for 2D graphics as well as 3D graphics?


OpenGL can do both 2D and 3D. I'm using OpenGL now and only focus on 2D

I'm not sure I want to use even a simplistic game engine. I thought the game engine was the way for me to go, but after really looking into it I found them to be too much point and click and not enough actual coding. I really want to have full access to program user input, save states, collisions, etc on my own. While I know C# syntax I'm still trying to get use to all the useful classes and combining syntax to do certain things. I want as much hands on as possible when I make my games to give myself as much practice as possible, then in the future I can always move over to an engine of choice.


Now this is based on my experiences

Originally when I started coding my games using "only code" I started with Microsoft's XNA which uses C#. And for me that was awesome! I wanted to do 2D games and it had everything I needed. Then when I heard Microsoft dropped XNA, I made the big leap to doing everything by myself from scratch. I ended up switching languages to C++ and moving to DirectX9, then to DirectX11, then to OpenGL for cross-platform support, then to OpenGL ES cause my friend was more comfortable do mobile stuff. And now I'm back at using OpenGL. So I have been across the spectrum of APIs and back. I have to admit doing things from scratch has definitely grown on me

I have noticed they all have one thing in common though. No matter what API (OpenGL or DirectX) you choose, when making things from scratch vs using a pre-made game engine/framework there is a huge learning curve. Don't get me wrong, I feel like I have become a better programmer and to me personally it has been rewarding. And I like the feeling that I get, that feeling of complete control. But you need to ask yourself the golden question:

Do you have the time and patience to make all the features you need and then all the features you want. When you know that those features are more than likely readily available in another game engine/framework? Plus the time and patience it takes to build and design your game on top of that?

Building a game in itself is a difficult task, which requires a starting point. And building this point from scratch is also a difficult task

MyLastGamble
MyLastGamble




Don't get me wrong, I feel like I have become a better programmer and to me personally it has been rewarding. And I like the feeling that I get, that feeling of complete control. But you need to ask yourself the golden question:

Do you have the time and patience to make all the features you need and then all the features you want. When you know that those features are more than likely readily available in another game engine/framework? Plus the time and patience it takes to build and design your game on top of that?

This is exactly why I am writing a game from scratch. I want to become a better programmer, and using something like OpenGl or Monogame, where some of the behind-the-scenes work is done for me but ultimately I have control, will help me overall become better. I'm writing a game for fun, but also to have a fun project to help increase my skill at programming. In the future, once I am comfortable in programming to where I don't need as much practice, I can try out an engine, but for now I feel I need to get my hands dirty and just code. :)

DvDmanDT
DvDmanDT

MonoGame is still rather low level. It's not a game engine, it just contains a lot more high-level stuff that is useful in game development. MonoGame can be used for 3D with an API that is very similar to Direct3D9. You still draw your own triangles and write your own shaders.

You can also use MonoGame for 2D stuff, but it's definitely not 2D only.

MonoGame will get you started faster, will be easier to port and work with and will most likely leave you in control over the things you actually care about. OpenGL is graphics only, MonoGame is graphics, sound, resource loading, math, networking and more. There's also alot more support and resources for using MonoGame than using OpenGL _with C#_ in my experience.

Hodgman
Hodgman
Every game is powered by a "game engine".
Drag'n'drop game-maker GUIs with visual scripting are not the only form of game engine.

If you choose to make a game without one, then you'll have built one by the time you're done.
The parts of your code that power the game, but aren't specific to the gameplay are "the engine".
Even if you make something simple like "pong" from scratch, you'll have built a "pong engine", which you can utilise to make other "pong-style" games, such as breakout.

I thought the game engine was the way for me to go, but after really looking into it I found them to be too much point and click and not enough actual coding. I really want to have full access to program user input, save states, collisions, etc on my own. While I know C# syntax I'm still trying to get use to all the useful classes and combining syntax to do certain things. I want as much hands on as possible when I make my games to give myself as much practice as possible, then in the future I can always move over to an engine of choice.

The first part isn't true - you'll still have to do a tonne of programming when using an existig engine.
If you don't use something like MonoGame, you'll just have to create your own version of it first, AND then build the game on top of your own "NotMonoGame" in exactly the same way that you would have done anyway.

As for the second part, if you're the kind of person who learns by doing, you'll probably be better off building your first games within existing, well designed, proven frameworks. Not only will you actually see results faster, but in the process of using these existing frameworks you'll be reading/using code written by expert game programmers, and gain a good understanding of how these base systems are often structured. Then later, when you try to build a game from scratch (AKA, buildnyour own engine) you'll already be a somewhat experienced game programmer, so you'll know what your engine should look like.

IMHO, trying to build an engine before you've built games is like trying to build a race-car before you've got a drivers license... Actually: before you've even ever driven in a car at all!
Sure it can be done, but an engineer/craftsman will do better to understand the users of their craft.

Even if your goal was to become a game-engine programmer, rather than a game programmer, I'd still advocate learning to make games on many different existing game engines first, so you understand the needs of your users (i.e. Game programmers) before trying to build your own engine.


Also don't underestimate the amount of work involved in either option.
When I worked in the games industry on low-budget games:
* when we used an existig engine, we had 2 engine programmers dedicated to modifying/maintaining that engine, plus a dozen gameplay programmers.
* when we used our own engine, we had two dozen engine/tools programmers and a dozen gameplay programmers.
For a simple 8-month game project, that's somewhere around 10 to 30 man-years of work, just on programming! Also, all of those staff had 5+ years of tertiary education/experience to begin with...

Completing any game as a 1-man band is a huge achievement to look forward to.
21st Century Moose
21st Century Moose
Or can OpenGL be used for 2D graphics as well as 3D graphics?

2D is just a special case of 3D.

With 3D, each point has a third co-ordinate (representing depth) (I'm simplifying a bit here) whereas with 2D that third co-ordinate is the same for all points. So anything that can do 3D can also do 2D, no problem at all.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls. 
MyLastGamble
MyLastGamble

Thanks everyone for the comments! As I'm new to this all and mostly just want to increase my C# skills I may try out both and see which one I prefer, and go from there. Thanks again for the help!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.