December 3, 2024

In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An application programming interface (API) is a particular set of rules and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between human users and computers.

An API is a software-to-software interface and not a user interface, take for example the process of buying items online, you order your item, enter your card details the site uses an API to send your credit card information to a remote application that verifies whether your information is correct. Once payment is confirmed, the remote application sends a response back to the movie Web site saying it’s OK to authorize the purchase. The user has no role to play other than initiating the process.

Let us take another look at how API’s work, this time using actual programming code.

import java.util.Scanner;

public class Test {
   public static void main(String[] args) {
       System.out.println("Enter your name:");
       Scanner scan = new Scanner(System.in);
       String name = scan.nextLine();
       System.out.println("Your name is" + name + ".");
       scan.close();
  }
}

Over here is a sample of code written in Java, the methods nextLine() and close() are part of the API for the Scanner class. The nextLine method advances the scanner past the current line and returns the input that was skipped while the close() method closes the scanner.

An API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together to build the bigger picture.

High-level API

High-level APIs are designed to remove complexity and accelerate design time. A high-level API is a subset or wrapper of a low-level API, and typically delivers the basic requirements of what most developers need today in terms of functionality. The amount of code is greatly reduced for each function, in effect simplifying the development process and enabling the developer to plainly direct the API on what to do.

Low-level APIs

Although there is an increasing demand for high-level APIs, there is still a substantial requirement for a low-level option. Developers with experience and expertise demand the level of control only a low-level API can deliver. A low-level API offers developers closer access to the hardware. What this means is that someone coding using a low-level API has a higher degree of granularity than with a high-level API.

Instead of going through a software translation layer, you can access the hardware interface directly thus eliminating the associated overhead. A low-level API lets programmers access more intricate hardware features but requires more expertise in coding. Because you are mostly interacting with the hardware on a very close level, you cannot (for example) just call a function to draw a polygon.

Now that we know what an API is and how it works, let us move into what is a graphics API.

Graphics APIs provide a standard platform that enables software developers to access specialised hardware (especially graphics hardware) features without needing to write hardware-specific code. For example, instead of having to write specialized code for Nvidia, AMD or Intel integrated GPUs, you can simply use an existing API such as DirectX12 or Vulkan to handle the draw calls and leave it to the API to instruct the hardware on how to do it.

Currently there are 3 major graphics APIs currently being used right now.

OpenGL

OpenGL was first released in 1992, by Silicon Graphics, Inc. It was created as an open standard, and is available on many platforms such as MacOS,Windows and Linux.  Even though it was created as an open standard, any changes that are done to the OpenGL source needed to be approved by the Khronos group an American non-profit member-funded industry consortium. The Khronos group consists of representatives from major companies involved with the graphics industry, including 3D Labs, SGI, Apple, NVIDIA, ATI, Intel, id Software, and for now at least, even Microsoft.

Direct3D

Microsoft DirectX is an advanced suite of multimedia APIs built into Microsoft Windows® operating systems. DirectX debuted in 1995 and quickly became a recognized standard for multimedia application development on the Windows platform.

Metal

Metal is a low-level, low-overhead hardware-accelerated graphics and compute application programming interface (API) that was announced in WWDC 2015 and debuted with iOS 8. It combines functionality similar to OpenGL and OpenCL under one API. It is Apple’s answer to Vulkan and Direct3D 12. Since June 8, 2015, Metal is available for iOS devices using the Apple A7 or later, as well as Macs (2012 models or later) running OS X El Capitan. Metal also further improves the capabilities of GPU programming by introducing compute shaders and uses a new shading language based on C++ 11 implemented using Clang and LLVM.

The Modern Need For Low-Level APIs

However our current graphics APIs suffer from two big issues, the first being end users mostly expect to have to download the latest drivers for their game to run. It’s possible of course for you to run a game without updating the drivers first, but most of the time performance is severely impacted. And as the level of demanding graphics increases, so does the amount of code required to optimize it as well as the size of these drivers. Performance is also a big issue, and often times than not there is a bottleneck in places where it should be because modern APIs simply cannot utilize the hardware enough. Nowadays even with the increasing number of cores and threads, games still rely heavily on single-core performance whereas the need for proper load distribution between all the cores is the better option.

Enter Low-Level Graphics APIs

Back in the early days of computer graphics, applications such as games directly interacted with the hardware. With time,  however, as the complexity of graphics increased and so did the variety in the number of consumer products. To make applications work on this huge variety of devices available on the market, some standards had to be defined. Thus device drivers appeared and operating systems separated access from the hardware. But even then the complexity of these programs continued to grow and it was no longer viable to directly interact with the hardware using API calls in the game’s source code itself. Thus game engines appeared providing developers access to quick resources such as assets, camera, light, and then interacting with the hardware itself using APIs.

Today, Games, as well as game engines constantly become more and more complex. Most games these days require drivers in order to be run optimally on hardware and are often bogged down by bottlenecks.

This is where the new generation of graphics APIs come in. Drivers can now become smaller and simpler, while upper layers will have more responsibility of manually managing stuff instead of automatic facilities provided by the driver. It also means API is again closer to the actual hardware. Thanks to all that, the usage of GPU can be optimized better by knowing all higher-level details about specific application on the engine level and can reduce CPU’s workload by giving developers a way to talk to the GPU directly with much less translation. With less work for the CPU to do, programmers can squeeze much more performance from a system, delivering the greatest benefits in gaming systems where the CPU can be the bottleneck.

This new generation of APIs can drastically change the gaming world if more games used it. Lower-end computers, laptops could see significant gaming performance increases. AMD Mantle was just a first taste of it. Although the development for Mantle has now ended several new low-level APIs have now entered the market.

No more bloated requirements, true next-generation graphics, and better driver support. Vulkan, Direct3D 12, and Metal are now here and gaming industry as we know it is going to change.