Code Monkey home page Code Monkey logo

libepoxy's Introduction

Epoxy

Linux/GCC Windows/MSVC Binaries
Linux Status Windows Build Status Binaries

Epoxy is a library for handling OpenGL function pointer management for you.

It hides the complexity of dlopen(), dlsym(), glXGetProcAddress(), eglGetProcAddress(), etc. from the developer. They get to read GL specifications and write code using undecorated function names like glCompileShader().

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

  • Automatically initializes as functions are used.
  • Can be mixed with non-Epoxy GL usage.
  • Knows about function aliases.
  • OpenGL Core Context Support
  • OpenGL ES Context Support
  • EGL, GLX, & WGL Support

Building Epoxy

You will need the following tools at a minimum in addition to the standard compilers for your system (GCC, Xcode/Clang, MinGW, MSVC, etc.).

  • Python 2.7+
  • CMake 2.8+

Just compile as usual for a CMake project:

mkdir build
cd build
cmake ..
make && make test

and optionally:

make install

Using Epoxy

The only headers you need to include are:

#include <epoxy/gl.h>  // instead of <GL/gl.h> and <GL/glext.h>
#include <epoxy/glx.h> // instead of <GL/glx.h> and <GL/glxext.h> (for GLX)
#include <epoxy/egl.h> // instead of <EGL/egl.h> and <EGL/eglext.h> (for EGL)
#include <epoxy/wgl.h> // instead of <windows.h> and <GL/wglext.h> (for WGL)

The other headers aren't needed, but can be included as long as Epoxy's headers are included first.

Epoxy also defines some helper functions:

  • int epoxy_gl_version(): Returns GL Version
    • 12 for OpenGL 1.2
    • 20 for OpenGL 2.0
    • 44 for OpenGL 4.4
  • bool epoxy_has_gl_extension(): Returns Whether GL Extension Available
    • Keep this out of hot paths as it is not terribly performant.

Windows Usage Notes

IMPORTANT

If you are using MSVC and have a DLL build of Epoxy, you will need to #define EPOXY_DLL prior to including the headers so the functions are decorated with __declspec(dllimport) as needed. This is not required if building with a betterdifferent compiler such as MinGW GCC.

The automatic per-context symbol resolution for the Windows platform requires that Epoxy knows when wglMakeCurrent() is called. This is because wglGetProcAddress() return 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 wglMakeCurrent() variants are slower than they should be because they should be caching the resolved dispatch tables instead of resetting an entire thread-local dispatch table every time. This is an area for future improvement.

libepoxy's People

Contributors

airlied avatar anholt avatar cicku avatar cworth-gh avatar fanc999-1 avatar jeffprogrammer avatar mattst88 avatar nephatrine avatar nwnk avatar roothorick avatar schnitzeltony avatar sonicadvance1 avatar yaronct avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.