# OpenGL SlimDX, MDX or OGL?

## Recommended Posts

mickliddy    100
I had a look around the forums, so forgive me if Ive missed something about this already. Ive been programing in C# for the past year or so, and Ive started looking at trying my hand at building a game. However, I'm not exactly sure what which way to go. Ive heard alot of people say to use C++ instead of C#. But I already know a decent amount of C# and am comfortable with it. So, should I stick with C# or try C++? Should I try and use the OpenGL, DirectX/MDX or SlimDX?

##### Share on other sites
Take my words with a grain of salt, as I'm a C++ DirectX programmer (before using DX I was on OGL side), so I'm not into MDX/SlimDX, etc.

As for OpenGL/DirectX you can find many threads here. In the end it's up to you.

AFAIK MDX is dead, so I wouldn't suggest you to use it. SlimDX could be a better option but if you already know C#, I suggest you to have a look at XNA.

##### Share on other sites
FeverGames    126
i wonder why you say he should take a look at xna. Xna isn't exactually an industry standard way of working, it is a premade sort of engine in which a lot is not possible because it is based on development for the 360, and secondary for the PC.

so i do not agree that XNA is better if you already have knowledge of C# over SlimDX, i'd rather take the opposite. If you have little knowledge of C# XNa is great to get lots done in notime, but SlimDX gives you way more freedom because it has nothing premade, except the fact that you can do all the DX calls like is done in C++.

but thats my word.

##### Share on other sites
Evil Steve    2017
I'd suggest sticking with C# and learning XNA too.

C# is perfectly fine for game development, although it's limited to Microsoft platforms. C++ is still the main language used in the industry, but it's best to learn one thing at a time and learn XNA, then look at C++ if you want.

And if you're a C# person, you'll most likely be comfortable with XNA/DirectX than with OpenGL.

##### Share on other sites
dilyan_rusev    1360
I myself am a .NET developer, but I've been programming with C++ for years as well, so I can give you some advice. Your productivity will increase a lot if you use C# instead of C++. Some reasons to do so:
1) First, and most important of all, the .NET framework. In C++ you need a threading library, a sound library, a graphics library, etc... Plus, boost sucks. It just tries to emulate things that C++ wasn't meant for. In .NET, however, everything is there for free - just name it: garbage collector, network library on top of sockets (plus them if you need them), continual improvement, ridiculously easy multithreading and synchronization... If you want to build your graphical tools - WinForms and WPF are there waiting for you. And everything is well integrated.
2) Productivity. C++ is not meant to be a robust language (I mean for RAD). C#, however, is designed for that. The least of all is garbage collection. In C#, you can remove all elements of a collection given some predicate in just one line of code (IEnumerable's extension methods + lambda expression). You will never worry about simulating a sprintf behaviour in C# - it is just adding the params keyword before the last argument. These are just very simple examples - but in C++ you don't even have descent exception mechanism, using exceptions is even considered highly ineffective. For example, there is no such thing as finally. In C++ your destructor is not always called. So, your program crashes and there is a pretty good chance to leave lots of resources unfreed. Cool, huh?
3) Events and component-driven programming. In C++ you can emulate this behaviour with boost (which sucks IMO), Qt's signals and slots, Gtkmm's signals and slots (the last two being extremely intuitive and nice to use; boost claims to have improved gtkmm, but in reality it just made something very nice into a complete disaster). However, the resulting code is ugly and it is not very easy to get started, because all the examples online are extremely simple and if you need something complicated, you are left on your own and you will lose lots of time of research for something that is a-matter-of-fact in C#. Look at System.Collections.ComponentModel.ObservableCollection and see what I mean. You can do it in C++, but you will lose a lot of time before you even start coding for something as simple as that. In boost's signals you don't have the full control of an event's add and remove overides (just as a property's get and set if you've never customized an event). Something essential for component-driven programming (well, objects in games to tend to be componets with events, properties and all) is data binding, which is something you have to emulate on your own in C++ (not that it is difficult, but every time you have to emulate a feature, there is a chance that you make a mistake somewhere, and most importantly - you lose time).
4. Visual studio. It is free for both C++ and C#. However, code completion in C++ isn't good at all. It is the best there is (Eclipse CDT is very close, however), but it still isn't as good. Microsoft is investing a lot of money in .NET, and I'm left with the feeling that they just neglect C++. There are .net-only features in Visual Studio, which I find invaluable. For example, before you start coding, you have some sort of design for your game. Well, you can visually (via drag&drop) create a class diagram, and the tool generates the skeleton code for you. Every method is "implemented" with throw new NotImplementedException(), so you can't forget to implement them :D. There are very nice shortcuts: automatic add of a using statement, make a property out of a field, rename using refractor, etc. Templates are very time-saving as well: type for, the double-press tab, and it generates the skeleton for you. The same for all code structures. There is a shortcut for automatic interface and abstract class implementation (skeleton).

