mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
Use EGL_KHR_surfaceless_opengl
This commit is contained in:
parent
e0f5cc2574
commit
379b678c57
4 changed files with 17 additions and 58 deletions
|
|
@ -348,18 +348,10 @@ static struct gears *
|
||||||
gears_create(struct display *display)
|
gears_create(struct display *display)
|
||||||
{
|
{
|
||||||
const int x = 200, y = 200, width = 450, height = 500;
|
const int x = 200, y = 200, width = 450, height = 500;
|
||||||
EGLint major, minor, count;
|
EGLint major, minor;
|
||||||
EGLConfig config;
|
|
||||||
struct gears *gears;
|
struct gears *gears;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
static const EGLint config_attribs[] = {
|
|
||||||
EGL_SURFACE_TYPE, 0,
|
|
||||||
EGL_NO_SURFACE_CAPABLE_MESA, EGL_OPENGL_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
gears = malloc(sizeof *gears);
|
gears = malloc(sizeof *gears);
|
||||||
memset(gears, 0, sizeof *gears);
|
memset(gears, 0, sizeof *gears);
|
||||||
gears->d = display;
|
gears->d = display;
|
||||||
|
|
@ -373,13 +365,10 @@ gears_create(struct display *display)
|
||||||
if (!eglInitialize(gears->display, &major, &minor))
|
if (!eglInitialize(gears->display, &major, &minor))
|
||||||
die("failed to initialize display\n");
|
die("failed to initialize display\n");
|
||||||
|
|
||||||
if (!eglChooseConfig(gears->display, config_attribs, &config, 1, &count) ||
|
|
||||||
count == 0)
|
|
||||||
die("eglChooseConfig() failed\n");
|
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
|
|
||||||
gears->context = eglCreateContext(gears->display, config, EGL_NO_CONTEXT, NULL);
|
gears->context = eglCreateContext(gears->display,
|
||||||
|
NULL, EGL_NO_CONTEXT, NULL);
|
||||||
if (gears->context == NULL)
|
if (gears->context == NULL)
|
||||||
die("failed to create context\n");
|
die("failed to create context\n");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -870,19 +870,11 @@ struct display *
|
||||||
display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
|
display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
|
||||||
{
|
{
|
||||||
struct display *d;
|
struct display *d;
|
||||||
EGLint major, minor, count;
|
EGLint major, minor;
|
||||||
EGLConfig config;
|
|
||||||
int fd;
|
int fd;
|
||||||
GOptionContext *context;
|
GOptionContext *context;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
|
||||||
static const EGLint config_attribs[] = {
|
|
||||||
EGL_SURFACE_TYPE, 0,
|
|
||||||
EGL_NO_SURFACE_CAPABLE_MESA, EGL_OPENGL_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
g_type_init();
|
g_type_init();
|
||||||
|
|
||||||
context = g_option_context_new(NULL);
|
context = g_option_context_new(NULL);
|
||||||
|
|
@ -925,15 +917,9 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(d->dpy, config_attribs, &config, 1, &count) ||
|
|
||||||
count == 0) {
|
|
||||||
fprintf(stderr, "eglChooseConfig() failed\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
|
|
||||||
d->ctx = eglCreateContext(d->dpy, config, EGL_NO_CONTEXT, NULL);
|
d->ctx = eglCreateContext(d->dpy, NULL, EGL_NO_CONTEXT, NULL);
|
||||||
if (d->ctx == NULL) {
|
if (d->ctx == NULL) {
|
||||||
fprintf(stderr, "failed to create context\n");
|
fprintf(stderr, "failed to create context\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -305,15 +305,8 @@ on_drm_input(int fd, uint32_t mask, void *data)
|
||||||
static int
|
static int
|
||||||
init_egl(struct drm_compositor *ec, struct udev_device *device)
|
init_egl(struct drm_compositor *ec, struct udev_device *device)
|
||||||
{
|
{
|
||||||
EGLint major, minor, count;
|
EGLint major, minor;
|
||||||
EGLConfig config;
|
const char *extensions;
|
||||||
|
|
||||||
static const EGLint config_attribs[] = {
|
|
||||||
EGL_SURFACE_TYPE, 0,
|
|
||||||
EGL_NO_SURFACE_CAPABLE_MESA, EGL_OPENGL_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
ec->base.base.device = strdup(udev_device_get_devnode(device));
|
ec->base.base.device = strdup(udev_device_get_devnode(device));
|
||||||
ec->drm_fd = open(ec->base.base.device, O_RDWR);
|
ec->drm_fd = open(ec->base.base.device, O_RDWR);
|
||||||
|
|
@ -335,16 +328,15 @@ init_egl(struct drm_compositor *ec, struct udev_device *device)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(ec->base.display,
|
extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS);
|
||||||
config_attribs, &config, 1, &count) ||
|
if (!strstr(extensions, "EGL_KHR_surfaceless_opengl")) {
|
||||||
count == 0) {
|
fprintf(stderr, "EGL_KHR_surfaceless_opengl not available\n");
|
||||||
fprintf(stderr, "eglChooseConfig() failed\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
ec->base.context = eglCreateContext(ec->base.display,
|
ec->base.context = eglCreateContext(ec->base.display,
|
||||||
config, EGL_NO_CONTEXT, NULL);
|
NULL, EGL_NO_CONTEXT, NULL);
|
||||||
if (ec->base.context == NULL) {
|
if (ec->base.context == NULL) {
|
||||||
fprintf(stderr, "failed to create context\n");
|
fprintf(stderr, "failed to create context\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -198,15 +198,8 @@ dri2_authenticate(struct x11_compositor *c)
|
||||||
static int
|
static int
|
||||||
x11_compositor_init_egl(struct x11_compositor *c)
|
x11_compositor_init_egl(struct x11_compositor *c)
|
||||||
{
|
{
|
||||||
EGLint major, minor, count;
|
EGLint major, minor;
|
||||||
EGLConfig config;
|
const char *extensions;
|
||||||
|
|
||||||
static const EGLint config_attribs[] = {
|
|
||||||
EGL_SURFACE_TYPE, 0,
|
|
||||||
EGL_NO_SURFACE_CAPABLE_MESA, EGL_OPENGL_BIT,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
if (dri2_connect(c) < 0)
|
if (dri2_connect(c) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -233,16 +226,15 @@ x11_compositor_init_egl(struct x11_compositor *c)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eglChooseConfig(c->base.display,
|
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
|
||||||
config_attribs, &config, 1, &count) ||
|
if (!strstr(extensions, "EGL_KHR_surfaceless_opengl")) {
|
||||||
count == 0) {
|
fprintf(stderr, "EGL_KHR_surfaceless_opengl not available\n");
|
||||||
fprintf(stderr, "eglChooseConfig() failed\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
eglBindAPI(EGL_OPENGL_API);
|
eglBindAPI(EGL_OPENGL_API);
|
||||||
c->base.context = eglCreateContext(c->base.display,
|
c->base.context = eglCreateContext(c->base.display,
|
||||||
config, EGL_NO_CONTEXT, NULL);
|
NULL, EGL_NO_CONTEXT, NULL);
|
||||||
if (c->base.context == NULL) {
|
if (c->base.context == NULL) {
|
||||||
fprintf(stderr, "failed to create context\n");
|
fprintf(stderr, "failed to create context\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue