Having trouble understanding libraries and API.

What is the difference between a library and an API. I've heard some people say that the API is the interface for the library, but it doesn't really make sense.

What I want to know is what is the difference between OpenGL and a library like SFML? I know that you can make games in SFML without OpenGL, but then why do people use both of them to make games? What exactly does OpenGL do and what do game libraries like SFML do, can anyone explain the functionality of each? Can you write standalone games in OpenGL?
Last edited on
From what I know, SFML is a much smaller, less standard library, While opengl is literally the industry standard game Dev library, in a sense that many libraries are built from Opengl, and I believe SFML is one of them.
Can you make standalone games in Opengl? yes. But I think its much more difficult than using something like SFML
OpenGL is the library that talks to your graphics card. It does nothing else, as in, it doesn't know that you have a monitor, and it doesn't know when you click your mouse.

SFML provides a context for OpenGL to render onto. SFML provides an event handling system.

Neither one requires the other, but when you put them together you can have a program with cool graphics that responds to user input.

I'm not sure if OpenGL can run standalone, but you certainly wouldn't be able to see anything. A standalone program might be something that does a large amount of computation that graphics cards are better at handling these days.
Well, why do people use both libraries to make games? does it make graphics better?
Without seeing specific examples, the answer to that could be numerous things. It might just be easier to implement some feature using just openGL rather than having to derive it from already-existing, higher-level SFML classes/functions. Also, SFML is just 2D, so perhaps the program being made has some "2.5D" or 3D elements in it while still being mostly based on SFML.

Edit: Or maybe they're just using SFML for window rendering because it's easier than GLUT (and open-source), but they aren't relying on anything from <SFML/Graphics.hpp>
Last edited on
So, if I understand correctly, OpenGL is used for making graphics do things that you can't do with just a standalone library.
Topic archived. No new replies allowed.