In conclusion, productivity in C++ is just not good enough once you've been used to C# and .NET. I would use C# or Python for my projects over C++ anytime. If you want to use C# and OpenGL, you can try OpenTK - it seems very SDL-like (and is therefore very nice). For DirectX, you were told: XNA is very beginner-friendly.

##### Share on other sites
FeverGames    126
Just to add, SlimDX is nowdays good to use for development. It is (at least in my experience) stable and is not going to change _hughe_. But to be sure some of their developers should tell you these things.

if you are a beginner XNA is great. It depends on your needs as well. Are you going to develop an engine or are you going to make a simple scene with some effects, without bothering how it all actually works inside out...

##### Share on other sites
Scet    960
Quote:
 Original post by Evil SteveC# is perfectly fine for game development, although it's limited to Microsoft platforms.

Come on Steve, you're smarter than that. C# isn't limited to Microsoft, I've seen C# games running on a Mac OS. Portability depends on what APIs you use, not the language. You'd have to use Mono instead of .NET and use Tao instead of DirectX.

SlimDX - Windows
XNA - Windows, XBOX360, Zune
OpenGL - Windows, Mac, Linux

Not trying to say SlimDX is bad, I actually prefer it to the others. It just isn't as portable. If you don't care about that than give it a try.

##### Share on other sites
Evil Steve    2017
Quote:
Original post by Scet
Quote:
 Original post by Evil SteveC# is perfectly fine for game development, although it's limited to Microsoft platforms.

Come on Steve, you're smarter than that. C# isn't limited to Microsoft, I've seen C# games running on a Mac OS. Portability depends on what APIs you use, not the language. You'd have to use Mono instead of .NET and use Tao instead of DirectX.
You're right, I was having some sort of brain fart [embarrass]

I should have said, it's not available on as many platforms as C++ is.

##### Share on other sites
MJP    19789
Quote:
 Original post by FeverGamesi wonder why you say he should take a look at xna. Xna isn't exactually an industry standard way of working, it is a premade sort of engine in which a lot is not possible because it is based on development for the 360, and secondary for the PC.

Whoa whoa whoa whoa let's hit the breaks and back up a bit here.

XNA is not an engine or anything close to it. It has a few optional components like the Game class and the Content Pipeline that could be parts of a much larger engine, but if so they would be a small part of it.

What is it that you think is "not possible" with it? On the PC side of things the Graphics component is a wrapper of D3D9. The only things you can't do are the vendor-specific hacks, which off the top of my head included Nvidia's hardware shadow maps, ATI's R2VB, and any of the old methods for binding the depth buffer as a texture. Not exactly deal breakers, IMO (especially when you consider that you gain compatibility with a console for those things).

As for your assertion that it's "based on development for the 360", I'm a little curious as to what leads you to say that. If you ask me or any of the other guys who develop for the 360 using XNA, I doubt you'll find any that wouldn't agree that the PC is a much better choice for running a managed framework.

##### Share on other sites
FeverGames    126
i say this because if you start implementing things like low level audio api's or world wide used physics engines you are not going to be able to deploy it on the 360 anymore, which is kind of a big part of the whole xna thing. Also it doesn't allow you to easily swap to stuff like DX10 or DX11 in future, if not never.

ok so XNA might not be an engine, but it does do lots of things for you which you might not want.

but this might go a bit to much offtopic. I am just not a big fan of XNA :) It's a great way to start fast with 3D and get results fast on both the Xbox and pc. Just don't pass the lines that microsoft gives you (audio specific, physics specific, scripting languages other then written in .NET) :)

