Intial Wayland EGL integration.
This commit is contained in:
parent
a4d3019f04
commit
6af296409a
20 changed files with 278 additions and 44 deletions
89
src/windows/ui_interfaces/wayland/WaylandEglInterface.h
Normal file
89
src/windows/ui_interfaces/wayland/WaylandEglInterface.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
#pragma once
|
||||
|
||||
#include <wayland-egl.h>
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
class WaylandEglInterface
|
||||
{
|
||||
public:
|
||||
|
||||
void initialize(wl_display* display)
|
||||
{
|
||||
mEglDisplay = eglGetDisplay((EGLNativeDisplayType) display);
|
||||
if (mEglDisplay == EGL_NO_DISPLAY)
|
||||
{
|
||||
fprintf(stderr, "Can't create egl display\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Created egl display\n");
|
||||
}
|
||||
|
||||
EGLint major{0};
|
||||
EGLint minor{0};
|
||||
if (eglInitialize(mEglDisplay, &major, &minor) != EGL_TRUE)
|
||||
{
|
||||
fprintf(stderr, "Can't initialise egl display\n");
|
||||
return;
|
||||
}
|
||||
printf("EGL major: %d, minor %d\n", major, minor);
|
||||
|
||||
EGLint count{0};
|
||||
eglGetConfigs(mEglDisplay, nullptr, 0, &count);
|
||||
printf("EGL has %d configs\n", count);
|
||||
|
||||
EGLConfig* configs;
|
||||
configs = static_cast<EGLConfig*>(calloc(count, sizeof* configs));
|
||||
|
||||
EGLint n{0};
|
||||
EGLint config_attribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
eglChooseConfig(mEglDisplay, config_attribs, configs, count, &n);
|
||||
EGLint size{0};
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
eglGetConfigAttrib(mEglDisplay, configs[i], EGL_BUFFER_SIZE, &size);
|
||||
printf("Buffer size for config %d is %d\n", i, size);
|
||||
eglGetConfigAttrib(mEglDisplay, configs[i], EGL_RED_SIZE, &size);
|
||||
printf("Red size for config %d is %d\n", i, size);
|
||||
|
||||
// just choose the first one
|
||||
mEglConfig = configs[i];
|
||||
break;
|
||||
}
|
||||
|
||||
static const EGLint context_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
mEglContext = eglCreateContext(mEglDisplay, mEglConfig, EGL_NO_CONTEXT, context_attribs);
|
||||
}
|
||||
|
||||
EGLDisplay getDisplay() const
|
||||
{
|
||||
return mEglDisplay;
|
||||
}
|
||||
|
||||
EGLConfig getConfig() const
|
||||
{
|
||||
return mEglConfig;
|
||||
}
|
||||
|
||||
EGLContext getContext() const
|
||||
{
|
||||
return mEglContext;
|
||||
}
|
||||
|
||||
private:
|
||||
EGLDisplay mEglDisplay;
|
||||
EGLConfig mEglConfig;
|
||||
EGLContext mEglContext;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue