From: Frédéric Dalleau Date: Wed, 12 Jun 2013 09:07:11 +0000 (+0200) Subject: On windows, wgl backend, remove usage of wglBindTexImageARB. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~749^2~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6251ca710d978d803b52cc72995be9ba38993de;p=sdk%2Femulator%2Fqemu.git On windows, wgl backend, remove usage of wglBindTexImageARB. This function is provided by extension WGL_ARB_render_texture. The extension is not supported by Intel hardware. So instead, use glReadPixels/glTexImage2D Additionnally do not flip pbuffer vertically when using them as textures. --- diff --git a/tizen/src/hw/gloffscreen_agl.c b/tizen/src/hw/gloffscreen_agl.c index 33e38c55ee..5ae68c58fd 100644 --- a/tizen/src/hw/gloffscreen_agl.c +++ b/tizen/src/hw/gloffscreen_agl.c @@ -57,7 +57,7 @@ struct _GloSurface extern void glo_surface_getcontents_readpixels(int formatFlags, int stride, int bpp, int width, int height, - void *data); + void *data, int noflip); @@ -316,7 +316,7 @@ void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, { aglSwapBuffers(surface->context->context); aglSetInteger(surface->context->context, AGL_SWAP_INTERVAL, &swap_interval); - glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, surface->height, data); + glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, surface->height, data, 0); } } diff --git a/tizen/src/hw/gloffscreen_common.c b/tizen/src/hw/gloffscreen_common.c index bd1285421c..c8fd382c9b 100644 --- a/tizen/src/hw/gloffscreen_common.c +++ b/tizen/src/hw/gloffscreen_common.c @@ -102,7 +102,7 @@ void g_free(void *ptr); // --------------------------------------------------- extern void glo_surface_getcontents_readpixels(int formatFlags, int stride, - int bpp, int width, int height, void *data); + int bpp, int width, int height, void *data, int noflip); // --------------------------------------------------- @@ -370,7 +370,7 @@ void glo_geometry_get_from_glx(const int* attrib_list, int* width, int* height) } void glo_surface_getcontents_readpixels(int formatFlags, int stride, int bpp, - int width, int height, void *data) { + int width, int height, void *data, int noflip) { int glFormat, glType, rl, pa; static int once; @@ -418,12 +418,14 @@ void glo_surface_getcontents_readpixels(int formatFlags, int stride, int bpp, glReadPixels(0, 0, width, height, glFormat, glType, data); - for(irow = 0; irow < height/2; irow++) { - memcpy(tmp, b, stride); - memcpy(b, c, stride); - memcpy(c, tmp, stride); - b += stride; - c -= stride; + if (noflip == 0) { + for(irow = 0; irow < height/2; irow++) { + memcpy(tmp, b, stride); + memcpy(b, c, stride); + memcpy(c, tmp, stride); + b += stride; + c -= stride; + } } g_free(tmp); diff --git a/tizen/src/hw/gloffscreen_glx.c b/tizen/src/hw/gloffscreen_glx.c index f649a0ff3e..a2ec3b2cc0 100644 --- a/tizen/src/hw/gloffscreen_glx.c +++ b/tizen/src/hw/gloffscreen_glx.c @@ -71,7 +71,7 @@ struct _GloSurface { }; extern void glo_surface_getcontents_readpixels(int formatFlags, int stride, - int bpp, int width, int height, void *data); + int bpp, int width, int height, void *data, int noflip); static void glo_test_readback_methods(void); /* ------------------------------------------------------------------------ */ @@ -371,7 +371,7 @@ void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *dat // Compatible / fallback method. glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, - surface->height, data); + surface->height, data, 0); } // while(0) { diff --git a/tizen/src/hw/gloffscreen_wgl.c b/tizen/src/hw/gloffscreen_wgl.c index aa8d0ad0a1..610a911f7e 100644 --- a/tizen/src/hw/gloffscreen_wgl.c +++ b/tizen/src/hw/gloffscreen_wgl.c @@ -43,6 +43,12 @@ #include "gl_mangled.h" #endif +enum { + SURFACE_WINDOW, + SURFACE_PIXMAP, + SURFACE_PBUFFER +}; + /* In Windows, you must create a window *before* you can create a pbuffer or * get a context. So we create a hidden Window on startup (see glo_init/GloMain). * @@ -98,7 +104,7 @@ PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; extern const char *glo_glXQueryExtensionsString(void); extern void glo_surface_getcontents_readpixels(int formatFlags, int stride, - int bpp, int width, int height, void *data); + int bpp, int width, int height, void *data, int noflip); /* ------------------------------------------------------------------------ */ @@ -946,7 +952,7 @@ void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *dat // Compatible / fallback method. glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, - surface->height, data); + surface->height, data, 0); } /* Return the width and height of the given surface */ @@ -960,33 +966,35 @@ void glo_surface_get_size(GloSurface *surface, int *width, int *height) { /* Bind the surface as texture */ void glo_surface_as_texture(GloContext *ctxt, GloSurface *surface, int surface_type) { -#if 0 int glFormat, glType; - glo_surface_updatecontents(surface); - /*XXX: change the fixed target: GL_TEXTURE_2D*/ - glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat, &glType); - fprintf(stderr, "surface_as_texture:teximage:width=%d,height=%d,glFormat=0x%x,glType=0x%x.\n", surface->width, surface->height, glFormat, glType); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, surface->image->data); -#else - if(!Render_texture_support) - { - //fprintf(stderr, "Render to texture not supported on this machine, just return!\n"); - return ; - } + int bpp = 4; + int stride = surface->width * bpp; + char *data; + HGLRC oldCtx; + HDC oldDC; - if (!wglBindTexImageARB) - { - fprintf (stderr, "wglBindTexImageEXT not supported! Can't emulate glEGLImageTargetTexture2DOES!\n"); + data = malloc(surface->width * surface->height * bpp); + if (!data) return; - } - if ( !wglBindTexImageARB(surface->hPBuffer, WGL_FRONT_LEFT_ARB) ) - { - fprintf(stderr, "wglBindTexImageARBr error=%d.\n", glGetError()); - } + /* Read pixels from Speficied context */ + oldCtx = wglGetCurrentContext(); + oldDC = wglGetCurrentDC(); + glo_surface_makecurrent(surface); + glo_surface_updatecontents(surface); + glo_flags_get_readpixel_type(surface->context->formatFlags, &glFormat, &glType); + // Make sure we do not flip pbuffer surfaces on Windows + glo_surface_getcontents_readpixels(surface->context->formatFlags, + stride, bpp *8, surface->width, + surface->height, data, (surface_type == SURFACE_PBUFFER)); -#endif + /* Restore previous context for setting texture */ + wglMakeCurrent(oldDC, oldCtx); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->width, surface->height, 0, glFormat, glType, data); + free(data); } + void glo_surface_release_texture(GloSurface *surface) { if(!Render_texture_support) diff --git a/tizen/src/hw/gloffscreen_xcomposite.c b/tizen/src/hw/gloffscreen_xcomposite.c index 9887cc0572..e54e7cfb34 100644 --- a/tizen/src/hw/gloffscreen_xcomposite.c +++ b/tizen/src/hw/gloffscreen_xcomposite.c @@ -83,7 +83,7 @@ struct _GloSurface { }; extern void glo_surface_getcontents_readpixels(int formatFlags, int stride, - int bpp, int width, int height, void *data); + int bpp, int width, int height, void *data, int noflip); static void glo_test_readback_methods(void); /* ------------------------------------------------------------------------ */ @@ -477,7 +477,7 @@ void glo_surface_getcontents(GloSurface *surface, int stride, int bpp, void *dat // Compatible / fallback method. glo_surface_getcontents_readpixels(surface->context->formatFlags, stride, bpp, surface->width, - surface->height, data); + surface->height, data, 0); } /* Return the width and height of the given surface */