From a3fd0e561e2de95d1197b47342e35f2a0d255b94 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Mon, 20 Jan 2014 15:03:51 +0000 Subject: [PATCH] gl-render: import buffers from egl. git-svn-id: svn://kolibrios.org@4495 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/sdk/samples/Mesa/gl-render/main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/contrib/sdk/samples/Mesa/gl-render/main.c b/contrib/sdk/samples/Mesa/gl-render/main.c index ccac49e676..b02d744d41 100644 --- a/contrib/sdk/samples/Mesa/gl-render/main.c +++ b/contrib/sdk/samples/Mesa/gl-render/main.c @@ -29,12 +29,12 @@ int main() EGLContext context; EGLSurface surface; - EGLImageKHR fb_image; + EGLImageKHR front,fb_image; EGLConfig config; EGLint config_attribs[32]; EGLint num_configs, i; - GLuint texture, buffer, front; + GLuint texture, buffer; GLuint f_tex; int fd; @@ -83,7 +83,7 @@ int main() if (!context) printf("failed to create context"); -// gs = gbm_surface_create(gbm, 1024, 768, GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING); + gs = gbm_surface_create(gbm, 400, 300, GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING); BeginDraw(); @@ -92,15 +92,22 @@ int main() sna_create_mask(); - // surface = eglCreateWindowSurface(dpy,config, (EGLNativeWindowType)gs, NULL); - // if (surface == EGL_NO_SURFACE) - // printf("failed to create surface"); + surface = eglCreateWindowSurface(dpy,config, (EGLNativeWindowType)gs, NULL); + if (surface == EGL_NO_SURFACE) + printf("failed to create surface"); - if (!eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, context)) + if (!eglMakeCurrent(dpy, surface, surface, context)) printf("failed to make window current"); - front = create_framebuffer(400,300,&f_tex); + front = eglGetBufferImage(dpy, surface, EGL_DRM_BUFFER_BACK); + glGenTextures(1, &f_tex); + glBindTexture(GL_TEXTURE_2D, f_tex); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D,front); + glBindTexture(GL_TEXTURE_2D, 0); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);