16 EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
18 if (::eglInitialize(display,
nullptr,
nullptr) != EGL_TRUE) {
26 if (display_ != EGL_NO_DISPLAY) {
27 if (::eglTerminate(display_) != EGL_TRUE) {
34 return display_ != EGL_NO_DISPLAY;
41 std::vector<EGLint> attributes;
46 attributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
47 attributes.push_back(2);
50 attributes.push_back(EGL_CONTEXT_CLIENT_VERSION);
51 attributes.push_back(3);
55 attributes.push_back(EGL_NONE);
57 auto context = ::eglCreateContext(
60 share_context !=
nullptr ? share_context->
GetHandle() :
nullptr,
64 if (context == EGL_NO_CONTEXT) {
69 return std::unique_ptr<Context>(
new Context(display_, context));
77 std::vector<EGLint> attributes;
80 attributes.push_back(EGL_RENDERABLE_TYPE);
83 attributes.push_back(EGL_OPENGL_BIT);
86 attributes.push_back(EGL_OPENGL_ES2_BIT);
89 attributes.push_back(EGL_OPENGL_ES3_BIT);
95 attributes.push_back(EGL_SURFACE_TYPE);
98 attributes.push_back(EGL_WINDOW_BIT);
101 attributes.push_back(EGL_PBUFFER_BIT);
109 attributes.push_back(EGL_RED_SIZE);
110 attributes.push_back(8);
111 attributes.push_back(EGL_GREEN_SIZE);
112 attributes.push_back(8);
113 attributes.push_back(EGL_BLUE_SIZE);
114 attributes.push_back(8);
115 attributes.push_back(EGL_ALPHA_SIZE);
116 attributes.push_back(8);
119 attributes.push_back(EGL_RED_SIZE);
120 attributes.push_back(5);
121 attributes.push_back(EGL_GREEN_SIZE);
122 attributes.push_back(6);
123 attributes.push_back(EGL_BLUE_SIZE);
124 attributes.push_back(5);
130 attributes.push_back(EGL_DEPTH_SIZE);
131 attributes.push_back(
static_cast<EGLint
>(config.
depth_bits));
135 attributes.push_back(EGL_STENCIL_SIZE);
136 attributes.push_back(
static_cast<EGLint
>(config.
stencil_bits));
140 const auto sample_count =
static_cast<EGLint
>(config.
samples);
141 if (sample_count > 1) {
142 attributes.push_back(EGL_SAMPLE_BUFFERS);
143 attributes.push_back(1);
144 attributes.push_back(EGL_SAMPLES);
145 attributes.push_back(sample_count);
150 attributes.push_back(EGL_NONE);
152 EGLConfig config_out =
nullptr;
153 EGLint config_count_out = 0;
154 if (::eglChooseConfig(display_,
164 if (config_count_out != 1u) {
169 return std::make_unique<Config>(config, config_out);
174 EGLNativeWindowType
window) {
175 const EGLint attribs[] = {EGL_NONE};
176 auto surface = ::eglCreateWindowSurface(display_,
181 if (
surface == EGL_NO_SURFACE) {
192 const EGLint attribs[] = {
193 EGL_WIDTH,
static_cast<EGLint
>(
width),
194 EGL_HEIGHT,
static_cast<EGLint
>(
height),
198 auto surface = ::eglCreatePbufferSurface(display_,
202 if (
surface == EGL_NO_SURFACE) {
An EGL config. These are returned by the display to indicate support for a specific config descriptor...
const ConfigDescriptor & GetDescriptor() const
const EGLConfig & GetHandle() const
An instance of an EGL context.
const EGLContext & GetHandle() const
Get the underlying handle to the EGL context.
virtual std::unique_ptr< Surface > CreatePixelBufferSurface(const Config &config, size_t width, size_t height)
Create an offscreen pixelbuffer surface. These are of limited use except in the context where applica...
virtual std::unique_ptr< Context > CreateContext(const Config &config, const Context *share_context)
Create a context with a supported config. The supported config can be obtained via a successful call ...
virtual bool IsValid() const
virtual std::unique_ptr< Config > ChooseConfig(ConfigDescriptor config) const
Choose a config that most closely matches a given descriptor. If there are no matches,...
virtual std::unique_ptr< Surface > CreateWindowSurface(const Config &config, EGLNativeWindowType window)
Create a window surface. The window is an opaque pointer whose value value is platform specific....
An instance of an EGL surface. There is no ability to create surfaces directly. Instead,...