---
name: "waffle_init"
section: "3"
platform: "linux"
package: "libwaffle-doc"
version: "1.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/waffle_init"
---

# waffle\_init(3)

Initialize waffle's per-process global state

## NAME

waffle\_init - Initialize waffle's per-process global state

## SYNOPSIS

```
#include <waffle.h>
```

**bool waffle\_init(const int32\_t** *attrib\_list***\[\]);**

## DESCRIPTION

**waffle\_init()** initializes the per-process global state of the waffle library with the attributes specified in *attrib\_list*. The set of attributes is documented below. *attrib\_list* consists of a zero-terminated sequence of name/value pairs.

Most waffle functions emit an error if called when waffle is unitialized. The small set of functions that can be successfully called before initialization are explicitly documented as such.

If a call to **waffle\_init()** fails, no global state is initialized and the caller may safely attempt to call **waffle\_init()** again. If waffle has already been initialized by a successful call to **waffle\_init()** one has to call **waffle\_teardown()** to clear the global state. Otherwise calling **waffle\_init()** again emits the error **WAFFLE\_ERROR\_ALREADY\_INITIALIZED**.

## ATTRIBUTES

**WAFFLE\_PLATFORM**

This attribute is required. Possible values are:

**WAFFLE\_PLATFORM\_ANDROID**

\[Android\] Use EGL on Android.

**WAFFLE\_PLATFORM\_GBM**

\[Linux\] Use EGL with GBM, the "Generic Buffer Manager" provided by libgbm. This platform is capable of OpenGL rendering without a display manager.

**WAFFLE\_PLATFORM\_CGL**

\[MacOS\] Use CGL to create the [**waffle\_config**(3)](/waffle_config/3.md) and [**waffle\_context**(3)](/waffle_context/3.md). Use Cocoa to create the [**waffle\_window**(3)](/waffle_window/3.md).

**WAFFLE\_PLATFORM\_GLX**

\[Linux only, MacOS not yet supported\]

**WAFFLE\_PLATFORM\_SURFACELESS\_EGL**

\[Linux\] Use EGL's "surfaceless" platform, **EGL\_MESA\_platform\_surfaceless**\[1\].

**WAFFLE\_PLATFORM\_WAYLAND**

\[Linux\] Use EGL with the Wayland display server.

**WAFFLE\_PLATFORM\_WGL**

\[Windows\] Use WGL on Windows.

**WAFFLE\_PLATFORM\_X11\_EGL**

\[Linux\] Use EGL with the X11 display server.

## RETURN VALUE

Functions whose return type is **bool** return true on success and false on failure. Functions whose return type is a pointer return **NULL** on failure. Use [**waffle\_error\_get\_info**(3)](/waffle_error_get_info/3.md) to get information about any errors.

## ERRORS

See [**waffle\_error**(3)](/waffle_error/3.md) for the complete list of waffle's error codes.

Listed are the errors specific to **waffle\_init()**.

**WAFFLE\_ERROR\_ALREADY\_INITIALIZED**

Waffle has already been initialized with a successful call to **waffle\_init()**.

**WAFFLE\_ERROR\_BAD\_ATTRIBUTE**

An item in *attrib\_list* is unrecognized or has an invalid value, or a required attribute is missing.

**WAFFLE\_ERROR\_BUILT\_WITHOUT\_SUPPORT**

Waffle was built without support for the requested attribute.

## EXAMPLE

Initialize waffle for X11/EGL.

```
#include <waffle.h>
static const int32_t init_attrib_list[] = {
    WAFFLE_PLATFORM, WAFFLE_PLATFORM_X11_EGL,
    0,
};
int
main()
{
    bool ok = waffle_init(init_attrib_list);
    if (ok)
        return EXIT_SUCCESS;
    else
        return EXIT_FAILURE;
}
```

## ISSUES

Please report bugs or and feature requests to **https://gitlab.freedesktop.org/mesa/waffle/issues**.

## SEE ALSO

[**waffle**(7)](/waffle/7.md)

## AUTHOR

**Chad Versace** \<chad.versace@linux.intel.com\>

Former maintainer

## COPYRIGHT

Copyright © 2013 Intel\

This manual page is licensed under the Creative Commons Attribution-ShareAlike 3.0 United States License (CC BY-SA 3.0). To view a copy of this license, visit **http://creativecommons.org.license/by-sa/3.0/us**.

## NOTES

- 1\.

  EGL\_MESA\_platform\_surfaceless

  https://www.khronos.org/registry/egl/extensions/MESA/EGL\_MESA\_platform\_surfaceless.txt
