Navigation Menu

Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
llmike committed Oct 22, 2009
1 parent cc4ff58 commit 3724fd0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
58 changes: 46 additions & 12 deletions src/video/photon/SDL_photon.c
Expand Up @@ -328,7 +328,9 @@ photon_videoinit(_THIS)
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));
Expand Down Expand Up @@ -1470,7 +1472,7 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
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++] =
Expand Down Expand Up @@ -1501,12 +1503,19 @@ photon_gl_createcontext(_THIS, SDL_Window * window)

/* 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;
Expand Down Expand Up @@ -1622,6 +1631,8 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
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;
Expand All @@ -1630,9 +1641,9 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
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;
}
}
Expand All @@ -1644,9 +1655,9 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
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;
}
}
Expand All @@ -1656,15 +1667,34 @@ photon_gl_createcontext(_THIS, SDL_Window * window)

/* 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 =
Expand Down Expand Up @@ -2375,6 +2405,7 @@ photon_pumpevents(_THIS)
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 */
Expand All @@ -2391,6 +2422,7 @@ photon_pumpevents(_THIS)
PgFFlush(Ph_DONE_DRAW);
PgWaitHWIdle();
}
#endif /* SDL_VIDEO_OPENGL_ES */
} else {
/* Cycle through each rectangle */
for (it = 0; it < event->num_rects;
Expand Down Expand Up @@ -2424,6 +2456,7 @@ photon_pumpevents(_THIS)
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(),
Expand All @@ -2437,6 +2470,7 @@ photon_pumpevents(_THIS)
&dst_rect);
PgFFlush(Ph_DONE_DRAW);
PgWaitHWIdle();
#endif /* SDL_VIDEO_OPENGL_ES */
} else {
PhRect_t rect;

Expand Down Expand Up @@ -2705,7 +2739,7 @@ photon_pumpevents(_THIS)
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);
Expand Down
5 changes: 5 additions & 0 deletions src/video/photon/SDL_photon_render.c
Expand Up @@ -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);
Expand Down

0 comments on commit 3724fd0

Please sign in to comment.