Basic implementations

This chapter will focus on how a basic implementation of a render in each of the APIs. The implementations covered will neither be the quickest nor the smallest implementations available, but they will cover a basic overview of how the APIs function and which steps are to be followed in order to get a render to function.

The application we are developing is showing a single, static scene with a single pass. No special lighting tricks are applied and no special attention is paid to ensuring the data can be updated, created or deleted at runtime. In addition, no special cleanup routine exists for shutdown. The reason for this is mostly related to the fact that this is generally considered trivial. Important things to note about these limitations are touched on at a later point in time.

All of these implementations are made in C, not C++. While for the most part all C features are also included in C++, two features of C are used that break compatibility with C++ standard compilers: Compound literals, and designated initializers.

An example of these two features and the C++ equivalent:

some_function (
    &(some_struct){
        .someArraySize = 4,
        .someArray = (some_array_entry[4]){
            [0] = { .a = 1, },
            [1] = { .a = 1, },
        }
    }
);

some_struct tempStruct = { };
some_array_entry tempEntryArray[4] = { { 1 }, { 1 } };
tempStruct.someArraySize = 4;
tenoStruct.someArray = tempEntryArray;

some_function ( &tempStruct);

The former, C-only syntax is deemed more clear for the purposes of detailing these rather structure-heavy APIs.