Skip to content

untodesu/salad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SALAD

Nice hustle, tons-o-fun! Next time, eat a salad!

SALAD is an OpenAL loader which is made out of frustration with an obvious lack of permissively-licensed OpenAL loaders in the software/game development world. SALAD and all the headers are licensed under Simplified BSD License (see LICENSE for the full license text)

Why SALAD?

Because it's funny. The library is named as an omage to an existing OpenGL loader GLAD; if you compare the two loaders, using both to load their respective API functions is very similar and that's intentional.

Usage

Prerequisites

  • A working ISO C90 (ANSI C89) compiler
  • A system installation of OpenAL or an OpenAL DLL module

Compiling directly

  • Just copy all the headers and salad.c into your project's source tree and include them in the build script; everything should world out of the box;
  • Make sure to comply with license terms (at least put the license text somewhere, I guess);

Using a CMake subdirectory

add_subdirectory(salad)
target_link_libraries(myproject PRIVATE salad)

Using default DLL paths

#include <AL/al.h>
#include <AL/alc.h>
#include <AL/salad.h>

int main(void)
{
    if(!saladLoadALdefault())
        return 1;

    ALCdevice *device = alcOpenDevice(NULL);

    /* ... */

    return 0;
}

Using a custom DLL loader (Source SDK)

Initially I created the loader to integrate with Source SDK, so this example might be relevant for those who want to do the same with a better chance of success without burning out:

// In the precompiled header
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/salad.h"

// In the C++ source
#include "tier1/interface.h"

static CDllDemandLoader al_dll("OpenAL32");

static void *SALAD_LoadFunc(const char *procname, void *arg)
{
    return al_dll.GetProcAddress(procname);
}

bool InitSomething(void)
{
    if(!saladLoadALfunc(&SALAD_LoadFunc, NULL)) {
        // Crash the game?
        return false;
    }

    ALCdevice *dev = alcOpenDevice(NULL);
    // ...

    return true;
}