• Advertisement
Sign in to follow this  

OpenGL OpenGL Vs Monogame

This topic is 1185 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

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!

Share this post


Link to post
Share on other sites
Advertisement

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.

Edited by Ashaman73

Share this post


Link to post
Share on other sites
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. Edited by Hodgman

Share this post


Link to post
Share on other sites

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).

Edited by phil_t

Share this post


Link to post
Share on other sites

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*

Edited by sgt_barnes

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

(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.

Share this post


Link to post
Share on other sites


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. 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites


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. :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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!

Share this post


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

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By LifeArtist
      Good Evening,
      I want to make a 2D game which involves displaying some debug information. Especially for collision, enemy sights and so on ...
      First of I was thinking about all those shapes which I need will need for debugging purposes: circles, rectangles, lines, polygons.
      I am really stucked right now because of the fundamental question:
      Where do I store my vertices positions for each line (object)? Currently I am not using a model matrix because I am using orthographic projection and set the final position within the VBO. That means that if I add a new line I would have to expand the "points" array and re-upload (recall glBufferData) it every time. The other method would be to use a model matrix and a fixed vbo for a line but it would be also messy to exactly create a line from (0,0) to (100,20) calculating the rotation and scale to make it fit.
      If I proceed with option 1 "updating the array each frame" I was thinking of having 4 draw calls every frame for the lines vao, polygons vao and so on. 
      In addition to that I am planning to use some sort of ECS based architecture. So the other question would be:
      Should I treat those debug objects as entities/components?
      For me it would make sense to treat them as entities but that's creates a new issue with the previous array approach because it would have for example a transform and render component. A special render component for debug objects (no texture etc) ... For me the transform component is also just a matrix but how would I then define a line?
      Treating them as components would'nt be a good idea in my eyes because then I would always need an entity. Well entity is just an id !? So maybe its a component?
      Regards,
      LifeArtist
    • By QQemka
      Hello. I am coding a small thingy in my spare time. All i want to achieve is to load a heightmap (as the lowest possible walking terrain), some static meshes (elements of the environment) and a dynamic character (meaning i can move, collide with heightmap/static meshes and hold a varying item in a hand ). Got a bunch of questions, or rather problems i can't find solution to myself. Nearly all are deal with graphics/gpu, not the coding part. My c++ is on high enough level.
      Let's go:
      Heightmap - i obviously want it to be textured, size is hardcoded to 256x256 squares. I can't have one huge texture stretched over entire terrain cause every pixel would be enormous. Thats why i decided to use 2 specified textures. First will be a tileset consisting of 16 square tiles (u v range from 0 to 0.25 for first tile and so on) and second a 256x256 buffer with 0-15 value representing index of the tile from tileset for every heigtmap square. Problem is, how do i blend the edges nicely and make some computationally cheap changes so its not obvious there are only 16 tiles? Is it possible to generate such terrain with some existing program?
      Collisions - i want to use bounding sphere and aabb. But should i store them for a model or entity instance? Meaning i have 20 same trees spawned using the same tree model, but every entity got its own transformation (position, scale etc). Storing collision component per instance grats faster access + is precalculated and transformed (takes additional memory, but who cares?), so i stick with this, right? What should i do if object is dynamically rotated? The aabb is no longer aligned and calculating per vertex min/max everytime object rotates/scales is pretty expensive, right?
      Drawing aabb - problem similar to above (storing aabb data per instance or model). This time in my opinion per model is enough since every instance also does not have own vertex buffer but uses the shared one (so 20 trees share reference to one tree model). So rendering aabb is about taking the model's aabb, transforming with instance matrix and voila. What about aabb vertex buffer (this is more of a cosmetic question, just curious, bumped onto it in time of writing this). Is it better to make it as 8 points and index buffer (12 lines), or only 2 vertices with min/max x/y/z and having the shaders dynamically generate 6 other vertices and draw the box? Or maybe there should be just ONE 1x1x1 cube box template moved/scaled per entity?
      What if one model got a diffuse texture and a normal map, and other has only diffuse? Should i pass some bool flag to shader with that info, or just assume that my game supports only diffuse maps without fancy stuff?
      There were several more but i forgot/solved them at time of writing
      Thanks in advance
    • By RenanRR
      Hi All,
      I'm reading the tutorials from learnOpengl site (nice site) and I'm having a question on the camera (https://learnopengl.com/Getting-started/Camera).
      I always saw the camera being manipulated with the lookat, but in tutorial I saw the camera being changed through the MVP arrays, which do not seem to be camera, but rather the scene that changes:
      Vertex Shader:
      #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TexCoord = vec2(aTexCoord.x, aTexCoord.y); } then, the matrix manipulated:
      ..... glm::mat4 projection = glm::perspective(glm::radians(fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f); ourShader.setMat4("projection", projection); .... glm::mat4 view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); ourShader.setMat4("view", view); .... model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f)); ourShader.setMat4("model", model);  
      So, some doubts:
      - Why use it like that?
      - Is it okay to manipulate the camera that way?
      -in this way, are not the vertex's positions that changes instead of the camera?
      - I need to pass MVP to all shaders of object in my scenes ?
       
      What it seems, is that the camera stands still and the scenery that changes...
      it's right?
       
       
      Thank you
       
    • By dpadam450
      Sampling a floating point texture where the alpha channel holds 4-bytes of packed data into the float. I don't know how to cast the raw memory to treat it as an integer so I can perform bit-shifting operations.

      int rgbValue = int(textureSample.w);//4 bytes of data packed as color
      // algorithm might not be correct and endianness might need switching.
      vec3 extractedData = vec3(  rgbValue & 0xFF000000,  (rgbValue << 8) & 0xFF000000, (rgbValue << 16) & 0xFF000000);
      extractedData /= 255.0f;
    • By Devashish Khandelwal
      While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1.
      Anyone has any idea .. what should I do?
  • Advertisement