Use EGL_KHR_surfaceless_opengl

This commit is contained in:
Kristian Høgsberg 2010-07-28 22:52:28 -04:00
parent e0f5cc2574
commit 379b678c57
4 changed files with 17 additions and 58 deletions

View File

@ -348,18 +348,10 @@ static struct gears *
gears_create(struct display *display)
{
const int x = 200, y = 200, width = 450, height = 500;
EGLint major, minor, count;
EGLConfig config;
EGLint major, minor;
struct gears *gears;
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);
memset(gears, 0, sizeof *gears);
gears->d = display;
@ -373,13 +365,10 @@ gears_create(struct display *display)
if (!eglInitialize(gears->display, &major, &minor))
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);
gears->context = eglCreateContext(gears->display, config, EGL_NO_CONTEXT, NULL);
gears->context = eglCreateContext(gears->display,
NULL, EGL_NO_CONTEXT, NULL);
if (gears->context == NULL)
die("failed to create context\n");

View File

@ -870,19 +870,11 @@ struct display *
display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
{
struct display *d;
EGLint major, minor, count;
EGLConfig config;
EGLint major, minor;
int fd;
GOptionContext *context;
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();
context = g_option_context_new(NULL);
@ -925,15 +917,9 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
return NULL;
}
if (!eglChooseConfig(d->dpy, config_attribs, &config, 1, &count) ||
count == 0) {
fprintf(stderr, "eglChooseConfig() failed\n");
return NULL;
}
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) {
fprintf(stderr, "failed to create context\n");
return NULL;

View File

@ -305,15 +305,8 @@ on_drm_input(int fd, uint32_t mask, void *data)
static int
init_egl(struct drm_compositor *ec, struct udev_device *device)
{
EGLint major, minor, count;
EGLConfig config;
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
};
EGLint major, minor;
const char *extensions;
ec->base.base.device = strdup(udev_device_get_devnode(device));
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;
}
if (!eglChooseConfig(ec->base.display,
config_attribs, &config, 1, &count) ||
count == 0) {
fprintf(stderr, "eglChooseConfig() failed\n");
extensions = eglQueryString(ec->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_opengl")) {
fprintf(stderr, "EGL_KHR_surfaceless_opengl not available\n");
return -1;
}
eglBindAPI(EGL_OPENGL_API);
ec->base.context = eglCreateContext(ec->base.display,
config, EGL_NO_CONTEXT, NULL);
NULL, EGL_NO_CONTEXT, NULL);
if (ec->base.context == NULL) {
fprintf(stderr, "failed to create context\n");
return -1;

View File

@ -198,15 +198,8 @@ dri2_authenticate(struct x11_compositor *c)
static int
x11_compositor_init_egl(struct x11_compositor *c)
{
EGLint major, minor, count;
EGLConfig config;
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
};
EGLint major, minor;
const char *extensions;
if (dri2_connect(c) < 0)
return -1;
@ -233,16 +226,15 @@ x11_compositor_init_egl(struct x11_compositor *c)
return -1;
}
if (!eglChooseConfig(c->base.display,
config_attribs, &config, 1, &count) ||
count == 0) {
fprintf(stderr, "eglChooseConfig() failed\n");
extensions = eglQueryString(c->base.display, EGL_EXTENSIONS);
if (!strstr(extensions, "EGL_KHR_surfaceless_opengl")) {
fprintf(stderr, "EGL_KHR_surfaceless_opengl not available\n");
return -1;
}
eglBindAPI(EGL_OPENGL_API);
c->base.context = eglCreateContext(c->base.display,
config, EGL_NO_CONTEXT, NULL);
NULL, EGL_NO_CONTEXT, NULL);
if (c->base.context == NULL) {
fprintf(stderr, "failed to create context\n");
return -1;