##### Share on other sites
mickliddy    100
Awesome, thanks guys :) Explained alot there Dilyan, ty for that :) I was always told that C++ was the better language, but your explanation has alot more backing it up that the 'just cause' that I was told when I asked y :)
So, that leaves it at XNA/SlimDX/OpenGL. Is XNA a library(like MDX)? or more like MSVS? If I decided to use XNA/SlimDX whats compatabillity like with OGL? Can I create my own functions that utilise both without too much difficulty, or should they stay more-or-less apart?

##### Share on other sites
Flimflam    665
Quote:
 Original post by mickliddyAwesome, thanks guys :) Explained alot there Dilyan, ty for that :) I was always told that C++ was the better language, but your explanation has alot more backing it up that the 'just cause' that I was told when I asked y :)So, that leaves it at XNA/SlimDX/OpenGL. Is XNA a library(like MDX)? or more like MSVS? If I decided to use XNA/SlimDX whats compatabillity like with OGL? Can I create my own functions that utilise both without too much difficulty, or should they stay more-or-less apart?

XNA is a library like Managed DirectX. The only caveat is you need to distribute the XNA runtime with the things you make if you wish to distribute them, where as the old MDX came pre-packaged with DirectX.

I'm not quite sure what you're asking about compatibility, though. Are you asking if the different api can work together? If so, I'd say more or less no. You wouldn't want to combine them with the same project. You could use different ones for different tools, obviously, but I don't see why you would work with multiple libraries.

If you're just asking for a comparison between the compatibility with SlimDX/XNA and OpenGL, then OpenGL is by far the most cross-platform compatible api. SlimDX and XNA are pretty much limited to Windows (XNA stuff can be deployed on the Xbox360/Zune) machines while OpenGL enjoys deployment on Mac, Linux, and Windows alike.

##### Share on other sites
mickliddy    100
Asking more if I build using SlimDX, can I also use OGL if I decide that Id like more platforms to be supported? I know very little about SDX, but if I say create a graphics device with SDX and then got it to 'do stuff'(yes I know, this is very descriptive... I did say I knew very little) - such as drawing some triangles and then rendering, can I do something like...
var UGC = Users Graphics Choiceswitch(UGC)     case:SDX          //SDX Code to Set up device goes here.          break;     case:OGL          //OGL code that does the equivalent goes here.          break;     case:Hasnt Chosen          //Do something elsewhile(game is running){     if(UGC=SDX)     {          Draw what needs to be drawn here with SDX     }else{          Draw what needs to be drawn here with OGL     }}

##### Share on other sites
Flimflam    665
You can do that, yes. However if you do decide you want to support more api, I would highly recommend you encapsulate the separate renderers into separate plugin modules or something and create some sort of unified rendering scheme for drawing. Having two totally different sets of rendering code in one area would look confusing as hell.

##### Share on other sites
mickliddy    100
awesome, thanks everyone for the replies :)
Ive decided to go with C#, and use SDX with the possibility of adding OGL at a later date. Maybe if Im lucky Ill have a few people who like the end-product xD

##### Share on other sites
MJP    19789
Quote:
 Original post by FeverGamesi say this because if you start implementing things like low level audio api's or world wide used physics engines you are not going to be able to deploy it on the 360 anymore, which is kind of a big part of the whole xna thing. Also it doesn't allow you to easily swap to stuff like DX10 or DX11 in future, if not never. ok so XNA might not be an engine, but it does do lots of things for you which you might not want.but this might go a bit to much offtopic. I am just not a big fan of XNA :) It's a great way to start fast with 3D and get results fast on both the Xbox and pc. Just don't pass the lines that microsoft gives you (audio specific, physics specific, scripting languages other then written in .NET) :)

Well we're obviously talking about the PC here (since we're comparing XNA with SlimDX, OpenGL, etc.) so I'm not sure how the restrictions of the 360 runtime environment apply. On the PC you have your choice to use whatever components of XNA you want. You're not at all limited in terms of physics, audio API's, or any of the other things you mentioned.

