diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2010-12-06 11:24:20 -0800 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-02-28 08:29:07 +0100 |
commit | 2a61211fd7c75cecfe4c8b1030d11827f6d418c8 (patch) | |
tree | 39c798d738fefd2a7608233e254b6e6e5f4c7062 /src | |
parent | 0e7745057873f23f842a1b7aac3b851279715fab (diff) |
Fixed rendering
Diffstat (limited to 'src')
-rw-r--r-- | src/video/wayland/SDL_waylandgl.c | 51 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandvideo.c | 26 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandvideo.h | 9 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandwindow.c | 37 | ||||
-rw-r--r-- | src/video/wayland/SDL_waylandwindow.h | 15 |
5 files changed, 86 insertions, 52 deletions
diff --git a/src/video/wayland/SDL_waylandgl.c b/src/video/wayland/SDL_waylandgl.c index f1c4ad21..e49dd578 100644 --- a/src/video/wayland/SDL_waylandgl.c +++ b/src/video/wayland/SDL_waylandgl.c @@ -10,9 +10,10 @@ void Wayland_GL_SwapWindow(_THIS, SDL_Window * window) SDL_WaylandWindow *data = window->driverdata; data->current ^= 1; - glFramebufferRenderbuffer(GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, + glFlush(); + glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, data->rbo[data->current]); wl_surface_attach(data->surface, @@ -27,12 +28,33 @@ Wayland_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) printf("Wayland_GL_MakeCurrent\n"); SDL_WaylandData *data = _this->driverdata; SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata; + int i; + if (!eglMakeCurrent(data->edpy,EGL_NO_SURFACE, EGL_NO_SURFACE,wind->context)) { SDL_SetError("Unable to make EGL context current"); return -1; } + + glGenFramebuffers(1, &data->fbo); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, data->fbo); + + glGenRenderbuffers(2, wind->rbo); + for (i = 0; i < 2; ++i) { + glBindRenderbuffer(GL_RENDERBUFFER_EXT, wind->rbo[i]); + glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER_EXT, + wind->image[i]); + } + + wind->current = 0; + glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, + wind->rbo[wind->current]); + fprintf(stderr, "framebuffer complete: %d\n", + glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE); + return 1; } @@ -102,11 +124,13 @@ Wayland_GL_LoadLibrary(_THIS, const char *path) data->edpy = eglGetDRMDisplayMESA(data->drm_fd); - int major, minor; - if (!eglInitialize(data->edpy, &major, &minor)) { - fprintf(stderr, "failed to initialize display\n"); - return -1; - } + int major, minor; + if (!eglInitialize(data->edpy, &major, &minor)) { + fprintf(stderr, "failed to initialize display\n"); + return -1; + } + + eglBindAPI(EGL_OPENGL_API); /* if (!eglBindAPI(EGL_OPENGL_ES_API)) { fprintf(stderr, "failed to bind EGL_OPENGL_ES_API\n"); @@ -159,12 +183,9 @@ Wayland_GL_CreateContext(_THIS, SDL_Window * window) SDL_WaylandWindow *wind = (SDL_WaylandWindow *) window->driverdata; //Display *display = data->videodata->display; + printf("Wayland_GL_CreateContext\n"); - static const EGLint context_attribs[] = { - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE - }; - wind->context = eglCreateContext(data->edpy, NULL, EGL_NO_CONTEXT, context_attribs); + wind->context = eglCreateContext(data->edpy, NULL, EGL_NO_CONTEXT, NULL); if (wind->context == EGL_NO_CONTEXT) { @@ -172,9 +193,9 @@ Wayland_GL_CreateContext(_THIS, SDL_Window * window) return NULL; } + Wayland_GL_MakeCurrent(_this, window, NULL); //data->egl_active = 1; - return 1; } @@ -189,3 +210,5 @@ Wayland_GL_GetSwapInterval(_THIS) { return 0; } + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index bfda5956..2a829a23 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -91,11 +91,10 @@ Wayland_CreateDevice(int devindex) device->GL_CreateContext = Wayland_GL_CreateContext; device->GL_LoadLibrary = Wayland_GL_LoadLibrary; device->GL_UnloadLibrary = Wayland_GL_UnloadLibrary; - - - - device->CreateWindow = Wayland_CreateWindow; + + device->CreateWindow = Wayland_CreateWindow; + device->ShowWindow = Wayland_ShowWindow; device->free = Wayland_DeleteDevice; @@ -183,6 +182,22 @@ display_handle_global(struct wl_display *display, uint32_t id, } +static int update_event_mask(uint32_t mask, void *data) +{ + SDL_WaylandData *d = data; + + d->event_mask = mask; + printf(stderr, "updated event_mask: %d\n", mask); + +#if 0 + if (mask & WL_DISPLAY_READABLE) + wl_display_iterate(d->display, WL_DISPLAY_READABLE); +#endif + if (mask & WL_DISPLAY_WRITABLE) + wl_display_iterate(d->display, WL_DISPLAY_WRITABLE); + + return 0; +} int Wayland_VideoInit(_THIS) @@ -230,8 +245,7 @@ Wayland_VideoInit(_THIS) wl_display_iterate (data->display, WL_DISPLAY_READABLE); - - + data->event_fd = wl_display_get_fd(data->display, update_event_mask, data); SDL_VideoDisplay display; SDL_DisplayMode mode; diff --git a/src/video/wayland/SDL_waylandvideo.h b/src/video/wayland/SDL_waylandvideo.h index 29c747e4..a7f0d7cf 100644 --- a/src/video/wayland/SDL_waylandvideo.h +++ b/src/video/wayland/SDL_waylandvideo.h @@ -25,8 +25,8 @@ #define _SDL_waylandvideo_h #include "../SDL_sysvideo.h" -#include </home/joel/install/include/wayland-client.h> -#include </home/joel/install/include/wayland-client-protocol.h> +#include <wayland-client.h> +#include <wayland-client-protocol.h> #define GL_GLEXT_PROTOTYPES #define EGL_EGLEXT_PROTOTYPES #include <EGL/egl.h> @@ -52,7 +52,10 @@ typedef struct int drm_fd; EGLDisplay edpy; - + GLuint fbo; + + int event_fd; + int event_mask; } SDL_WaylandData; #endif /* _SDL_nullvideo_h */ diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 3adf7fe5..02524cba 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -5,6 +5,18 @@ #include "SDL_waylandvideo.h" +void Wayland_ShowWindow(_THIS, SDL_Window * window) +{ + SDL_WaylandWindow *data = (SDL_WaylandWindow*) window->driverdata; + glFlush(); + + wl_surface_attach(data->surface, + data->buffer[data->current]); + wl_surface_map(data->surface, + 0, 0, + window->w, window->h); +} + int Wayland_CreateWindow(_THIS, SDL_Window * window) { @@ -26,45 +38,26 @@ int Wayland_CreateWindow(_THIS, SDL_Window * window) EGL_NONE }; - data->surface = wl_compositor_create_surface(c->compositor); wl_surface_set_user_data(data->surface, data); - glGenRenderbuffers(2, data->rbo); + visual = wl_display_get_premultiplied_argb_visual(c->display); for (i = 0; i < 2; i++) { - glBindRenderbuffer(GL_RENDERBUFFER, data->rbo[i]); - attribs[1] = window->w; attribs[3] = window->h; data->image[i] = - eglCreateDRMImageMESA(c->display, attribs); - glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, - data->image[i]); - eglExportDRMImageMESA(c->display, data->image[i], + eglCreateDRMImageMESA(c->edpy, attribs); + eglExportDRMImageMESA(c->edpy, data->image[i], &name, NULL, &stride); data->buffer[i] = wl_drm_create_buffer(c->drm, name, window->w, window->h, stride, visual); } - data->current = 0; - glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, data->image[0]); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, - GL_COLOR_ATTACHMENT0, - GL_RENDERBUFFER, - data->rbo[data->current]); - - wl_surface_attach(data->surface, - data->buffer[data->current]); - wl_surface_map(data->surface, - 0, 0, - window->w, window->h); printf("window %d %d\n", window->w, window->h); - glClearColor(0, 0, 0, 0.5); - return 0; } diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h index 6b8e4f6a..59b8dcfb 100644 --- a/src/video/wayland/SDL_waylandwindow.h +++ b/src/video/wayland/SDL_waylandwindow.h @@ -9,18 +9,19 @@ typedef struct { - struct wl_surface *surface; - struct wl_buffer *buffer[2]; + struct wl_surface *surface; + struct wl_buffer *buffer[2]; - EGLImageKHR image[2]; - GLuint rbo[2]; - uint32_t fb_id[2]; - uint32_t current; + EGLImageKHR image[2]; + GLuint rbo[2]; + uint32_t fb_id[2]; + uint32_t current; EGLContext context; - + } SDL_WaylandWindow; +extern void Wayland_ShowWindow(_THIS, SDL_Window * window); extern int Wayland_CreateWindow(_THIS, SDL_Window * window); #endif /* _SDL_waylandwindow_h */ |