Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/untodesu/salad

An OpenAL loader
https://github.com/untodesu/salad

openal openal-soft

Last synced: 28 days ago
JSON representation

An OpenAL loader

Awesome Lists containing this project

README

        

# 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](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](https://github.com/Dav1dde/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

```cmake
add_subdirectory(salad)
target_link_libraries(myproject PRIVATE salad)
```

## Using default DLL paths

```c
#include
#include
#include

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:

```c++
// 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;
}
```