xenocara/dist/libepoxy/README.md

124 lines
4.0 KiB
Markdown
Raw Permalink Normal View History

2018-05-25 00:24:59 -06:00
[![Build Status](https://travis-ci.org/anholt/libepoxy.svg?branch=master)](https://travis-ci.org/anholt/libepoxy)
[![Build status](https://ci.appveyor.com/api/projects/status/xv6y5jurt5v5ngjx/branch/master?svg=true)](https://ci.appveyor.com/project/ebassi/libepoxy/branch/master)
2015-04-15 01:32:24 -06:00
Epoxy is a library for handling OpenGL function pointer management for
you.
2018-05-25 00:24:59 -06:00
It hides the complexity of `dlopen()`, `dlsym()`, `glXGetProcAddress()`,
`eglGetProcAddress()`, etc. from the app developer, with very little
knowledge needed on their part. They get to read GL specs and write
code using undecorated function names like `glCompileShader()`.
2015-04-15 01:32:24 -06:00
Don't forget to check for your extensions or versions being present
before you use them, just like before! We'll tell you what you forgot
to check for instead of just segfaulting, though.
Features
--------
2018-05-25 00:24:59 -06:00
* Automatically initializes as new GL functions are used.
* GL 4.6 core and compatibility context support.
* GLES 1/2/3 context support.
* Knows about function aliases so (e.g.) `glBufferData()` can be
used with `GL_ARB_vertex_buffer_object` implementations, along
with GL 1.5+ implementations.
* EGL, GLX, and WGL support.
* Can be mixed with non-epoxy GL usage.
2015-04-15 01:32:24 -06:00
Building
--------
2018-05-25 00:24:59 -06:00
```sh
mkdir _build && cd _build
meson
ninja
sudo ninja install
```
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
Dependencies for Debian:
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
* meson
* libegl1-mesa-dev
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
Dependencies for macOS (using MacPorts):
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
* pkgconfig
* meson
2015-04-15 01:32:24 -06:00
The test suite has additional dependencies depending on the platform.
(X11, EGL, a running X Server).
Switching your code to using epoxy
----------------------------------
It should be as easy as replacing:
2018-05-25 00:24:59 -06:00
```cpp
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>
```
2015-04-15 01:32:24 -06:00
with:
2018-05-25 00:24:59 -06:00
```cpp
#include <epoxy/gl.h>
#include <epoxy/glx.h>
```
2015-04-15 01:32:24 -06:00
As long as epoxy's headers appear first, you should be ready to go.
Additionally, some new helpers become available, so you don't have to
write them:
2018-05-25 00:24:59 -06:00
`int epoxy_gl_version()` returns the GL version:
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
* 12 for GL 1.2
* 20 for GL 2.0
* 44 for GL 4.4
2015-04-15 01:32:24 -06:00
2018-05-25 00:24:59 -06:00
`bool epoxy_has_gl_extension()` returns whether a GL extension is
available (`GL_ARB_texture_buffer_object`, for example).
2015-04-15 01:32:24 -06:00
Note that this is not terribly fast, so keep it out of your hot paths,
ok?
Why not use libGLEW?
--------------------
GLEW has several issues:
2018-05-25 00:24:59 -06:00
* Doesn't know about aliases of functions (There are 5 providers of
`glPointParameterfv()`, for example, and you don't want to have to
choose which one to call when they're all the same).
* Doesn't support OpenGL ES.
* Has a hard-to-maintain parser of extension specification text
instead of using the old .spec file or the new .xml.
* Has significant startup time overhead when `glewInit()`
autodetects the world.
* User-visible multithreading support choice for win32.
2015-04-15 01:32:24 -06:00
The motivation for this project came out of previous use of libGLEW in
[piglit](http://piglit.freedesktop.org/). Other GL dispatch code
generation projects had similar failures. Ideally, piglit wants to be
able to build a single binary for a test that can run on whatever
context or window system it chooses, not based on link time choices.
We had to solve some of GLEW's problems for piglit and solving them
meant replacing every single piece of GLEW, so we built
piglit-dispatch from scratch. And since we wanted to reuse it in
other GL-related projects, this is the result.
2018-05-25 00:24:59 -06:00
Known issues when running on Windows
------------------------------------
2015-04-15 01:32:24 -06:00
The automatic per-context symbol resolution for win32 requires that
2018-05-25 00:24:59 -06:00
epoxy knows when `wglMakeCurrent()` is called, because `wglGetProcAddress()`
returns values depend on the context's device and pixel format. If
`wglMakeCurrent()` is called from outside of epoxy (in a way that might
change the device or pixel format), then epoxy needs to be notified of
the change using the `epoxy_handle_external_wglMakeCurrent()` function.
The win32 `wglMakeCurrent()` variants are slower than they should be,
2015-04-15 01:32:24 -06:00
because they should be caching the resolved dispatch tables instead of
resetting an entire thread-local dispatch table every time.