changeset 3411:d15a4daa4a58

Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
author Mike Gorchak <lestat@i.com.ua>
date Thu, 22 Oct 2009 06:08:36 +0000
parents f4bc25567731
children fe9c8a5cab51
files src/video/photon/SDL_photon.c src/video/photon/SDL_photon_render.c
diffstat 2 files changed, 51 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/photon/SDL_photon.c	Thu Oct 22 06:07:05 2009 +0000
+++ b/src/video/photon/SDL_photon.c	Thu Oct 22 06:08:36 2009 +0000
@@ -328,7 +328,9 @@
     char *override;
 
     /* By default Photon do not uses swap on VSYNC */
+#if defined(SDL_VIDEO_OPENGL_ES)
     phdata->swapinterval = 0;
+#endif /* SDL_VIDEO_OPENGL_ES */
 
     for (it = 0; it < phdata->avail_rids; it++) {
         didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
@@ -1470,7 +1472,7 @@
         return NULL;
     }
 
-    /* Prepare attributes list to pass them to OpenGL ES */
+    /* Prepare attributes list to pass them to OpenGL ES egl interface */
     attr_pos = 0;
     wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID;
     wdata->gles_attributes[attr_pos++] =
@@ -1501,12 +1503,19 @@
 
     /* Setup depth buffer bits */
     wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
-    wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size;
+    if (_this->gl_config.depth_size)
+    {
+        wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size;
+    }
+    else
+    {
+        wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
+    }
 
     /* Setup stencil bits */
     if (_this->gl_config.stencil_size) {
         wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
-        wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size;
+        wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size;
     } else {
         wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
         wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
@@ -1622,6 +1631,8 @@
     for (cit = 0; cit < configs; cit++) {
         uint32_t stencil_found;
         uint32_t depth_found;
+        EGLint   cur_depth;
+        EGLint   cur_stencil;
 
         stencil_found = 0;
         depth_found = 0;
@@ -1630,9 +1641,9 @@
             status =
                 eglGetConfigAttrib(phdata->egldisplay,
                                    wdata->gles_configs[cit], EGL_STENCIL_SIZE,
-                                   &attr_value);
+                                   &cur_stencil);
             if (status == EGL_TRUE) {
-                if (attr_value != 0) {
+                if (cur_stencil != 0) {
                     stencil_found = 1;
                 }
             }
@@ -1644,9 +1655,9 @@
             status =
                 eglGetConfigAttrib(phdata->egldisplay,
                                    wdata->gles_configs[cit], EGL_DEPTH_SIZE,
-                                   &attr_value);
+                                   &cur_depth);
             if (status == EGL_TRUE) {
-                if (attr_value != 0) {
+                if (cur_depth != 0) {
                     depth_found = 1;
                 }
             }
@@ -1656,15 +1667,34 @@
 
         /* Exit from loop if found appropriate configuration */
         if ((depth_found != 0) && (stencil_found != 0)) {
-            break;
+            /* Store last satisfied configuration id */
+            wdata->gles_config = cit;
+
+            if (cur_depth==_this->gl_config.depth_size)
+            {
+                /* Exact match on depth bits */
+                if (!_this->gl_config.stencil_size)
+                {
+                    /* Stencil is not required */
+                    break;
+                }
+                else
+                {
+                    if (cur_stencil==_this->gl_config.stencil_size)
+                    {
+                        /* Exact match on stencil bits */
+                        break;
+                    }
+                }
+            }
         }
     }
 
-    /* If best could not be found, use first */
-    if (cit == configs) {
+    /* If best could not be found, use first or last satisfied */
+    if ((cit == configs) && (wdata->gles_config==0)) {
         cit = 0;
+        wdata->gles_config = cit;
     }
-    wdata->gles_config = cit;
 
     /* Create OpenGL ES context */
     wdata->gles_context =
@@ -2375,6 +2405,7 @@
                                 if ((wdata != NULL) && (window != NULL)) {
                                     /* Check if window uses OpenGL ES */
                                     if (wdata->uses_gles == SDL_TRUE) {
+                                        #if defined(SDL_VIDEO_OPENGL_ES)
                                         /* Cycle through each rectangle */
                                         for (it = 0; it < event->num_rects; it++) {
                                             /* Blit OpenGL ES pixmap surface directly to window region */
@@ -2391,6 +2422,7 @@
                                             PgFFlush(Ph_DONE_DRAW);
                                             PgWaitHWIdle();
                                         }
+                                        #endif /* SDL_VIDEO_OPENGL_ES */
                                     } else {
                                         /* Cycle through each rectangle */
                                         for (it = 0; it < event->num_rects;
@@ -2424,6 +2456,7 @@
                                         src_rect.lr.x = window->w - 1;
                                         src_rect.lr.y = window->h - 1;
 
+                                        #if defined(SDL_VIDEO_OPENGL_ES)
                                         /* We need to redraw entire window */
                                         PgFFlush(Ph_START_DRAW);
                                         PgSetRegionCx(PhDCGetCurrent(),
@@ -2437,6 +2470,7 @@
                                                       &dst_rect);
                                         PgFFlush(Ph_DONE_DRAW);
                                         PgWaitHWIdle();
+                                        #endif /* SDL_VIDEO_OPENGL_ES */
                                     } else {
                                         PhRect_t rect;
 
@@ -2705,7 +2739,7 @@
                                         PhRegionChange(Ph_REGION_EV_SENSE, 0,
                                                        &wregion, NULL, NULL);
 
-                                        /* If window got a focus, the it is visible */
+                                        /* If window got a focus, then it is visible */
                                         SDL_SendWindowEvent(window->id,
                                                             SDL_WINDOWEVENT_SHOWN,
                                                             0, 0);
--- a/src/video/photon/SDL_photon_render.c	Thu Oct 22 06:07:05 2009 +0000
+++ b/src/video/photon/SDL_photon_render.c	Thu Oct 22 06:08:36 2009 +0000
@@ -34,6 +34,11 @@
 #include "SDL_photon_render.h"
 #include "SDL_photon.h"
 
+#ifndef Pg_OSC_MEM_LINEAR_ACCESSIBLE
+    /* For QNX 6.3.2 compatibility */
+    #define Pg_OSC_MEM_LINEAR_ACCESSIBLE 0
+#endif /* Pg_OSC_MEM_LINEAR_ACCESSIBLE */
+
 static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags);
 static int photon_displaymodechanged(SDL_Renderer * renderer);
 static int photon_activaterenderer(SDL_Renderer * renderer);