Absolute beginner question regarding APIs, frameworks, libraries...
Members - Reputation: 106
Posted 08 October 2012 - 02:11 PM
From what I understand, DirectX and OpenGL are APIs... what exactly is an API, why/when would you use them for a game? What is something like XNA, then?
Further on, from what I understand, things like SDL and SFML are libraries - how are they separate from things like DirectX and OpenGL, are they used together/in conjunction? When would you use one over the other?
Finally, there's Unity, which from what I understand is an engine. So can you just use something like Unity to make a game and ignore the rest?
Crossbones+ - Reputation: 3630
Posted 08 October 2012 - 02:36 PM
In general, they're all "already written code you can use". You would use them when you don't want to spend the multiple man-years spent by experts in making the code you can use for free.
Senior Staff - Reputation: 12250
Posted 08 October 2012 - 05:48 PM
An API, or Application Programming Interface, provides an interface to some (usually lower-level) functionality. In the case of OpenGL and Direct3d that functionality is talking to graphics hardware in order to draw things on the screen -- if you did not use an existing API you would have to write a different code implementation for each different piece of hardware you want your game to run on, but the API hides all that complexity from you and allows you to simply use the provided commands and data structures to describe what you want to happen, and then handles talking to the hardware for you.
A library (or "framework", just to throw another term at you!) is a piece of code -- generally a collection of related or semi-related functionality -- that has been pre-written for your usage. These terms are sometimes used interchangeably with "API" or "engine".
Most people consider the term "engine" to refer to a more complete software package -- potentially including tools and multiple libraries -- for completing some task, and it's usually designed for more specific rather than general usage. Looking at Unreal as an example, you have a fairly complete package that is designed for first or third person games: it includes all of the stuff you would need to create such a game -- physics, rendering, input handling, maps, etc. -- and all you need to do is create your game-specific functionality. Remember however that the terms "engine" and "library" or "framework" are sometimes used interchangeably, and just to be confusing might also be referred to as an API in some cases.
Don't get bogged down in the terminology though -- if you're not sure what something is, just check what capabilities and functionality is actually on offer and get on with the task at hand.
Hope that's somewhat helpful!
- Jason Astle-Adams.
Members - Reputation: 428
Posted 08 October 2012 - 06:49 PM
The term "Library" refers to a specific way functionality can be packaged for use by the application programmer.
Specifically, in a compiled language like C++, a set of functionality is compiled to object code (i.e., "link-able" .obj files), and made available in an "archive" or "library", which on windows is a .lib file (.lib files essentially contain a bunch of .obj files). The application programmer generally "includes" provided header files which declare functions and types implemented in the library, uses them in code, and links the library into the executable.
The term "library" says nothing about what type of functionality is provided, or what it might be used for.
As mentioned, API means "Application Programming Interface". "API" generally refers to a library, but is named for the interface (i.e., the contents of accompanying header files) to which the application code will be written, rather than the implementation in the library.
The phrase, "Application Programming" implies that the functionality provided is specific for creating some certain type of application. The Windows API is used for making Windows applications; The OpenGL ("Open Graphics Library") API is used for making graphical applications; Etc. APIs often deal with how the application interacts with the outside world - how it gets input and/or generates output.
In general, an API is a library but a library is not necessarily an API. The C++ standard library, for example, is mostly functionality for a program's internal processing. It's not designed for giving an application access to, or control over, any specific platform/environment.
A game engine is a unified set of run-time software technology designed to provide a good portion of the core functionality of a game. The thing that makes it an engine, is its frame-based multi-tasking nature. The thing that makes it a game engine is all the basic functionality it delivers that makes it useful for building games. (OpenGL and Direct 3D are not engines, for example. They provide nothing but a way to get graphics on screen.)
While not technically part of the engine itself, most engines would be useless without a set of accompanying tools for generating content specific to that engine, so a tool-set is sometimes thought of as part of the engine.
The term "engine" says nothing about how the functionality is delivered. It could, for example, be delivered as a set of libraries, or as source code for a sample game "stub". If it's a set of libraries, they could be considered an API for developing applications on that engine.
The "Open Graphics Library" is a cross-platform API for putting graphics on-screen.
Providers of all sorts of different platforms, that have graphics rendering ablilty, can implement the library for their platform. All implementations of the library work with the published OpenGL interface. That way, applications programmers can write applications using that interface, and they'll build and work on various different platforms, without alteration.
Direct X is a Microsoft API for developing "multi-media" applications on Microsoft platforms. In addition to Direct 3D (their graphics API), it includes other components like Direct Sound and Direct Input.
SDL & SFML
SDL & SFML are video games APIs.
They provide facilities for such things as audio output, input acquisition, networking, threading, timing, etc. They work with, or along-side, OpenGL.
I don't really know much about Unity, but in general, any robust game engine will include all of the functionality provided by the graphics and video games APIs, and more (e.g., physics, collision, AI, game objects/entities, message passing, asset handling, load/save, GUI/menus, etc.).
Edited by VReality, 09 October 2012 - 02:24 PM.
Members - Reputation: 333
Posted 10 October 2012 - 10:34 PM