Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have read alot of interesting questions asking about XNA vs. OpenTK vs. SlimDX vs. OpenGL vs. DX, and while it is really useful to get others general impressions from 100s of hours using these various APIs/Frameworks, I haven't seen any answer which clearly defines what the scope of each is.

It's understood what the difference between an API, Engine and Framework is in theory, but for someone who has limitied experience with graphics systems, its harder to see what on the practical side falls into each category. (Not made easier by all the overlap! e.g. XNA implementing a content pipeline as an integral part)

Take for example face culling - XNA 'does' this in the background without the programmer needing to think about it, but where does it happen? Is there a 'cull face' function in DX that must be called, or perhaps above in XNA? Or does the GPU or its driver do it?

I read in the documentation for one of the managed projects (annoyingly I can't remember which) about how difficult it was to implement efficient rendering code, and how that project abstracted it. This unnerved me a bit, and made me wonder just what XNA is doing beneath DrawIndexedPrimitives that would have to be done manually should the framework be left for something more flexible.

This site demonstrates how to draw a simple textured cube in XNA; it has all the basics such as vertex buffers and view matrices but certainly appears to be abstracting away a great deal if you look at the rendering pipeline for OpenGL.

What does XNA do in the background, when rendering that cube, that a managed API would not?

share|improve this question… Sums up the engine vs framework API is simply how that framework/library/engine is presented. – The Communist Duck Jun 8 '11 at 18:17
Other than your example face culling question, this question is rather vague. What sort of answer are you looking for? It seems to me that you are asking for a list of everything that every library does, so that you can discern which layers do what. I think perhaps you should consult the relevant documentation and, where available, source code on a case-by-case basis. Your face culling question can be answered, but the rest of the encapsulating question seems open ended to me. – Ricket Jun 8 '11 at 18:21
I think the main question is in the title. OP would like to know how much "busy work" is XNA doing vs. programming in C++ and Direct X – Nate Jun 8 '11 at 18:40
@Ricket, Sorry its likely a little vague because I am not sure exactly the best way to express the answer. Regarding a list of layers, you are right; not huge exhaustive lists, but maybe a few examples of the kind of functions that XNA calls in the background, or methods that are required for rendering in OpenGL but not in XNA, would do a good job in illustrating just how big the difference in level is. Nate is correct; if you are coming from a low level its fairly easy to see what has been hidden, but if you started with XNA its harder to see whats missing (and thus how high up you are). – sebf Jun 8 '11 at 18:49
(I've edited the question to be a little more prescriptive) @The Communist Duck, Thanks, I find that thread helpful - especially your last sentance about Game Seperated From The Engine I think illustrates very well what an Engine really is. – sebf Jun 8 '11 at 18:50
up vote 0 down vote accepted

I think the question would be better answered if you inversed it. How exactly does a graphics card work, and what calls are made by DirectX or OpenGL to utilise these features?

This wouldn't answer your question per se, but as DirectX and OpenGL add a lot of higher level classes to simplify things for you I believe the difference is too vague with what XNA provides for example.

For the basics you will find similarities in DirectX/XNA calls because at a certain (lower) level, things cannot be more abstacted and the calls will have to be made by yourself.

So I'd say go create a simple rendering engine in OpenGL (I'd say more accessible to get lower level) and see where that takes you!

share|improve this answer
Its hard to pick answers when the consensus between all is essentially that the question does not have one, but this is essentially what I will do as I think now the only way to understand the difference is to play with SlimDX or OpenTK (even though I started out with Assembly I've been so spoilt by C# I don't think I'll go without the GC just yet ;)) and see it first hand. – sebf Jun 9 '11 at 13:06

A framework, essentially, provides an API. Often it uses or wraps other APIs in order to do this. The two terms are not necessarily distinct, there's no clear difference in scope, and it's not really important for you to be able to tell the difference - what is important is to know what level of abstraction any given API, library, framework, engine, platform, or package operates at. Finding this out varies on a case by case basis unfortunately.

share|improve this answer

The framework starts... where the API ends. The API is a limited set of functions/classes/whatever that you can use, and the framework just wraps all that stuff up.

If you're asking about how much stuff goes on in between your call to whatever framework function you're using to get to whatever API method its calling, that really isn't answerable in the general case. Some things are easy, some things are really abstracted away and may be hiding things that would be useful to know about (which is why I'm assuming you're asking this question).

For XNA specifically, you can probably see the code by using a tool like ILSpy to break open the XNA DLLs and see what's going on under the hood.

share|improve this answer
I did have a look at the DrawIndexedPrimitives method using .NET Reflector, and in many ways it was helpful but in others incomplete. On one hand I don't think that navtive DX programmers draw geometry by obtaining a pointer to a device, offsetting into it by a hardcoded constant to retrieve a function pointer, and then call this (at least I really hope not! :-o). On the other hand it does appear that the DrawUserPrimitives function is, at least for that function, just a wrapper with a great deal of error checking and XNA doesnt acctaully do anything beyond it. – sebf Jun 8 '11 at 19:37
I think I may have mis-estimated just how varied the scope of the examples I listed are, and as you and Kylotan say the only way to see is to learn a managed API. – sebf Jun 8 '11 at 19:37
The hardcoded constant to retrieve function pointer is a result of decompilation from C++/CLI. If you write a C++/CLI Console app and reference the native Direct3D apis, and do something like 'pDirect3DDevice->EndScene();' it will decompile into what you saw (or similar) when viewed as C# in Reflector - I believe a lot of XNA is written in C++/CLI not C#. – jeffora Jun 8 '11 at 23:19
@jeffora, That makes more sense. Does the .NET Reflector itself do the decompilation on demand when opening a library? – sebf Jun 9 '11 at 13:00
RedGate's Reflector is essentially mapping IL to it's managed language equivalent. You'll notice you can change the language and even view just the IL. The source code displayed is not always accurate to what was typed in - it's accurate decompilation of what the compiler generated. The C# code from parts of decompiled XNA will not even compile if you try to write it yourself (in C#) – jeffora Jun 10 '11 at 11:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.