summaryrefslogtreecommitdiff
path: root/README.txt
blob: fc4847ce179fd1227746129458ea3979ddd8c22a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
Waffle - a library for selecting GL API and window system at runtime

homepage:       http://people.freedesktop.org/~chadversary/waffle
mailing-list:   TODO
maintainer:     Chad Versace <chad@chad.versace@linux.intel.com>
source:         git://people.freedesktop.org/~chadversary/waffle.git
gitweb:         http://cgit.freedesktop.org/~chadversary/waffle
license:        Apache 2.0


Summary
=======

Waffle is a cross-platform library that allows one to defer selection of GL
API and of window system until runtime. For example, on Linux, Waffle enables
an application to select X11/EGL with an OpenGL 3.3 core profile, Wayland
with OpenGL ES2, and other window system / API combinations.

Waffle's immediate goal is to enable Piglit [1] to test multiple GL flavors in
a cross-platform way, and to allow each Piglit test to choose its GL API and
window system at runtime. A future goal is to enable the ability to record
(with another tool such APITrace [2]) an application's GL calls on one
operating system or window system, and then replay that trace on a different
system.


[1] http://cgit.freedesktop.org/piglit/tree/README
[2] http://github.com/apitrace/apitrace#readme


Features
========

Waffle supports the following GL API's:
    - OpenGL
    - OpenGL ES1
    - OpenGL ES2

Waffle does not yet support selection of OpenGL version and profile, but
that's on the short todo list.

Waffle supports, or has planned support, for the following window systems:
    - Android   (planned)
    - Apple/GLX (planned)
    - Apple/CGL (planned)
    - GLX       (planned, coming next)
    - Wayland   (planned, after GLX)
    - Windows   (planned)
    - X11/EGL   (complete)


Example Usage
=============

The example below is just a code snippet that demonstrates basic usage of
Waffle. It is not complete; it does not handle errors.  For a complete
example, see `/examples/gl_basic.c` [3].

[3] http://cgit.freedesktop.org/~chadversary/waffle/tree/gl_basic.c.

-----------------------------
    #include <waffle/waffle.h>

    // Declare function pointers and enums for glClear, glClearColor.

    int
    main()
    {
        const int32_t init_attrs[] = {
            WAFFLE_PLATFORM,            WAFFLE_PLATFORM_X11_EGL,
            WAFFLE_OPENGL_API,          WAFFLE_OPENGL_ES2,
            0,
        };

        const int32_t config_attrs[] = {
            WAFFLE_RED_SIZE,            8,
            WAFFLE_BLUE_SIZE,           8,
            WAFFLE_GREEN_SIZE,          8,
            0,
        };

        // Setup waffle objects.
        waffle_init(init_attrs);
        struct waffle_display *dpy = waffle_display_connect(NULL);
        struct waffle_config *config = waffle_config_choose(dpy, config_attrs);
        struct waffle_window *window = waffle_window_create(dpy, width, height);
        struct waffle_context *ctx = waffle_context_creat(config, NULL);

        glClearColor = waffle_dlsym_gl("glClearColor");
        glClear = waffle_dlsym_gl("glClear");

        waffle_make_current(dpy, window, ctx);
        glClearColor(1.0, 0.0, 0.0, 1.0);
        glClear(GL_COLOR_BUFFER_BIT);
        waffle_window_swap_buffers(window);

        // Teardown waffle.
        waffle_make_current(dpy, NULL, NULL);
        waffle_window_destroy(window);
        waffle_context_destroy(ctx);
        waffle_config_destroy(config);
        waffle_display_disconnect(dpy);
        waffle_finish();

        return 0;
    }
-----------------------------


Building
========

Below is a full description of Waffle's configuration options. If CMake scares
you and you don't like reading, just do this:
    cmake \
        -DCMAKE_LIBRARY_PATH=$(echo $LIBRARY_PATH | sed 's/:/;/g') \
        -Dwaffle_has_x11_egl=1 \
        $WAFFLE_SOURCE_DIR
    make
    make check
    make install


Configuration Options
---------------------

Options are given in -Dname=value format.

CMake options:
    Unlike Autoconf, CMake doesn't detect environment variables like
    LIBRARY_PATH and CFLAGS. You need to set some of the options below to get
    that behavior.

    - CMAKE_BUILD_TYPE
        [default=?; choices=debug,release]
        This affects CFLAGS.

    - CMAKE_C_FLAGS
        [default="--std=c99 -Wall -Werror"]

    - CMAKE_C_FLAGS_DEBUG
        [default="-g3 -O0 -DDEBUG"]
        Flags to append to CMAKE_C_FLAGS when CMAKE_BUILD_TYPE=debug.

    - CMAKE_C_FLAGS_RELEASE
        [default="-g1 -O2 -DNEDEBUG"]
        Flags to append to CMAKE_C_FLAGS when CMAKE_BUILD_TYPE=release.

    - CMAKE_LIBRARY_PATH
        [default=none]
        A semicolon-separated list of directories in which to search for
        libraries.

    - CMAKE_INSTALL_PREFIX
        [default=/usr/local]
        Equivalent to autoconf's --prefix.

Platform options:

    - waffle_has_x11_egl
        [default=1 if libraries are autodetected] [choices=0,1]
        Build Waffle with support for X11/EGL.

Install options:
    - waffle_install_includedir
        [default=${CMAKE_INSTALL_PREFIX}/include]
        Directory where libraries will be instaled.

    - waffle_install_libdir
        [default=${CMAKE_INSTALL_PREFIX}/lib]
        Directory where libraries will be installed.

    - waffle_install_docdir
        [default=${CMAKE_INSTALL_PREFIX}/share/doc/waffle]
        Directory where documentation will be instaled.

Miscellaneous options:

    - waffle_build_tests
        [default=1; choices=0,1]
        Build the unit tests and functional tests ran by `make check`.

    - waffle_build_examples
        [default=1; choices=0,1]
        Build the stuff in the /examples directory.


License
=======

For a list of copyright holders, see NOTICE.txt.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.