##### Share on other sites
mickliddy    100
well, I just got SDX and was having a mess around with it, when I noticed that it seems to lack a representative for DirectX.AudioVideoPlayback... is there any particular way that I should go about playing back AVI files(without having to pay an arm and a leg for BINK), or is this just very well hidden inside the SDK?

##### Share on other sites
amethyste    138
But XNA can make a good game with good performances ?

"XNA vs SlimDX" is good title for a benchmark or the capacities.

and C++ versus the winner ...

##### Share on other sites
MJP    19789
Quote:
 Original post by amethysteBut XNA can make a good game with good performances ?

Of course. Why would it not be able to?

##### Share on other sites
Mike.Popoloski    3258
Quote:
 Original post by mickliddywell, I just got SDX and was having a mess around with it, when I noticed that it seems to lack a representative for DirectX.AudioVideoPlayback... is there any particular way that I should go about playing back AVI files(without having to pay an arm and a leg for BINK), or is this just very well hidden inside the SDK?

As of now, the preferred method is to use DirectShow.Net, which is a separate project that wraps DirectShow; DirectX.AudioVideoPlayback is based off of that, IIRC. We may add some video support in the future, but for now it's not on the menu.

mickliddy    100
Thanx :)

##### Share on other sites
FeverGames    126
i think if you want to 'wrap' two different api's together you want to go for the most low level api's like DX and OpenGL, since XNA comes with quite a few premade classes. If you want to be able to run a game on a platform that doesn't support .NET you have to be able to not use XNA as a reference (so you cannot use the premade classes from xna). Of course you can also simply not use the premade classes but then for me it sounds weird to use XNA, but that's more of a feeling than performance or anything other decision for me. of course it is all doable ;)

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ## Partner Spotlight

• ### Similar Content

• I assumed that if a shader is computationally expensive then the execution is just slower. But running the following GLSL FS instead just crashes
void main() { float x = 0; float y = 0; int sum = 0; for (float x = 0; x < 10; x += 0.00005) { for (float y = 0; y < 10; y += 0.00005) { sum++; } } fragColor = vec4(1, 1, 1 , 1.0); } with unhandled exception in nvoglv32.dll. Are there any hard limits on the number of steps/time that a shader can take before it is shut down? I was thinking about implementing some time intensive computation in shaders where it would take on the order of seconds to compute a frame, is that possible? Thanks.

• There are studios selling applications which is just copying any 3Dgraphic content and regenerating into another new window. especially for CAVE Virtual reality experience. so that the user opens REvite or CAD or any other 3D applications and opens a model. then when the user selects the rendered window the VR application copies the 3D model information from the OpenGL window.
I got the clue that the VR application replaces the windows opengl32.dll file. how this is possible ... how can we copy the 3d content from the current OpenGL window.
anyone, please help me .. how to go further... to create an application like VR CAVE.

Thanks
• By cebugdev
hi all,

i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
thank you, and looking forward to positive replies.

• I have a few beginner questions about tesselation that I really have no clue.
The opengl wiki doesn't seem to talk anything about the details.

What is the relationship between TCS layout out and TES layout in?
How does the tesselator know how control points are organized?
e.g. If TES input requests triangles, but TCS can output N vertices.
What happens in this case?
http://www.informit.com/articles/article.aspx?p=2120983
the isoline example TCS out=4, but TES in=isoline.
And gl_TessCoord is only a single one.
So which ones are the control points?
How are tesselator building primitives?
• By Orella
I've been developing a 2D Engine using SFML + ImGui.
Here you can see an image
The editor is rendered using ImGui and the scene window is a sf::RenderTexture where I draw the GameObjects and then is converted to ImGui::Image to render it in the editor.
Now I need to create a 3D Engine during this year in my Bachelor Degree but using SDL2 + ImGui and I want to recreate what I did with the 2D Engine.
I've managed to render the editor like I did in the 2D Engine using this example that comes with ImGui.
3D Editor preview
But I don't know how to create an equivalent of sf::RenderTexture in SDL2, so I can draw the 3D scene there and convert it to ImGui::Image to show it in the editor.
If you can provide code will be better. And if you want me to provide any specific code tell me.
Thanks!

• 9
• 10
• 9
• 14
• 10