From c7790bdb2b7d1793cb6e7091ae06de653ce93e67 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 6 Aug 2014 11:34:54 -0700 Subject: [PATCH 01/50] Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers --- include/SDL_pixels.h | 6 +- src/render/opengl/SDL_render_gl.c | 116 +++++++---- src/render/opengl/SDL_shaders_gl.c | 102 +++++++++- src/render/opengl/SDL_shaders_gl.h | 4 +- src/render/opengles2/SDL_render_gles2.c | 233 ++++++++++------------- src/render/opengles2/SDL_shaders_gles2.c | 82 ++++++++ src/render/opengles2/SDL_shaders_gles2.h | 4 +- src/test/SDL_test_common.c | 6 + src/video/SDL_pixels.c | 2 + src/video/SDL_surface.c | 35 +++- test/testautomation_pixels.c | 10 +- test/testoverlay2.c | 39 +++- 12 files changed, 456 insertions(+), 183 deletions(-) diff --git a/include/SDL_pixels.h b/include/SDL_pixels.h index 3131af7b7..61e97c8d2 100644 --- a/include/SDL_pixels.h +++ b/include/SDL_pixels.h @@ -248,7 +248,11 @@ enum SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ - SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U') + SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), + SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), + SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1') }; typedef struct SDL_Color diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index e1c78cb8b..e3a6b55bc 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -164,8 +164,9 @@ typedef struct int pitch; SDL_Rect locked_rect; - /* YV12 texture support */ + /* YUV texture support */ SDL_bool yuv; + SDL_bool nv12; GLuint utexture; GLuint vtexture; @@ -531,6 +532,8 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) if (data->shaders && data->num_texture_units >= 3) { renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; } #ifdef __MACOSX__ @@ -611,16 +614,18 @@ convert_format(GL_RenderData *renderdata, Uint32 pixel_format, break; case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: *internalFormat = GL_LUMINANCE; *format = GL_LUMINANCE; *type = GL_UNSIGNED_BYTE; break; #ifdef __MACOSX__ case SDL_PIXELFORMAT_UYVY: - *internalFormat = GL_RGB8; - *format = GL_YCBCR_422_APPLE; - *type = GL_UNSIGNED_SHORT_8_8_APPLE; - break; + *internalFormat = GL_RGB8; + *format = GL_YCBCR_422_APPLE; + *type = GL_UNSIGNED_SHORT_8_8_APPLE; + break; #endif default: return SDL_FALSE; @@ -672,6 +677,11 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) /* Need to add size for the U and V planes */ size += (2 * (texture->h * data->pitch) / 4); } + if (texture->format == SDL_PIXELFORMAT_NV12 || + texture->format == SDL_PIXELFORMAT_NV21) { + /* Need to add size for the U/V plane */ + size += ((texture->h * data->pitch) / 2); + } data->pixels = SDL_calloc(1, size); if (!data->pixels) { SDL_free(data); @@ -801,6 +811,27 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderdata->glDisable(data->type); } + if (texture->format == SDL_PIXELFORMAT_NV12 || + texture->format == SDL_PIXELFORMAT_NV21) { + data->nv12 = SDL_TRUE; + + renderdata->glGenTextures(1, &data->utexture); + renderdata->glEnable(data->type); + + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, GL_LUMINANCE_ALPHA, texture_w/2, + texture_h/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); + renderdata->glDisable(data->type); + } + return GL_CheckError("", renderer); } @@ -848,6 +879,17 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, rect->w/2, rect->h/2, data->format, data->formattype, pixels); } + + if (data->nv12) { + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2)); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels); + } renderdata->glDisable(data->type); return GL_CheckError("glTexSubImage2D()", renderer); @@ -1184,15 +1226,10 @@ GL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) } static int -GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_FRect * dstrect) +GL_SetupCopy(SDL_Renderer * renderer, SDL_Texture * texture) { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; - GLfloat minx, miny, maxx, maxy; - GLfloat minu, maxu, minv, maxv; - - GL_ActivateRenderer(renderer); data->glEnable(texturedata->type); if (texturedata->yuv) { @@ -1204,6 +1241,12 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, data->glActiveTextureARB(GL_TEXTURE0_ARB); } + if (texturedata->nv12) { + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glBindTexture(texturedata->type, texturedata->utexture); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } data->glBindTexture(texturedata->type, texturedata->texture); if (texture->modMode) { @@ -1215,10 +1258,33 @@ GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, GL_SetBlendMode(data, texture->blendMode); if (texturedata->yuv) { - GL_SetShader(data, SHADER_YV12); + GL_SetShader(data, SHADER_YUV); + } else if (texturedata->nv12) { + if (texture->format == SDL_PIXELFORMAT_NV12) { + GL_SetShader(data, SHADER_NV12); + } else { + GL_SetShader(data, SHADER_NV21); + } } else { GL_SetShader(data, SHADER_RGB); } + return 0; +} + +static int +GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + GLfloat minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + + GL_ActivateRenderer(renderer); + + if (GL_SetupCopy(renderer, texture) < 0) { + return -1; + } minx = dstrect->x; miny = dstrect->y; @@ -1263,30 +1329,8 @@ GL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GL_ActivateRenderer(renderer); - data->glEnable(texturedata->type); - if (texturedata->yuv) { - data->glActiveTextureARB(GL_TEXTURE2_ARB); - data->glBindTexture(texturedata->type, texturedata->vtexture); - - data->glActiveTextureARB(GL_TEXTURE1_ARB); - data->glBindTexture(texturedata->type, texturedata->utexture); - - data->glActiveTextureARB(GL_TEXTURE0_ARB); - } - data->glBindTexture(texturedata->type, texturedata->texture); - - if (texture->modMode) { - GL_SetColor(data, texture->r, texture->g, texture->b, texture->a); - } else { - GL_SetColor(data, 255, 255, 255, 255); - } - - GL_SetBlendMode(data, texture->blendMode); - - if (texturedata->yuv) { - GL_SetShader(data, SHADER_YV12); - } else { - GL_SetShader(data, SHADER_RGB); + if (GL_SetupCopy(renderer, texture) < 0) { + return -1; } centerx = center->x; diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index b10a1a492..616f64aac 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -113,7 +113,7 @@ static const char *shader_source[NUM_SHADERS][2] = "}" }, - /* SHADER_YV12 */ + /* SHADER_YUV */ { /* vertex shader */ "varying vec4 v_color;\n" @@ -162,6 +162,106 @@ static const char *shader_source[NUM_SHADERS][2] = "\n" " // That was easy. :) \n" " gl_FragColor = vec4(rgb, 1.0) * v_color;\n" +"}" + }, + + /* SHADER_NV12 */ + { + /* vertex shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +" v_texCoord = vec2(gl_MultiTexCoord0);\n" +"}", + /* fragment shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0; // Y \n" +"uniform sampler2D tex1; // U/V \n" +"\n" +"// YUV offset \n" +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" +"\n" +"// RGB coefficients \n" +"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n" +"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n" +"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n" +"\n" +"void main()\n" +"{\n" +" vec2 tcoord;\n" +" vec3 yuv, rgb;\n" +"\n" +" // Get the Y value \n" +" tcoord = v_texCoord;\n" +" yuv.x = texture2D(tex0, tcoord).r;\n" +"\n" +" // Get the U and V values \n" +" tcoord *= 0.5;\n" +" yuv.yz = texture2D(tex1, tcoord).ra;\n" +"\n" +" // Do the color transform \n" +" yuv += offset;\n" +" rgb.r = dot(yuv, Rcoeff);\n" +" rgb.g = dot(yuv, Gcoeff);\n" +" rgb.b = dot(yuv, Bcoeff);\n" +"\n" +" // That was easy. :) \n" +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" +"}" + }, + + /* SHADER_NV21 */ + { + /* vertex shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +" v_texCoord = vec2(gl_MultiTexCoord0);\n" +"}", + /* fragment shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0; // Y \n" +"uniform sampler2D tex1; // U/V \n" +"\n" +"// YUV offset \n" +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" +"\n" +"// RGB coefficients \n" +"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n" +"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n" +"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n" +"\n" +"void main()\n" +"{\n" +" vec2 tcoord;\n" +" vec3 yuv, rgb;\n" +"\n" +" // Get the Y value \n" +" tcoord = v_texCoord;\n" +" yuv.x = texture2D(tex0, tcoord).r;\n" +"\n" +" // Get the U and V values \n" +" tcoord *= 0.5;\n" +" yuv.yz = texture2D(tex1, tcoord).ar;\n" +"\n" +" // Do the color transform \n" +" yuv += offset;\n" +" rgb.r = dot(yuv, Rcoeff);\n" +" rgb.g = dot(yuv, Gcoeff);\n" +" rgb.b = dot(yuv, Bcoeff);\n" +"\n" +" // That was easy. :) \n" +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" "}" }, }; diff --git a/src/render/opengl/SDL_shaders_gl.h b/src/render/opengl/SDL_shaders_gl.h index fdd4db7fc..4604f05f7 100644 --- a/src/render/opengl/SDL_shaders_gl.h +++ b/src/render/opengl/SDL_shaders_gl.h @@ -26,7 +26,9 @@ typedef enum { SHADER_NONE, SHADER_SOLID, SHADER_RGB, - SHADER_YV12, + SHADER_YUV, + SHADER_NV12, + SHADER_NV21, NUM_SHADERS } GL_Shader; diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 604b93fc7..a32c738a3 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -81,8 +81,9 @@ typedef struct GLES2_TextureData GLenum pixel_type; void *pixel_data; int pitch; - /* YV12 texture support */ + /* YUV texture support */ SDL_bool yuv; + SDL_bool nv12; GLenum texture_v; GLenum texture_u; GLES2_FBOList *fbo; @@ -151,7 +152,9 @@ typedef enum GLES2_IMAGESOURCE_TEXTURE_ARGB, GLES2_IMAGESOURCE_TEXTURE_RGB, GLES2_IMAGESOURCE_TEXTURE_BGR, - GLES2_IMAGESOURCE_TEXTURE_YUV + GLES2_IMAGESOURCE_TEXTURE_YUV, + GLES2_IMAGESOURCE_TEXTURE_NV12, + GLES2_IMAGESOURCE_TEXTURE_NV21 } GLES2_ImageSource; typedef struct GLES2_DriverContext @@ -488,6 +491,8 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) break; case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: format = GL_LUMINANCE; type = GL_UNSIGNED_BYTE; break; @@ -505,6 +510,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) data->pixel_format = format; data->pixel_type = type; data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12)); + data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21)); data->texture_u = 0; data->texture_v = 0; scaleMode = GetScaleQuality(); @@ -518,6 +524,10 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Need to add size for the U and V planes */ size += (2 * (texture->h * data->pitch) / 4); } + if (data->nv12) { + /* Need to add size for the U/V plane */ + size += ((texture->h * data->pitch) / 2); + } data->pixel_data = SDL_calloc(1, size); if (!data->pixel_data) { SDL_free(data); @@ -557,6 +567,23 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } } + if (data->nv12) { + renderdata->glGenTextures(1, &data->texture_u); + if (GL_CheckError("glGenTexures()", renderer) < 0) { + return -1; + } + renderdata->glActiveTexture(GL_TEXTURE1); + renderdata->glBindTexture(data->texture_type, data->texture_u); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->texture_type, 0, GL_LUMINANCE_ALPHA, texture->w / 2, texture->h / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); + if (GL_CheckError("glTexImage2D()", renderer) < 0) { + return -1; + } + } + renderdata->glGenTextures(1, &data->texture); if (GL_CheckError("glGenTexures()", renderer) < 0) { return -1; @@ -673,6 +700,20 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect pixels, pitch / 2, 1); } + if (tdata->nv12) { + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); + data->glBindTexture(tdata->texture_type, tdata->texture_u); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + rect->w / 2, + rect->h / 2, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + pixels, pitch, 2); + } + return GL_CheckError("glTexSubImage2D()", renderer); } @@ -1093,6 +1134,12 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM case GLES2_IMAGESOURCE_TEXTURE_YUV: ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC; break; + case GLES2_IMAGESOURCE_TEXTURE_NV12: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE_NV21: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC; + break; default: goto fault; } @@ -1432,20 +1479,15 @@ GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) } static int -GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, - const SDL_FRect *dstrect) +GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; SDL_BlendMode blendMode; - GLfloat vertices[8]; - GLfloat texCoords[8]; GLES2_ProgramCacheEntry *program; Uint8 r, g, b, a; - GLES2_ActivateRenderer(renderer); - /* Activate an appropriate shader and set the projection matrix */ blendMode = texture->blendMode; if (renderer->target) { @@ -1505,11 +1547,22 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s break; } break; + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_YV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; + break; + case SDL_PIXELFORMAT_NV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; + break; + case SDL_PIXELFORMAT_NV21: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; + break; + default: + return SDL_SetError("Unsupported texture format"); } } else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ - } - else { + } else { switch (texture->format) { case SDL_PIXELFORMAT_ARGB8888: @@ -1524,13 +1577,18 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s case SDL_PIXELFORMAT_BGR888: sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; break; - // TODO: new shader to change yv planes YV12 format case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_YV12: sourceType = GLES2_IMAGESOURCE_TEXTURE_YUV; break; + case SDL_PIXELFORMAT_NV12: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV12; + break; + case SDL_PIXELFORMAT_NV21: + sourceType = GLES2_IMAGESOURCE_TEXTURE_NV21; + break; default: - return -1; + return SDL_SetError("Unsupported texture format"); } } @@ -1548,6 +1606,12 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s data->glActiveTexture(GL_TEXTURE0); } + if (tdata->nv12) { + data->glActiveTexture(GL_TEXTURE1); + data->glBindTexture(tdata->texture_type, tdata->texture_u); + + data->glActiveTexture(GL_TEXTURE0); + } data->glBindTexture(tdata->texture_type, tdata->texture); /* Configure color modulation */ @@ -1578,6 +1642,23 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s GLES2_SetBlendMode(data, blendMode); GLES2_SetTexCoords(data, SDL_TRUE); + return 0; +} + +static int +GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_FRect *dstrect) +{ + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + GLfloat vertices[8]; + GLfloat texCoords[8]; + + GLES2_ActivateRenderer(renderer); + + if (GLES2_SetupCopy(renderer, texture) < 0) { + return -1; + } /* Emit the textured quad */ vertices[0] = dstrect->x; @@ -1609,10 +1690,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; - GLES2_ImageSource sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; - GLES2_ProgramCacheEntry *program; - Uint8 r, g, b, a; - SDL_BlendMode blendMode; GLfloat vertices[8]; GLfloat texCoords[8]; GLfloat translate[8]; @@ -1621,6 +1698,10 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect GLES2_ActivateRenderer(renderer); + if (GLES2_SetupCopy(renderer, texture) < 0) { + return -1; + } + data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_CENTER); data->glEnableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE); fAngle[0] = fAngle[1] = fAngle[2] = fAngle[3] = (GLfloat)(360.0f - angle); @@ -1628,124 +1709,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect translate[0] = translate[2] = translate[4] = translate[6] = (center->x + dstrect->x); translate[1] = translate[3] = translate[5] = translate[7] = (center->y + dstrect->y); - /* Activate an appropriate shader and set the projection matrix */ - blendMode = texture->blendMode; - if (renderer->target) { - /* Check if we need to do color mapping between the source and render target textures */ - if (renderer->target->format != texture->format) { - switch (texture->format) - { - case SDL_PIXELFORMAT_ARGB8888: - switch (renderer->target->format) - { - case SDL_PIXELFORMAT_ABGR8888: - case SDL_PIXELFORMAT_BGR888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - case SDL_PIXELFORMAT_RGB888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; - break; - } - break; - case SDL_PIXELFORMAT_ABGR8888: - switch (renderer->target->format) - { - case SDL_PIXELFORMAT_ARGB8888: - case SDL_PIXELFORMAT_RGB888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - case SDL_PIXELFORMAT_BGR888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; - break; - } - break; - case SDL_PIXELFORMAT_RGB888: - switch (renderer->target->format) - { - case SDL_PIXELFORMAT_ABGR8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - case SDL_PIXELFORMAT_ARGB8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; - break; - case SDL_PIXELFORMAT_BGR888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - } - break; - case SDL_PIXELFORMAT_BGR888: - switch (renderer->target->format) - { - case SDL_PIXELFORMAT_ABGR8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; - break; - case SDL_PIXELFORMAT_ARGB8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; - break; - case SDL_PIXELFORMAT_RGB888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - } - break; - } - } - else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */ - } - else { - switch (texture->format) - { - case SDL_PIXELFORMAT_ARGB8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; - break; - case SDL_PIXELFORMAT_ABGR8888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; - break; - case SDL_PIXELFORMAT_RGB888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; - break; - case SDL_PIXELFORMAT_BGR888: - sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; - break; - default: - return -1; - } - } - if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) - return -1; - - /* Select the target texture */ - data->glBindTexture(tdata->texture_type, tdata->texture); - - /* Configure color modulation */ - /* !!! FIXME: grep for glUniform4f(), move that stuff to a subroutine, it's a lot of copy/paste. */ - g = texture->g; - a = texture->a; - - if (renderer->target && - (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || - renderer->target->format == SDL_PIXELFORMAT_RGB888)) { - r = texture->b; - b = texture->r; - } else { - r = texture->r; - b = texture->b; - } - - program = data->current_program; - - if (!CompareColors(program->modulation_r, program->modulation_g, program->modulation_b, program->modulation_a, r, g, b, a)) { - data->glUniform4f(program->uniform_locations[GLES2_UNIFORM_MODULATION], r * inv255f, g * inv255f, b * inv255f, a * inv255f); - program->modulation_r = r; - program->modulation_g = g; - program->modulation_b = b; - program->modulation_a = a; - } - - /* Configure texture blending */ - GLES2_SetBlendMode(data, blendMode); - - GLES2_SetTexCoords(data, SDL_TRUE); - /* Emit the textured quad */ vertices[0] = dstrect->x; vertices[1] = dstrect->y; @@ -2066,6 +2029,8 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_NV21; GLES2_ResetState(renderer); diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c index bdc14aeda..48040f968 100644 --- a/src/render/opengles2/SDL_shaders_gles2.c +++ b/src/render/opengles2/SDL_shaders_gles2.c @@ -150,6 +150,50 @@ static const Uint8 GLES2_FragmentSrc_TextureYUVSrc_[] = " \ } \ "; +/* NV12 to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureNV12Src_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform sampler2D u_texture_u; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + mediump vec3 yuv; \ + lowp vec3 rgb; \ + yuv.x = texture2D(u_texture, v_texCoord).r; \ + yuv.yz = texture2D(u_texture_u, v_texCoord).ra - 0.5; \ + rgb = mat3( 1, 1, 1, \ + 0, -0.39465, 2.03211, \ + 1.13983, -0.58060, 0) * yuv; \ + gl_FragColor = vec4(rgb, 1); \ + gl_FragColor *= u_modulation; \ + } \ +"; + +/* NV21 to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureNV21Src_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform sampler2D u_texture_u; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + mediump vec3 yuv; \ + lowp vec3 rgb; \ + yuv.x = texture2D(u_texture, v_texCoord).r; \ + yuv.yz = texture2D(u_texture_u, v_texCoord).ar - 0.5; \ + rgb = mat3( 1, 1, 1, \ + 0, -0.39465, 2.03211, \ + 1.13983, -0.58060, 0) * yuv; \ + gl_FragColor = vec4(rgb, 1); \ + gl_FragColor *= u_modulation; \ + } \ +"; + static const GLES2_ShaderInstance GLES2_VertexSrc_Default = { GL_VERTEX_SHADER, GLES2_SOURCE_SHADER, @@ -199,6 +243,20 @@ static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVSrc = { GLES2_FragmentSrc_TextureYUVSrc_ }; +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV12Src_), + GLES2_FragmentSrc_TextureNV12Src_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21Src = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureNV21Src_), + GLES2_FragmentSrc_TextureNV21Src_ +}; + /************************************************************************************************* * Vertex/fragment shader binaries (NVIDIA Tegra 1/2) * @@ -731,6 +789,20 @@ static GLES2_Shader GLES2_FragmentShader_TextureYUVSrc = { } }; +static GLES2_Shader GLES2_FragmentShader_TextureNV12Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV12Src + } +}; + +static GLES2_Shader GLES2_FragmentShader_TextureNV21Src = { + 1, + { + &GLES2_FragmentSrc_TextureNV21Src + } +}; + /************************************************************************************************* * Shader selector * @@ -820,6 +892,16 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo return &GLES2_FragmentShader_TextureYUVSrc; } + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC: + { + return &GLES2_FragmentShader_TextureNV12Src; + } + + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC: + { + return &GLES2_FragmentShader_TextureNV21Src; + } + default: return NULL; } diff --git a/src/render/opengles2/SDL_shaders_gles2.h b/src/render/opengles2/SDL_shaders_gles2.h index 51bbbcc40..d68f7d05c 100644 --- a/src/render/opengles2/SDL_shaders_gles2.h +++ b/src/render/opengles2/SDL_shaders_gles2.h @@ -47,7 +47,9 @@ typedef enum GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC, GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC, GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC } GLES2_ShaderType; #define GLES2_SOURCE_SHADER (GLenum)-1 diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index a2fe31984..d05dda47b 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -572,6 +572,12 @@ SDLTest_PrintPixelFormat(Uint32 format) case SDL_PIXELFORMAT_YVYU: fprintf(stderr, "YVYU"); break; + case SDL_PIXELFORMAT_NV12: + fprintf(stderr, "NV12"); + break; + case SDL_PIXELFORMAT_NV21: + fprintf(stderr, "NV21"); + break; default: fprintf(stderr, "0x%8.8x", format); break; diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 9eb507e13..0858daade 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -122,6 +122,8 @@ SDL_GetPixelFormatName(Uint32 format) CASE(SDL_PIXELFORMAT_YUY2) CASE(SDL_PIXELFORMAT_UYVY) CASE(SDL_PIXELFORMAT_YVYU) + CASE(SDL_PIXELFORMAT_NV12) + CASE(SDL_PIXELFORMAT_NV21) #undef CASE default: return "SDL_PIXELFORMAT_UNKNOWN"; diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index ccf89ca1c..421e2b806 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -1005,7 +1005,7 @@ int SDL_ConvertPixels(int width, int height, SDL_Rect rect; void *nonconst_src = (void *) src; - /* Check to make sure we are bliting somewhere, so we don't crash */ + /* Check to make sure we are blitting somewhere, so we don't crash */ if (!dst) { return SDL_InvalidParamError("dst"); } @@ -1015,17 +1015,21 @@ int SDL_ConvertPixels(int width, int height, /* Fast path for same format copy */ if (src_format == dst_format) { - int bpp; + int bpp, i; if (SDL_ISPIXELFORMAT_FOURCC(src_format)) { switch (src_format) { - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: case SDL_PIXELFORMAT_YVYU: bpp = 2; break; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + bpp = 1; + break; default: return SDL_SetError("Unknown FOURCC pixel format"); } @@ -1034,11 +1038,32 @@ int SDL_ConvertPixels(int width, int height, } width *= bpp; - while (height-- > 0) { + for (i = height; i--;) { SDL_memcpy(dst, src, width); src = (Uint8*)src + src_pitch; dst = (Uint8*)dst + dst_pitch; } + + if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) { + /* U and V planes are a quarter the size of the Y plane */ + width /= 2; + height /= 2; + src_pitch /= 2; + dst_pitch /= 2; + for (i = height * 2; i--;) { + SDL_memcpy(dst, src, width); + src = (Uint8*)src + src_pitch; + dst = (Uint8*)dst + dst_pitch; + } + } else if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) { + /* U/V plane is half the height of the Y plane */ + height /= 2; + for (i = height; i--;) { + SDL_memcpy(dst, src, width); + src = (Uint8*)src + src_pitch; + dst = (Uint8*)dst + dst_pitch; + } + } return 0; } diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c index 04e00deb2..7b88caaa9 100644 --- a/test/testautomation_pixels.c +++ b/test/testautomation_pixels.c @@ -79,14 +79,16 @@ char* _RGBPixelFormatsVerbose[] = }; /* Definition of all Non-RGB formats used to test pixel conversions */ -const int _numNonRGBPixelFormats = 5; +const int _numNonRGBPixelFormats = 7; Uint32 _nonRGBPixelFormats[] = { SDL_PIXELFORMAT_YV12, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_YUY2, SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU + SDL_PIXELFORMAT_YVYU, + SDL_PIXELFORMAT_NV12, + SDL_PIXELFORMAT_NV21 }; char* _nonRGBPixelFormatsVerbose[] = { @@ -94,7 +96,9 @@ char* _nonRGBPixelFormatsVerbose[] = "SDL_PIXELFORMAT_IYUV", "SDL_PIXELFORMAT_YUY2", "SDL_PIXELFORMAT_UYVY", - "SDL_PIXELFORMAT_YVYU" + "SDL_PIXELFORMAT_YVYU", + "SDL_PIXELFORMAT_NV12", + "SDL_PIXELFORMAT_NV21" }; /* Definition of some invalid formats for negative tests */ diff --git a/test/testoverlay2.c b/test/testoverlay2.c index 441e1f338..d9bd82737 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -206,6 +206,29 @@ ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h, } } +void +ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h, + int monochrome, int luminance) +{ + int x, y; + int yuv[3]; + Uint8 *op[2]; + + op[0] = out; + op[1] = op[0] + w*h; + for (y = 0; y < h; ++y) { + for (x = 0; x < w; ++x) { + RGBtoYUV(rgb, yuv, monochrome, luminance); + *(op[0]++) = yuv[0]; + if (x % 2 == 0 && y % 2 == 0) { + *(op[1]++) = yuv[1]; + *(op[1]++) = yuv[2]; + } + rgb += 3; + } + } +} + static void PrintUsage(char *argv0) { @@ -241,7 +264,11 @@ main(int argc, char **argv) int fps = 12; int fpsdelay; int nodelay = 0; +#ifdef TEST_NV12 + Uint32 pixel_format = SDL_PIXELFORMAT_NV12; +#else Uint32 pixel_format = SDL_PIXELFORMAT_YV12; +#endif int scale = 5; SDL_bool done = SDL_FALSE; @@ -371,7 +398,17 @@ main(int argc, char **argv) rgb[2] = MooseColors[frame[j]].b; rgb += 3; } - ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100); + switch (pixel_format) { + case SDL_PIXELFORMAT_YV12: + ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100); + break; + case SDL_PIXELFORMAT_NV12: + ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100); + break; + default: + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n"); + break; + } } free(RawMooseData); From 587dd65dec9ef90fb6c689589ba52a887e304d8d Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sun, 10 Aug 2014 22:21:21 -0400 Subject: [PATCH 02/50] WinRT build fix for ARM platforms The _xgetbv intrinsic was being used in ARM builds of SDL/WinRT, which was leading to linker errors. This commit limits _xgetbv use to the platforms on which it is available, x86 and x64. --- src/cpuinfo/SDL_cpuinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 3f2308bdb..c725c01a0 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -246,7 +246,7 @@ CPU_OSSavesYMM(void) a = 0; #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) asm(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx"); -#elif defined(_MSC_VER) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ +#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ a = (int)_xgetbv(0); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm From 270b8d0d52a9c0723d4ed65304aaacff0391e19a Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 11 Aug 2014 22:45:08 +0200 Subject: [PATCH 03/50] Removed 42 from README. --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index d538dca0d..de173bd28 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,7 +12,7 @@ Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog -and many Humble Bundle games. 42 +and many Humble Bundle games. SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code. From 1a726f39d286b8eb9780df957518e764f89101c8 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 11 Aug 2014 22:53:03 +0200 Subject: [PATCH 04/50] Updated README name in header. --- include/SDL_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 21ef3b956..f5136424e 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -59,7 +59,7 @@ typedef enum /* Application events */ SDL_QUIT = 0x100, /**< User-requested quit */ - /* These application events have special meaning on iOS, see README-ios.txt for details */ + /* These application events have special meaning on iOS, see README-ios.md for details */ SDL_APP_TERMINATING, /**< The application is being terminated by the OS Called on iOS in applicationWillTerminate() Called on Android in onDestroy() From 35ea23dbc4746a3823e9d207a2e5255b2ef0ef7e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 11 Aug 2014 23:13:20 +0200 Subject: [PATCH 05/50] Fixed doxygen warning and markdown formatting. --- docs/README-android.md | 53 ++++++++------- docs/README-ios.md | 146 ++++++++++++++++++++--------------------- 2 files changed, 101 insertions(+), 98 deletions(-) diff --git a/docs/README-android.md b/docs/README-android.md index c061f95a7..04fb05b6a 100644 --- a/docs/README-android.md +++ b/docs/README-android.md @@ -144,18 +144,19 @@ under src matching your package, e.g. src/com/gamemaker/game/MyGame.java Here's an example of a minimal class file: ---- MyGame.java -------------------------- -package com.gamemaker.game; -import org.libsdl.app.SDLActivity; - -/* - * A sample wrapper class that just calls SDLActivity - */ - -public class MyGame extends SDLActivity { } - ------------------------------------------- + --- MyGame.java -------------------------- + package com.gamemaker.game; + + import org.libsdl.app.SDLActivity; + + /* + * A sample wrapper class that just calls SDLActivity + */ + + public class MyGame extends SDLActivity { } + + ------------------------------------------ Then replace "SDLActivity" in AndroidManifest.xml with the name of your class, .e.g. "MyGame" @@ -320,15 +321,16 @@ If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code. For example, if your crash looks like this: -I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0 -I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4 -I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c -I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c -I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030 -I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so -I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so -I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so -I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so + + I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0 + I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4 + I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c + I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c + I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030 + I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so + I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so + I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so + I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code: @@ -364,11 +366,12 @@ export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x8 Once valgrind is built, you can create a wrapper script to launch your application with it, changing org.libsdl.app to your package identifier: ---- start_valgrind_app ------------------- -#!/system/bin/sh -export TMPDIR=/data/data/org.libsdl.app -exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $* ------------------------------------------- + + --- start_valgrind_app ------------------- + #!/system/bin/sh + export TMPDIR=/data/data/org.libsdl.app + exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $* + ------------------------------------------ Then push it to the device: adb push start_valgrind_app /data/local diff --git a/docs/README-ios.md b/docs/README-ios.md index 62ec395d5..7ffd7699e 100644 --- a/docs/README-ios.md +++ b/docs/README-ios.md @@ -68,56 +68,56 @@ not give you any processing time after the events are delivered. e.g. -int HandleAppEvents(void *userdata, SDL_Event *event) -{ - switch (event->type) + int HandleAppEvents(void *userdata, SDL_Event *event) { - case SDL_APP_TERMINATING: - /* Terminate the app. - Shut everything down before returning from this function. - */ - return 0; - case SDL_APP_LOWMEMORY: - /* You will get this when your app is paused and iOS wants more memory. - Release as much memory as possible. - */ - return 0; - case SDL_APP_WILLENTERBACKGROUND: - /* Prepare your app to go into the background. Stop loops, etc. - This gets called when the user hits the home button, or gets a call. - */ - return 0; - case SDL_APP_DIDENTERBACKGROUND: - /* This will get called if the user accepted whatever sent your app to the background. - If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. - When you get this, you have 5 seconds to save all your state or the app will be terminated. - Your app is NOT active at this point. - */ - return 0; - case SDL_APP_WILLENTERFOREGROUND: - /* This call happens when your app is coming back to the foreground. - Restore all your state here. - */ - return 0; - case SDL_APP_DIDENTERFOREGROUND: - /* Restart your loops here. - Your app is interactive and getting CPU again. - */ - return 0; - default: - /* No special processing, add it to the event queue */ - return 1; + switch (event->type) + { + case SDL_APP_TERMINATING: + /* Terminate the app. + Shut everything down before returning from this function. + */ + return 0; + case SDL_APP_LOWMEMORY: + /* You will get this when your app is paused and iOS wants more memory. + Release as much memory as possible. + */ + return 0; + case SDL_APP_WILLENTERBACKGROUND: + /* Prepare your app to go into the background. Stop loops, etc. + This gets called when the user hits the home button, or gets a call. + */ + return 0; + case SDL_APP_DIDENTERBACKGROUND: + /* This will get called if the user accepted whatever sent your app to the background. + If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops. + When you get this, you have 5 seconds to save all your state or the app will be terminated. + Your app is NOT active at this point. + */ + return 0; + case SDL_APP_WILLENTERFOREGROUND: + /* This call happens when your app is coming back to the foreground. + Restore all your state here. + */ + return 0; + case SDL_APP_DIDENTERFOREGROUND: + /* Restart your loops here. + Your app is interactive and getting CPU again. + */ + return 0; + default: + /* No special processing, add it to the event queue */ + return 1; + } + } + + int main(int argc, char *argv[]) + { + SDL_SetEventFilter(HandleAppEvents, NULL); + + ... run your main loop + + return 0; } -} - -int main(int argc, char *argv[]) -{ - SDL_SetEventFilter(HandleAppEvents, NULL); - - ... run your main loop - - return 0; -} ============================================================================== @@ -198,28 +198,28 @@ This will set up the given function to be called back on the animation callback, e.g. -extern "C" -void ShowFrame(void*) -{ - ... do event handling, frame logic and rendering -} - -int main(int argc, char *argv[]) -{ - ... initialize game ... - -#if __IPHONEOS__ - // Initialize the Game Center for scoring and matchmaking - InitGameCenter(); - - // Set up the game to run in the window animation callback on iOS - // so that Game Center and so forth works correctly. - SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); -#else - while ( running ) { - ShowFrame(0); - DelayFrame(); - } -#endif - return 0; -} + extern "C" + void ShowFrame(void*) + { + ... do event handling, frame logic and rendering + } + + int main(int argc, char *argv[]) + { + ... initialize game ... + + #if __IPHONEOS__ + // Initialize the Game Center for scoring and matchmaking + InitGameCenter(); + + // Set up the game to run in the window animation callback on iOS + // so that Game Center and so forth works correctly. + SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); + #else + while ( running ) { + ShowFrame(0); + DelayFrame(); + } + #endif + return 0; + } From 36341cbc344be66d15a3e1c250d7c877d4e5e29e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 11 Aug 2014 23:16:47 +0200 Subject: [PATCH 06/50] Added javadoc comment for consistency. --- android-project/src/org/libsdl/app/SDLActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 59d6a694d..47db8abff 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -543,6 +543,9 @@ public class SDLActivity extends Activity { /** com.android.vending.expansion.zipfile.ZipResourceFile's getInputStream() or null. */ private Method expansionFileMethod; + /** + * This method is called by SDL using JNI. + */ public InputStream openAPKExtensionInputStream(String fileName) throws IOException { // Get a ZipResourceFile representing a merger of both the main and patch files if (expansionFile == null) { From 33e7cc6d8deb46a5748e4efbc3d51be828462953 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Mon, 11 Aug 2014 23:18:35 +0200 Subject: [PATCH 07/50] Fixed typo in source comment. --- src/audio/xaudio2/SDL_xaudio2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 6fef7f219..85ac14602 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -58,7 +58,7 @@ /* The configure script already did any necessary checking */ # define SDL_XAUDIO2_HAS_SDK 1 #elif defined(__WINRT__) -/* WinRT always has access to the the XAudio 2 SDK */ +/* WinRT always has access to the XAudio 2 SDK */ # define SDL_XAUDIO2_HAS_SDK #else /* XAudio2 exists as of the March 2008 DirectX SDK From 05e40eb04a6a9b85b854a967c5bf4343239ed302 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 11 Aug 2014 17:24:54 -0700 Subject: [PATCH 08/50] Added an entry for the new Steam controller XInput emulation mode --- src/joystick/SDL_gamecontrollerdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index 89837176c..fe3a1671a 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -67,6 +67,7 @@ static const char *s_ControllerMappings [] = "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", From c1d6f153680b95b235ea493dd07847930c74b5e3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 11 Aug 2014 17:25:53 -0700 Subject: [PATCH 09/50] Implemented SDL_GetPrefPath() on Android - it returns the path used by SDL_AndroidGetInternalStoragePath() --- Android.mk | 2 +- include/SDL_config_android.h | 4 +- src/filesystem/android/SDL_sysfilesystem.c | 62 ++++++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/filesystem/android/SDL_sysfilesystem.c diff --git a/Android.mk b/Android.mk index 7541443c9..9d5b6e824 100755 --- a/Android.mk +++ b/Android.mk @@ -34,7 +34,7 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/*.c) \ $(wildcard $(LOCAL_PATH)/src/power/android/*.c) \ - $(wildcard $(LOCAL_PATH)/src/filesystem/dummy/*.c) \ + $(wildcard $(LOCAL_PATH)/src/filesystem/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*.c) \ $(wildcard $(LOCAL_PATH)/src/render/*/*.c) \ $(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \ diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 7310601fb..569ff1d5e 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -141,7 +141,7 @@ /* Enable system power support */ #define SDL_POWER_ANDROID 1 -/* !!! FIXME: what does Android do for filesystem stuff? */ -#define SDL_FILESYSTEM_DUMMY 1 +/* Enable the filesystem driver */ +#define SDL_FILESYSTEM_ANDROID 1 #endif /* _SDL_config_android_h */ diff --git a/src/filesystem/android/SDL_sysfilesystem.c b/src/filesystem/android/SDL_sysfilesystem.c new file mode 100644 index 000000000..b3937449a --- /dev/null +++ b/src/filesystem/android/SDL_sysfilesystem.c @@ -0,0 +1,62 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_FILESYSTEM_ANDROID + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include + +#include "SDL_error.h" +#include "SDL_filesystem.h" +#include "SDL_system.h" + + +char * +SDL_GetBasePath(void) +{ + /* The current working directory is / on Android */ + return NULL; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + const char *path = SDL_AndroidGetInternalStoragePath(); + if (path) { + size_t pathlen = SDL_strlen(path)+2; + char *fullpath = (char *)SDL_malloc(pathlen); + if (!fullpath) { + SDL_OutOfMemory(); + return NULL; + } + SDL_snprintf(fullpath, pathlen, "%s/", path); + return fullpath; + } + return NULL; +} + +#endif /* SDL_FILESYSTEM_ANDROID */ + +/* vi: set ts=4 sw=4 expandtab: */ From b75c6e2eb2a02d4570acdd0f6a836e1b5e385118 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Tue, 12 Aug 2014 23:28:45 +0200 Subject: [PATCH 10/50] Fixed doxygen warnings and markdown formatting. --- docs/README-android.md | 77 +++++++++++++++++++++++++---------------- docs/doxyfile | 2 +- include/SDL_egl.h | 4 +-- include/SDL_opengles2.h | 2 +- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/docs/README-android.md b/docs/README-android.md index 04fb05b6a..7eee4edae 100644 --- a/docs/README-android.md +++ b/docs/README-android.md @@ -81,33 +81,33 @@ sdk.dir=PATH_TO_ANDROID_SDK Here's an explanation of the files in the Android project, so you can customize them: -android-project/ - AndroidManifest.xml - package manifest. Among others, it contains the class name - of the main Activity and the package name of the application. - build.properties - empty - build.xml - build description file, used by ant. The actual application name - is specified here. - default.properties - holds the target ABI for the application, android-10 and up - project.properties - holds the target ABI for the application, android-10 and up - local.properties - holds the SDK path, you should change this to the path to your SDK - jni/ - directory holding native code - jni/Android.mk - Android makefile that can call recursively the Android.mk files - in all subdirectories - jni/SDL/ - (symlink to) directory holding the SDL library files - jni/SDL/Android.mk - Android makefile for creating the SDL shared library - jni/src/ - directory holding your C/C++ source - jni/src/Android.mk - Android makefile that you should customize to include your + android-project/ + AndroidManifest.xml - package manifest. Among others, it contains the class name + of the main Activity and the package name of the application. + build.properties - empty + build.xml - build description file, used by ant. The actual application name + is specified here. + default.properties - holds the target ABI for the application, android-10 and up + project.properties - holds the target ABI for the application, android-10 and up + local.properties - holds the SDK path, you should change this to the path to your SDK + jni/ - directory holding native code + jni/Android.mk - Android makefile that can call recursively the Android.mk files + in all subdirectories + jni/SDL/ - (symlink to) directory holding the SDL library files + jni/SDL/Android.mk - Android makefile for creating the SDL shared library + jni/src/ - directory holding your C/C++ source + jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references - res/ - directory holding resources for your application - res/drawable-* - directories holding icons for different phone hardware. Could be - one dir called "drawable". - res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout. - We don't need it because we use the SDL video output. - res/values/strings.xml - strings used in your application, including the application name - shown on the phone. - src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding - to SDL. Be very careful changing this, as the SDL library relies - on this implementation. + res/ - directory holding resources for your application + res/drawable-* - directories holding icons for different phone hardware. Could be + one dir called "drawable". + res/layout/main.xml - Usually contains a file main.xml, which declares the screen layout. + We don't need it because we use the SDL video output. + res/values/strings.xml - strings used in your application, including the application name + shown on the phone. + src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding + to SDL. Be very careful changing this, as the SDL library relies + on this implementation. ================================================================================ @@ -141,6 +141,7 @@ To customize your application name, edit AndroidManifest.xml and replace Then create a Java class extending SDLActivity and place it in a directory under src matching your package, e.g. + src/com/gamemaker/game/MyGame.java Here's an example of a minimal class file: @@ -291,30 +292,39 @@ You can create and run an emulator from the Eclipse IDE: * Window -> Android SDK and AVD Manager You can see if adb can see any devices with the following command: + adb devices You can see the output of log messages on the default device with: + adb logcat You can push files to the device with: + adb push local_file remote_path_and_file You can push files to the SD Card at /sdcard, for example: + adb push moose.dat /sdcard/moose.dat You can see the files on the SD card with a shell command: + adb shell ls /sdcard/ You can start a command shell on the default device with: + adb shell You can remove the library files of your project (and not the SDL lib files) with: + ndk-build clean You can do a build with the following command: + ndk-build You can see the complete command line that ndk-build is using by passing V=1 on the command line: + ndk-build V=1 If your application crashes in native code, you can use addr2line to convert the @@ -334,7 +344,9 @@ For example, if your crash looks like this: You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code: + arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so + and then paste in the number after "pc" in the call stack, from the line that I care about: 000014bc @@ -342,9 +354,9 @@ I get output from addr2line showing that it's in the quit function, in testsprit You can add logging to your code to help show what's happening: -#include - - __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x); + #include + + __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x); If you need to build without optimization turned on, you can create a file called "Application.mk" in the jni directory, with the following line in it: @@ -357,7 +369,9 @@ APP_OPTIM := debug The best (and slowest) way to debug memory issues on Android is valgrind. Valgrind has support for Android out of the box, just grab code using: + svn co svn://svn.valgrind.org/valgrind/trunk valgrind + ... and follow the instructions in the file README.android to build it. One thing I needed to do on Mac OS X was change the path to the toolchain, @@ -374,12 +388,15 @@ application with it, changing org.libsdl.app to your package identifier: ------------------------------------------ Then push it to the device: + adb push start_valgrind_app /data/local and make it executable: + adb shell chmod 755 /data/local/start_valgrind_app and tell Android to use the script to launch your application: + adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app" If the setprop command says "could not set property", it's likely that @@ -390,9 +407,11 @@ You can then launch your application normally and waaaaaaaiiittt for it. You can monitor the startup process with the logcat command above, and when it's done (or even while it's running) you can grab the valgrind output file: + adb pull /sdcard/valgrind.log When you're done instrumenting with valgrind, you can disable the wrapper: + adb shell setprop wrap.org.libsdl.app "" ================================================================================ diff --git a/docs/doxyfile b/docs/doxyfile index 151fa896a..67bec11f1 100644 --- a/docs/doxyfile +++ b/docs/doxyfile @@ -1510,7 +1510,7 @@ DOTFILE_DIRS = # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -DOT_GRAPH_MAX_NODES = 50 +DOT_GRAPH_MAX_NODES = 60 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable diff --git a/include/SDL_egl.h b/include/SDL_egl.h index 546a1a745..ed49a92fd 100644 --- a/include/SDL_egl.h +++ b/include/SDL_egl.h @@ -20,9 +20,9 @@ */ /** - * \file SDL_opengles.h + * \file SDL_egl.h * - * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + * This is a simple file to encapsulate the EGL API headers. */ #ifndef _MSC_VER diff --git a/include/SDL_opengles2.h b/include/SDL_opengles2.h index d7585d52e..d245b8eb4 100644 --- a/include/SDL_opengles2.h +++ b/include/SDL_opengles2.h @@ -20,7 +20,7 @@ */ /** - * \file SDL_opengles.h + * \file SDL_opengles2.h * * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. */ From 69487c41dddbe62310900f065d9a07ab40b3799e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Tue, 12 Aug 2014 23:33:16 +0200 Subject: [PATCH 11/50] Fixed warning about implicit boxing to Java Object. --- android-project/src/org/libsdl/app/SDLActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 47db8abff..d3b22647a 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -549,8 +549,8 @@ public class SDLActivity extends Activity { public InputStream openAPKExtensionInputStream(String fileName) throws IOException { // Get a ZipResourceFile representing a merger of both the main and patch files if (expansionFile == null) { - Integer mainVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION")); - Integer patchVersion = Integer.parseInt(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION")); + Integer mainVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION")); + Integer patchVersion = Integer.valueOf(nativeGetHint("SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION")); try { // To avoid direct dependency on Google APK extension library that is From d0d7ebee0fd745805bee4fd3d5eb70776ad1a7b9 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Tue, 12 Aug 2014 23:37:12 +0200 Subject: [PATCH 12/50] Fixed warnings about unused local variables. --- src/render/opengles2/SDL_render_gles2.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index a32c738a3..fd7f1b379 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -1650,7 +1650,6 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s const SDL_FRect *dstrect) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLfloat vertices[8]; GLfloat texCoords[8]; @@ -1689,7 +1688,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; - GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; GLfloat vertices[8]; GLfloat texCoords[8]; GLfloat translate[8]; From bafc5ef326c870ab52a7b150535aea5ed3f8276f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 14 Aug 2014 21:31:50 -0700 Subject: [PATCH 13/50] Take advantage of GL_ARB_texture_non_power_of_two when it's available --- src/render/opengl/SDL_render_gl.c | 20 +++++++++++++++----- src/render/opengl/SDL_shaders_gl.c | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index e3a6b55bc..c43739ec8 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -121,6 +121,7 @@ typedef struct GLDEBUGPROCARB next_error_callback; GLvoid *next_error_userparam; + SDL_bool GL_ARB_texture_non_power_of_two_supported; SDL_bool GL_ARB_texture_rectangle_supported; struct { GL_Shader shader; @@ -499,9 +500,13 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) data->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); } - if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") - || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { + if (SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two")) { + data->GL_ARB_texture_non_power_of_two_supported = SDL_TRUE; + } else if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || + SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { data->GL_ARB_texture_rectangle_supported = SDL_TRUE; + } + if (data->GL_ARB_texture_rectangle_supported) { data->glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB, &value); renderer->info.max_texture_width = value; renderer->info.max_texture_height = value; @@ -697,7 +702,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CheckError("", renderer); renderdata->glGenTextures(1, &data->texture); - if (GL_CheckError("glGenTexures()", renderer) < 0) { + if (GL_CheckError("glGenTextures()", renderer) < 0) { if (data->pixels) { SDL_free(data->pixels); } @@ -706,8 +711,13 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) } texture->driverdata = data; - if ((renderdata->GL_ARB_texture_rectangle_supported) - /* && texture->access != SDL_TEXTUREACCESS_TARGET */){ + if (renderdata->GL_ARB_texture_non_power_of_two_supported) { + data->type = GL_TEXTURE_2D; + texture_w = texture->w; + texture_h = texture->h; + data->texw = 1.0f; + data->texh = 1.0f; + } else if (renderdata->GL_ARB_texture_rectangle_supported) { data->type = GL_TEXTURE_RECTANGLE_ARB; texture_w = texture->w; texture_h = texture->h; diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 616f64aac..d8f60d4a0 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -376,8 +376,9 @@ GL_CreateShaderContext() return NULL; } - if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") - || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { + if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") && + (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || + SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) { ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE; } From 32dfd062cb39772b4bd36c93a6ef76275131ea56 Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Fri, 15 Aug 2014 23:13:51 +0200 Subject: [PATCH 14/50] Fixed enumeration in README. --- docs/README-ios.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README-ios.md b/docs/README-ios.md index 7ffd7699e..394fee67b 100644 --- a/docs/README-ios.md +++ b/docs/README-ios.md @@ -47,8 +47,8 @@ FIXME: This needs to be updated for the latest methods Here is the easiest method: 1. Build the SDL libraries (libSDL.a and libSDLSimulator.a) and the iPhone SDL Application template. -1. Install the iPhone SDL Application template by copying it to one of XCode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/XCode/Project Templates/" and placing it there. -2. Start a new project using the template. The project should be immediately ready for use with SDL. +2. Install the iPhone SDL Application template by copying it to one of XCode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iOS.platform/Developer/Library/XCode/Project Templates/" and placing it there. +3. Start a new project using the template. The project should be immediately ready for use with SDL. Here is a more manual method: 1. Create a new iPhone view based application. From bb534092c122266f2abe9c0a662c37453c16a1bc Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Fri, 15 Aug 2014 23:18:57 +0200 Subject: [PATCH 15/50] Updated README. --- docs/README-android.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/README-android.md b/docs/README-android.md index 7eee4edae..e232cb90b 100644 --- a/docs/README-android.md +++ b/docs/README-android.md @@ -128,7 +128,7 @@ Instructions: export NDK_MODULE_PATH="$PWD"/.. 5. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to - System.loadLibrary("SDL2") line 42. + System.loadLibrary("SDL2"). 6. Run 'ndk-build' (a script provided by the NDK). This compiles the C source @@ -151,7 +151,7 @@ Here's an example of a minimal class file: import org.libsdl.app.SDLActivity; - /* + /** * A sample wrapper class that just calls SDLActivity */ @@ -232,7 +232,7 @@ If you want to use threads in your SDL app, it's strongly recommended that you do so by creating them using SDL functions. This way, the required attach/detach handling is managed by SDL automagically. If you have threads created by other means and they make calls to SDL functions, make sure that you call -Android_JNI_SetupThread before doing anything else otherwise SDL will attach +Android_JNI_SetupThread() before doing anything else otherwise SDL will attach your thread automatically anyway (when you make an SDL call), but it'll never detach it. @@ -268,7 +268,7 @@ Once you've copied the SDL android project and customized it, you can create an * Select the Android -> Android Project wizard and click Next * Enter the name you'd like your project to have * Select "Create project from existing source" and browse for your project directory - * Make sure the Build Target is set to Android 2.0 + * Make sure the Build Target is set to Android 3.1 (API 12) * Click Finish From 178a30b438c8732dbdf5f7ed6992764fad88b46e Mon Sep 17 00:00:00 2001 From: Philipp Wiesemann Date: Fri, 15 Aug 2014 23:39:14 +0200 Subject: [PATCH 16/50] Fixed markdown formatting in READMEs. --- docs/README-android.md | 65 ++++++++++++++++++++------------------ docs/README-cmake.md | 23 +++++++------- docs/README-directfb.md | 6 ++-- docs/README-gesture.md | 24 +++++++------- docs/README-hg.md | 3 +- docs/README-ios.md | 45 ++++++++++++++------------ docs/README-macosx.md | 43 +++++++++++++------------ docs/README-nacl.md | 12 +++---- docs/README-platforms.md | 26 +++++++-------- docs/README-raspberrypi.md | 1 + docs/README-touch.md | 19 +++++------ 11 files changed, 140 insertions(+), 127 deletions(-) diff --git a/docs/README-android.md b/docs/README-android.md index e232cb90b..a4b38210f 100644 --- a/docs/README-android.md +++ b/docs/README-android.md @@ -18,9 +18,9 @@ Joystick support is available for API level >=12 devices. - Android applications are Java-based, optionally with parts written in C - As SDL apps are C-based, we use a small Java shim that uses JNI to talk to -the SDL library + the SDL library - This means that your application C code must be placed inside an Android -Java project, along with some C support code that communicates with Java + Java project, along with some C support code that communicates with Java - This eventually produces a standard Android .apk package The Android Java code implements an "Activity" and can be found in: @@ -42,15 +42,15 @@ For simple projects you can use the script located at build-scripts/androidbuild There's two ways of using it: -androidbuild.sh com.yourcompany.yourapp < sources.list -androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c + androidbuild.sh com.yourcompany.yourapp < sources.list + androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c sources.list should be a text file with a source file name in each line Filenames should be specified relative to the current directory, for example if you are in the build-scripts directory and want to create the testgles.c test, you'll run: - -./androidbuild.sh org.libsdl.testgles ../test/testgles.c + + ./androidbuild.sh org.libsdl.testgles ../test/testgles.c One limitation of this script is that all sources provided will be aggregated into a single directory, thus all your source files should have a unique name. @@ -74,7 +74,9 @@ For more complex projects, follow these instructions: If you want to use the Eclipse IDE, skip to the Eclipse section below. 5. Create /local.properties and use that to point to the Android SDK directory, by writing a line with the following form: -sdk.dir=PATH_TO_ANDROID_SDK + + sdk.dir=PATH_TO_ANDROID_SDK + 6. Run 'ant debug' in android/project. This compiles the .java and eventually creates a .apk with the native code embedded 7. 'ant debug install' will push the apk to the device or emulator (if connected) @@ -125,7 +127,7 @@ Instructions: 4. create and export an environment variable named NDK_MODULE_PATH that points to the parent directory of this SDL directory. e.g.: - export NDK_MODULE_PATH="$PWD"/.. + export NDK_MODULE_PATH="$PWD"/.. 5. Edit /src/org/libsdl/app/SDLActivity.java and remove the call to System.loadLibrary("SDL2"). @@ -142,7 +144,7 @@ To customize your application name, edit AndroidManifest.xml and replace Then create a Java class extending SDLActivity and place it in a directory under src matching your package, e.g. - src/com/gamemaker/game/MyGame.java + src/com/gamemaker/game/MyGame.java Here's an example of a minimal class file: @@ -184,9 +186,9 @@ standard functions in SDL_rwops.h. There are also a few Android specific functions that allow you to get other useful paths for saving and loading data: -SDL_AndroidGetInternalStoragePath() -SDL_AndroidGetExternalStorageState() -SDL_AndroidGetExternalStoragePath() +* SDL_AndroidGetInternalStoragePath() +* SDL_AndroidGetExternalStorageState() +* SDL_AndroidGetExternalStoragePath() See SDL_system.h for more details on these functions. @@ -228,6 +230,7 @@ under iOS, if the OS can not restore your GL context it will just kill your app) For a quick tour on how Linux native threads interoperate with the Java VM, take a look here: http://developer.android.com/guide/practices/jni.html + If you want to use threads in your SDL app, it's strongly recommended that you do so by creating them using SDL functions. This way, the required attach/detach handling is managed by SDL automagically. If you have threads created by other @@ -242,7 +245,8 @@ detach it. You can use STL in your project by creating an Application.mk file in the jni folder and adding the following line: -APP_STL := stlport_static + + APP_STL := stlport_static For more information check out CPLUSPLUS-SUPPORT.html in the NDK documentation. @@ -293,39 +297,39 @@ You can create and run an emulator from the Eclipse IDE: You can see if adb can see any devices with the following command: - adb devices + adb devices You can see the output of log messages on the default device with: - adb logcat + adb logcat You can push files to the device with: - adb push local_file remote_path_and_file + adb push local_file remote_path_and_file You can push files to the SD Card at /sdcard, for example: - adb push moose.dat /sdcard/moose.dat + adb push moose.dat /sdcard/moose.dat You can see the files on the SD card with a shell command: - adb shell ls /sdcard/ + adb shell ls /sdcard/ You can start a command shell on the default device with: - adb shell + adb shell You can remove the library files of your project (and not the SDL lib files) with: - ndk-build clean + ndk-build clean You can do a build with the following command: - ndk-build + ndk-build You can see the complete command line that ndk-build is using by passing V=1 on the command line: - ndk-build V=1 + ndk-build V=1 If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code. @@ -345,7 +349,7 @@ For example, if your crash looks like this: You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code: - arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so + arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so and then paste in the number after "pc" in the call stack, from the line that I care about: 000014bc @@ -360,7 +364,8 @@ You can add logging to your code to help show what's happening: If you need to build without optimization turned on, you can create a file called "Application.mk" in the jni directory, with the following line in it: -APP_OPTIM := debug + + APP_OPTIM := debug ================================================================================ @@ -370,7 +375,7 @@ APP_OPTIM := debug The best (and slowest) way to debug memory issues on Android is valgrind. Valgrind has support for Android out of the box, just grab code using: - svn co svn://svn.valgrind.org/valgrind/trunk valgrind + svn co svn://svn.valgrind.org/valgrind/trunk valgrind ... and follow the instructions in the file README.android to build it. @@ -389,15 +394,15 @@ application with it, changing org.libsdl.app to your package identifier: Then push it to the device: - adb push start_valgrind_app /data/local + adb push start_valgrind_app /data/local and make it executable: - adb shell chmod 755 /data/local/start_valgrind_app + adb shell chmod 755 /data/local/start_valgrind_app and tell Android to use the script to launch your application: - adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app" + adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app" If the setprop command says "could not set property", it's likely that your package name is too long and you should make it shorter by changing @@ -408,11 +413,11 @@ You can monitor the startup process with the logcat command above, and when it's done (or even while it's running) you can grab the valgrind output file: - adb pull /sdcard/valgrind.log + adb pull /sdcard/valgrind.log When you're done instrumenting with valgrind, you can disable the wrapper: - adb shell setprop wrap.org.libsdl.app "" + adb shell setprop wrap.org.libsdl.app "" ================================================================================ Why is API level 10 the minimum required? diff --git a/docs/README-cmake.md b/docs/README-cmake.md index b5daad908..5b440c546 100644 --- a/docs/README-cmake.md +++ b/docs/README-cmake.md @@ -10,22 +10,23 @@ It works in parallel to the legacy system, so users can experiment with it without complication. While still experimental, the build system should be usable on the following platforms: - - * FreeBSD - * Linux - * VS.NET 2010 - * MinGW and Msys - * OS X with support for XCode - + +* FreeBSD +* Linux +* VS.NET 2010 +* MinGW and Msys +* OS X with support for XCode + + ================================================================================ Usage ================================================================================ Assuming the source for SDL is located at ~/sdl -cd ~ -mkdir build -cd build -cmake ../sdl + cd ~ + mkdir build + cd build + cmake ../sdl This will build the static and dynamic versions of SDL in the ~/build directory. diff --git a/docs/README-directfb.md b/docs/README-directfb.md index a7b542fa3..7df8bb864 100644 --- a/docs/README-directfb.md +++ b/docs/README-directfb.md @@ -11,9 +11,9 @@ Supports: What you need: -DirectFB 1.0.1, 1.2.x, 1.3.0 -Kernel-Framebuffer support: required: vesafb, radeonfb .... -Mesa 7.0.x - optional for OpenGL +* DirectFB 1.0.1, 1.2.x, 1.3.0 +* Kernel-Framebuffer support: required: vesafb, radeonfb .... +* Mesa 7.0.x - optional for OpenGL /etc/directfbrc diff --git a/docs/README-gesture.md b/docs/README-gesture.md index fc8a093c7..7b90b54d9 100644 --- a/docs/README-gesture.md +++ b/docs/README-gesture.md @@ -14,18 +14,18 @@ SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch dev Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event. A SDL_DOLLARRECORD event is a dgesture with the following fields: -event.dgesture.touchId - the Id of the touch used to record the gesture. -event.dgesture.gestureId - the unique id of the recorded gesture. +* event.dgesture.touchId - the Id of the touch used to record the gesture. +* event.dgesture.gestureId - the unique id of the recorded gesture. Performing: ----------- As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields: -event.dgesture.touchId - the Id of the touch which performed the gesture. -event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke. -event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match. -event.dgesture.numFingers - the number of fingers used to draw the stroke. +* event.dgesture.touchId - the Id of the touch which performed the gesture. +* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke. +* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match. +* event.dgesture.numFingers - the number of fingers used to draw the stroke. Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed). @@ -54,12 +54,12 @@ Multi Gestures SDL provides simple support for pinch/rotate/swipe gestures. Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields: -event.mgesture.touchId - the Id of the touch on which the gesture was performed. -event.mgesture.x - the normalized x coordinate of the gesture. (0..1) -event.mgesture.y - the normalized y coordinate of the gesture. (0..1) -event.mgesture.dTheta - the amount that the fingers rotated during this motion. -event.mgesture.dDist - the amount that the fingers pinched during this motion. -event.mgesture.numFingers - the number of fingers used in the gesture. +* event.mgesture.touchId - the Id of the touch on which the gesture was performed. +* event.mgesture.x - the normalized x coordinate of the gesture. (0..1) +* event.mgesture.y - the normalized y coordinate of the gesture. (0..1) +* event.mgesture.dTheta - the amount that the fingers rotated during this motion. +* event.mgesture.dDist - the amount that the fingers pinched during this motion. +* event.mgesture.numFingers - the number of fingers used in the gesture. =========================================================================== diff --git a/docs/README-hg.md b/docs/README-hg.md index 27396327c..6e18bab0a 100644 --- a/docs/README-hg.md +++ b/docs/README-hg.md @@ -9,7 +9,7 @@ at the Mercurial website ( http://mercurial.selenic.com/ ) for more information on using hg, where you can also download software for Mac OS X, Windows, and Unix systems. - hg clone http://hg.libsdl.org/SDL + hg clone http://hg.libsdl.org/SDL If you are building SDL with an IDE, you will need to copy the file include/SDL_config.h.default to include/SDL_config.h before building. @@ -18,7 +18,6 @@ If you are building SDL via configure, you will need to run autogen.sh before running configure. There is a web interface to the subversion repository at: - http://hg.libsdl.org/SDL/ There is an RSS feed available at that URL, for those that want to diff --git a/docs/README-ios.md b/docs/README-ios.md index 394fee67b..af33e03b9 100644 --- a/docs/README-ios.md +++ b/docs/README-ios.md @@ -14,11 +14,12 @@ Instructions: There are three build targets: - libSDL.a: Build SDL as a statically linked library -- testsdl +- testsdl: Build a test program (there are known test failures which are fine) - Template: Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen. + ============================================================================== Build SDL for iOS from the command line ============================================================================== @@ -57,6 +58,7 @@ Here is a more manual method: 4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically. 5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code. + ============================================================================== Notes -- Application events ============================================================================== @@ -148,11 +150,14 @@ The SDL keyboard API has been extended to support on-screen keyboards: void SDL_StartTextInput() -- enables text events and reveals the onscreen keyboard. + void SDL_StopTextInput() -- disables text events and hides the onscreen keyboard. + SDL_bool SDL_IsTextInputActive() -- returns whether or not text events are enabled (and the onscreen keyboard is visible) + ============================================================================== Notes -- Reading and Writing files ============================================================================== @@ -161,12 +166,12 @@ Each application installed on iPhone resides in a sandbox which includes its own Once your application is installed its directory tree looks like: -MySDLApp Home/ - MySDLApp.app - Documents/ - Library/ - Preferences/ - tmp/ + MySDLApp Home/ + MySDLApp.app + Documents/ + Library/ + Preferences/ + tmp/ When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences". @@ -191,8 +196,8 @@ Game Center ============================================================================== Game Center integration requires that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using: - -int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); + + int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run. @@ -201,7 +206,7 @@ e.g. extern "C" void ShowFrame(void*) { - ... do event handling, frame logic and rendering + ... do event handling, frame logic and rendering ... } int main(int argc, char *argv[]) @@ -209,17 +214,17 @@ e.g. ... initialize game ... #if __IPHONEOS__ - // Initialize the Game Center for scoring and matchmaking - InitGameCenter(); + // Initialize the Game Center for scoring and matchmaking + InitGameCenter(); - // Set up the game to run in the window animation callback on iOS - // so that Game Center and so forth works correctly. - SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); + // Set up the game to run in the window animation callback on iOS + // so that Game Center and so forth works correctly. + SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL); #else - while ( running ) { - ShowFrame(0); - DelayFrame(); - } + while ( running ) { + ShowFrame(0); + DelayFrame(); + } #endif - return 0; + return 0; } diff --git a/docs/README-macosx.md b/docs/README-macosx.md index ca6b7ee12..768a33e33 100644 --- a/docs/README-macosx.md +++ b/docs/README-macosx.md @@ -45,28 +45,29 @@ Some things you have to be aware of when using SDL on Mac OS X: file with the app. To solve these issues, put the following code in your NSApplicationDelegate implementation: - - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender - { - if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); - } - return NSTerminateCancel; - } - - - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename - { - if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { - SDL_Event event; - event.type = SDL_DROPFILE; - event.drop.file = SDL_strdup([filename UTF8String]); - return (SDL_PushEvent(&event) > 0); - } - - return NO; - } + - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender + { + if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); + } + + return NSTerminateCancel; + } + + - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename + { + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup([filename UTF8String]); + return (SDL_PushEvent(&event) > 0); + } + + return NO; + } ============================================================================== Using the Simple DirectMedia Layer with a traditional Makefile diff --git a/docs/README-nacl.md b/docs/README-nacl.md index b664f05ee..4c9432b69 100644 --- a/docs/README-nacl.md +++ b/docs/README-nacl.md @@ -2,9 +2,9 @@ Native Client ================================================================================ Requirements: - - * Native Client SDK (https://developer.chrome.com/native-client), - (tested with Pepper version 33 or higher). + +* Native Client SDK (https://developer.chrome.com/native-client), + (tested with Pepper version 33 or higher). The SDL backend for Chrome's Native Client has been tested only with the PNaCl toolchain, which generates binaries designed to run on ARM and x86_32/64 @@ -91,9 +91,9 @@ To be able to save into the directory "/save/" (like backup of game) : And add to manifest.json : - "permissions": [ - "unlimitedStorage" - ] + "permissions": [ + "unlimitedStorage" + ] ================================================================================ TODO - Known Issues diff --git a/docs/README-platforms.md b/docs/README-platforms.md index 3f1950a91..4bf77b206 100644 --- a/docs/README-platforms.md +++ b/docs/README-platforms.md @@ -8,27 +8,27 @@ Officially supported platforms ============================== (code compiles, and thoroughly tested for release) ============================== -Windows XP/Vista/7/8 -Mac OS X 10.5+ -Linux 2.6+ -iOS 5.1.1+ -Android 2.3.3+ +* Windows XP/Vista/7/8 +* Mac OS X 10.5+ +* Linux 2.6+ +* iOS 5.1.1+ +* Android 2.3.3+ Unofficially supported platforms ================================ (code compiles, but not thoroughly tested) ================================ -FreeBSD -NetBSD -OpenBSD -Solaris +* FreeBSD +* NetBSD +* OpenBSD +* Solaris Platforms supported by volunteers ================================= -Haiku - maintained by Axel Dörfler -PSP - maintained by 527721088@qq.com -Pandora - maintained by Scott Smith -NaCl - maintained by Gabriel Jacobo +* Haiku - maintained by Axel Dörfler +* PSP - maintained by 527721088@qq.com +* Pandora - maintained by Scott Smith +* NaCl - maintained by Gabriel Jacobo Platforms that need maintainers =============================== diff --git a/docs/README-raspberrypi.md b/docs/README-raspberrypi.md index de920cce1..c14dbf1ad 100644 --- a/docs/README-raspberrypi.md +++ b/docs/README-raspberrypi.md @@ -15,6 +15,7 @@ Raspbian (other Linux distros may work as well). * Input (mouse/keyboard/joystick) via EVDEV * Hotplugging of input devices via UDEV + ================================================================================ Raspbian Build Dependencies ================================================================================ diff --git a/docs/README-touch.md b/docs/README-touch.md index 5850b4f8f..e76e2d396 100644 --- a/docs/README-touch.md +++ b/docs/README-touch.md @@ -20,18 +20,18 @@ Events SDL_FINGERDOWN: Sent when a finger (or stylus) is placed on a touch device. Fields: -event.tfinger.touchId - the Id of the touch device. -event.tfinger.fingerId - the Id of the finger which just went down. -event.tfinger.x - the x coordinate of the touch (0..1) -event.tfinger.y - the y coordinate of the touch (0..1) -event.tfinger.pressure - the pressure of the touch (0..1) +* event.tfinger.touchId - the Id of the touch device. +* event.tfinger.fingerId - the Id of the finger which just went down. +* event.tfinger.x - the x coordinate of the touch (0..1) +* event.tfinger.y - the y coordinate of the touch (0..1) +* event.tfinger.pressure - the pressure of the touch (0..1) SDL_FINGERMOTION: Sent when a finger (or stylus) is moved on the touch device. Fields: Same as SDL_FINGERDOWN but with additional: -event.tfinger.dx - change in x coordinate during this motion event. -event.tfinger.dy - change in y coordinate during this motion event. +* event.tfinger.dx - change in x coordinate during this motion event. +* event.tfinger.dy - change in y coordinate during this motion event. SDL_FINGERUP: Sent when a finger (or stylus) is lifted from the touch device. @@ -70,11 +70,12 @@ A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it As a result, be very careful to check for NULL return values. A SDL_Finger has the following fields: ->x,y,pressure: +* x,y,pressure: The current coordinates of the touch. ->pressure: +* pressure: The pressure of the touch. + =========================================================================== Notes =========================================================================== From a5d019efa3dd92f0ceff13f09e16ec7aa9fe5b97 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:40:01 -0400 Subject: [PATCH 17/50] Haptic: Don't interpret a direction of polar 35999 as "unsupported type". (or linux-direction 0xFFFF) Thanks, Elias! Partially fixes Bugzilla #2686. --HG-- extra : histedit_source : 767fa48d79fe8dfe8dda1f155ff1e19a470d7efc --- src/haptic/linux/SDL_syshaptic.c | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 7598a5633..fc8ab5fc9 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -652,15 +652,15 @@ SDL_SYS_ToButton(Uint16 button) /* - * Returns the ff_effect usable direction from a SDL_HapticDirection. + * Initializes the ff_effect usable direction from a SDL_HapticDirection. */ -static Uint16 -SDL_SYS_ToDirection(SDL_HapticDirection * dir) +static int +SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) { Uint32 tmp; float f; /* Ideally we'd use fixed point math instead of floats... */ - switch (dir->type) { + switch (src->type) { case SDL_HAPTIC_POLAR: /* Linux directions start from south. (and range from 0 to 0xFFFF) @@ -671,10 +671,11 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir) 180 deg -> 0x8000 (up) 270 deg -> 0xC000 (right) */ - tmp = (((18000 + dir->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ - return (Uint16) tmp; + tmp = (((18000 + src->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ + *dest = (Uint16) tmp; + break; - case SDL_HAPTIC_SPHERICAL: + case SDL_HAPTIC_SPHERICAL: /* We convert to polar, because that's the only supported direction on Linux. The first value of a spherical direction is practically the same as a @@ -683,12 +684,13 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir) --> add 9000 --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ - tmp = ((dir->dir[0]) + 9000) % 36000; /* Convert to polars */ + tmp = ((src->dir[0]) + 9000) % 36000; /* Convert to polars */ tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ - return (Uint16) tmp; + *dest = (Uint16) tmp; + break; case SDL_HAPTIC_CARTESIAN: - f = atan2(dir->dir[1], dir->dir[0]); + f = atan2(src->dir[1], src->dir[0]); /* atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - Y-axis-value is the second coordinate (from center to SOUTH) @@ -701,10 +703,11 @@ SDL_SYS_ToDirection(SDL_HapticDirection * dir) */ tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000; tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ - return (Uint16) tmp; + *dest = (Uint16) tmp; + break; default: - return (Uint16) SDL_SetError("Haptic: Unsupported direction type."); + return SDL_SetError("Haptic: Unsupported direction type."); } return 0; @@ -735,8 +738,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) /* Header */ dest->type = FF_CONSTANT; - dest->direction = SDL_SYS_ToDirection(&constant->direction); - if (dest->direction == (Uint16) - 1) + if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1) return -1; /* Replay */ @@ -771,8 +773,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) /* Header */ dest->type = FF_PERIODIC; - dest->direction = SDL_SYS_ToDirection(&periodic->direction); - if (dest->direction == (Uint16) - 1) + if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1) return -1; /* Replay */ @@ -868,8 +869,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) /* Header */ dest->type = FF_RAMP; - dest->direction = SDL_SYS_ToDirection(&ramp->direction); - if (dest->direction == (Uint16) - 1) + if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1) return -1; /* Replay */ From b9be1131961da8fa34971ef092e79cf3c226fbba Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:41:25 -0400 Subject: [PATCH 18/50] Haptic: DInput's POLAR direction actually matches Linux's direction. Thanks, Elias! Partially fixes Bugzilla #2686. --HG-- extra : histedit_source : 214ecbc7baaf28e6c7ff1eee687ee66f356446eb --- include/SDL_haptic.h | 6 +++--- src/haptic/linux/SDL_syshaptic.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index bc33a7921..dceaeb863 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -370,7 +370,7 @@ typedef struct _SDL_Haptic SDL_Haptic; ^ | | - (1,0) West <----[ HAPTIC ]----> East (-1,0) + (-1,0) West <----[ HAPTIC ]----> East (1,0) | | v @@ -395,9 +395,9 @@ typedef struct _SDL_Haptic SDL_Haptic; * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses * the first three \c dir parameters. The cardinal directions would be: * - North: 0,-1, 0 - * - East: -1, 0, 0 + * - East: 1, 0, 0 * - South: 0, 1, 0 - * - West: 1, 0, 0 + * - West: -1, 0, 0 * * The Z axis represents the height of the effect if supported, otherwise * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index fc8ab5fc9..c70a4708d 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -671,7 +671,7 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) 180 deg -> 0x8000 (up) 270 deg -> 0xC000 (right) */ - tmp = (((18000 + src->dir[0]) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ + tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; break; @@ -682,10 +682,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) Polar direction, except that we have to add 90 degrees. It is the angle from EAST {1,0} towards SOUTH {0,1}. --> add 9000 - --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. + --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ tmp = ((src->dir[0]) + 9000) % 36000; /* Convert to polars */ - tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ + tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; break; @@ -699,10 +699,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) have the first spherical value. Therefore we proceed as in case SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. --> add 45000 in total - --> finally add 18000 and convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. + --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ - tmp = (((int) (f * 18000. / M_PI)) + 45000) % 36000; - tmp = (((18000 + tmp) % 36000) * 0xFFFF) / 36000; /* convert to range [0,0xFFFF] */ + tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000; + tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; break; From f703b1b22cbe1ce9fbb9b994aef53ba2e40f7233 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:42:55 -0400 Subject: [PATCH 19/50] Haptic: Explicitly avoid floating point arithmetic if it's not needed. Thanks, Elias! Partially fixes Bugzilla #2686. --- src/haptic/linux/SDL_syshaptic.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index c70a4708d..5320fb599 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -658,7 +658,6 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) { Uint32 tmp; - float f; /* Ideally we'd use fixed point math instead of floats... */ switch (src->type) { case SDL_HAPTIC_POLAR: @@ -690,7 +689,12 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) break; case SDL_HAPTIC_CARTESIAN: - f = atan2(src->dir[1], src->dir[0]); + if (!src->dir[1]) + *dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000); + else if (!src->dir[0]) + *dest = (src->dir[1] >= 0 ? 0x8000 : 0); + else { + float f = atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ /* atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - Y-axis-value is the second coordinate (from center to SOUTH) @@ -702,8 +706,9 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000; - tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ - *dest = (Uint16) tmp; + tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ + *dest = (Uint16) tmp; + } break; default: From 640631c6dc1bdc5275ebbb16f06c2af42abf98ac Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:47:42 -0400 Subject: [PATCH 20/50] Haptic: Fix the saturation and deadband parameters' available range. There was a misconception that Linux's saturation and deadband parameters - on which the corresponding SDL parameters were based - use only half of the possible range. Thanks, Elias! Partially fixes Bugzilla #2686. --- include/SDL_haptic.h | 6 +++--- src/haptic/darwin/SDL_syshaptic.c | 6 +++--- src/haptic/linux/SDL_syshaptic.c | 14 ++++++-------- src/haptic/windows/SDL_dinputhaptic.c | 6 +++--- test/testhaptic.c | 9 +++++---- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/SDL_haptic.h b/include/SDL_haptic.h index dceaeb863..827aa24cd 100644 --- a/include/SDL_haptic.h +++ b/include/SDL_haptic.h @@ -604,11 +604,11 @@ typedef struct SDL_HapticCondition Uint16 interval; /**< How soon it can be triggered again after button. */ /* Condition */ - Uint16 right_sat[3]; /**< Level when joystick is to the positive side. */ - Uint16 left_sat[3]; /**< Level when joystick is to the negative side. */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ - Uint16 deadband[3]; /**< Size of the dead zone. */ + Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ Sint16 center[3]; /**< Position of the dead zone. */ } SDL_HapticCondition; diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 408b81a88..dc9416ba4 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -924,10 +924,10 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); condition[i].dwPositiveSaturation = - CCONVERT(hap_condition->right_sat[i]); + CCONVERT(hap_condition->right_sat[i] / 2); condition[i].dwNegativeSaturation = - CCONVERT(hap_condition->left_sat[i]); - condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i]); + CCONVERT(hap_condition->left_sat[i] / 2); + condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2); } dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index 5320fb599..459d0ab24 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -847,20 +847,18 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) /* Condition */ /* X axis */ - dest->u.condition[0].right_saturation = - CLAMP(condition->right_sat[0]); - dest->u.condition[0].left_saturation = CLAMP(condition->left_sat[0]); + dest->u.condition[0].right_saturation = condition->right_sat[0]; + dest->u.condition[0].left_saturation = condition->left_sat[0]; dest->u.condition[0].right_coeff = condition->right_coeff[0]; dest->u.condition[0].left_coeff = condition->left_coeff[0]; - dest->u.condition[0].deadband = CLAMP(condition->deadband[0]); + dest->u.condition[0].deadband = condition->deadband[0]; dest->u.condition[0].center = condition->center[0]; /* Y axis */ - dest->u.condition[1].right_saturation = - CLAMP(condition->right_sat[1]); - dest->u.condition[1].left_saturation = CLAMP(condition->left_sat[1]); + dest->u.condition[1].right_saturation = condition->right_sat[1]; + dest->u.condition[1].left_saturation = condition->left_sat[1]; dest->u.condition[1].right_coeff = condition->right_coeff[1]; dest->u.condition[1].left_coeff = condition->left_coeff[1]; - dest->u.condition[1].deadband = CLAMP(condition->deadband[1]); + dest->u.condition[1].deadband = condition->deadband[1]; dest->u.condition[1].center = condition->center[1]; /* diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 489ca5ea6..0d6b2089d 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -763,10 +763,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); condition[i].dwPositiveSaturation = - CONVERT(hap_condition->right_sat[i]); + CONVERT(hap_condition->right_sat[i] / 2); condition[i].dwNegativeSaturation = - CONVERT(hap_condition->left_sat[i]); - condition[i].lDeadBand = CONVERT(hap_condition->deadband[i]); + CONVERT(hap_condition->left_sat[i] / 2); + condition[i].lDeadBand = CONVERT(hap_condition->deadband[i] / 2); } dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; diff --git a/test/testhaptic.c b/test/testhaptic.c index f62414193..92fcec50f 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -172,8 +172,8 @@ main(int argc, char **argv) efx[nefx].type = SDL_HAPTIC_SPRING; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0x7FFF; - efx[nefx].condition.left_sat[i] = 0x7FFF; + efx[nefx].condition.right_sat[i] = 0xFFFF; + efx[nefx].condition.left_sat[i] = 0xFFFF; efx[nefx].condition.right_coeff[i] = 0x2000; efx[nefx].condition.left_coeff[i] = 0x2000; efx[nefx].condition.center[i] = 0x1000; /* Displace the center for it to move. */ @@ -191,10 +191,11 @@ main(int argc, char **argv) efx[nefx].type = SDL_HAPTIC_INERTIA; efx[nefx].condition.length = 5000; for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { - efx[nefx].condition.right_sat[i] = 0x7FFF; - efx[nefx].condition.left_sat[i] = 0x7FFF; + efx[nefx].condition.right_sat[i] = 0xFFFF; + efx[nefx].condition.left_sat[i] = 0xFFFF; efx[nefx].condition.right_coeff[i] = 0x2000; efx[nefx].condition.left_coeff[i] = 0x2000; + efx[nefx].condition.deadband[i] = 0x1000; /* 1/16th of axis-range around the center is 'dead'. */ } id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); if (id[nefx] < 0) { From ea687875b095a85562e1e1d62a0ecb626d0400fc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:49:00 -0400 Subject: [PATCH 21/50] Haptic: Fix clamping bugs on Windows, by using the Darwin haptics code. Thanks, Elias! Partially fixes Bugzilla #2686. --- src/haptic/windows/SDL_dinputhaptic.c | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 0d6b2089d..35edcb3e9 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -602,7 +602,10 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes) } } -#define CONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) +/* Clamps and converts. */ +#define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) +/* Just converts. */ +#define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the DIEFFECT from a SDL_HapticEffect. */ @@ -689,9 +692,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { - envelope->dwAttackLevel = CONVERT(hap_constant->attack_level); + envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level); envelope->dwAttackTime = hap_constant->attack_length * 1000; - envelope->dwFadeLevel = CONVERT(hap_constant->fade_level); + envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level); envelope->dwFadeTime = hap_constant->fade_length * 1000; } @@ -736,9 +739,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { - envelope->dwAttackLevel = CONVERT(hap_periodic->attack_level); + envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level); envelope->dwAttackTime = hap_periodic->attack_length * 1000; - envelope->dwFadeLevel = CONVERT(hap_periodic->fade_level); + envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level); envelope->dwFadeTime = hap_periodic->fade_length * 1000; } @@ -763,10 +766,10 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); condition[i].dwPositiveSaturation = - CONVERT(hap_condition->right_sat[i] / 2); + CCONVERT(hap_condition->right_sat[i] / 2); condition[i].dwNegativeSaturation = - CONVERT(hap_condition->left_sat[i] / 2); - condition[i].lDeadBand = CONVERT(hap_condition->deadband[i] / 2); + CCONVERT(hap_condition->left_sat[i] / 2); + condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2); } dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; @@ -819,9 +822,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { - envelope->dwAttackLevel = CONVERT(hap_ramp->attack_level); + envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level); envelope->dwAttackTime = hap_ramp->attack_length * 1000; - envelope->dwFadeLevel = CONVERT(hap_ramp->fade_level); + envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level); envelope->dwFadeTime = hap_ramp->fade_length * 1000; } @@ -842,7 +845,7 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, custom->rglForceData = SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels); for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ - custom->rglForceData[i] = CONVERT(hap_custom->data[i]); + custom->rglForceData[i] = CCONVERT(hap_custom->data[i]); } dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE); dest->lpvTypeSpecificParams = custom; @@ -864,9 +867,9 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { - envelope->dwAttackLevel = CONVERT(hap_custom->attack_level); + envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level); envelope->dwAttackTime = hap_custom->attack_length * 1000; - envelope->dwFadeLevel = CONVERT(hap_custom->fade_level); + envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level); envelope->dwFadeTime = hap_custom->fade_length * 1000; } From 6ee688f85c407c5adad2984b9830f4f0e9417a6f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 16 Aug 2014 16:50:10 -0400 Subject: [PATCH 22/50] Haptic: Add some missing haptic types to test, and fix wrong array-sizes. Thanks, Elias! Fixes Bugzilla #2686. (along with the last several commits.) --- test/testhaptic.c | 62 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/test/testhaptic.c b/test/testhaptic.c index 92fcec50f..2efd21481 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -45,8 +45,8 @@ main(int argc, char **argv) int i; char *name; int index; - SDL_HapticEffect efx[5]; - int id[5]; + SDL_HapticEffect efx[9]; + int id[9]; int nefx; unsigned int supported; @@ -149,6 +149,7 @@ main(int argc, char **argv) } nefx++; } + /* Now the classical constant effect. */ if (supported & SDL_HAPTIC_CONSTANT) { SDL_Log(" effect %d: Constant Force\n", nefx); @@ -166,6 +167,7 @@ main(int argc, char **argv) } nefx++; } + /* The cute spring effect. */ if (supported & SDL_HAPTIC_SPRING) { SDL_Log(" effect %d: Condition Spring\n", nefx); @@ -185,6 +187,24 @@ main(int argc, char **argv) } nefx++; } + /* The interesting damper effect. */ + if (supported & SDL_HAPTIC_DAMPER) { + SDL_Log(" effect %d: Condition Damper\n", nefx); + efx[nefx].type = SDL_HAPTIC_DAMPER; + efx[nefx].condition.length = 5000; + for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { + efx[nefx].condition.right_sat[i] = 0xFFFF; + efx[nefx].condition.left_sat[i] = 0xFFFF; + efx[nefx].condition.right_coeff[i] = 0x2000; + efx[nefx].condition.left_coeff[i] = 0x2000; + } + id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); + if (id[nefx] < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + abort_execution(); + } + nefx++; + } /* The pretty awesome inertia effect. */ if (supported & SDL_HAPTIC_INERTIA) { SDL_Log(" effect %d: Condition Inertia\n", nefx); @@ -204,6 +224,44 @@ main(int argc, char **argv) } nefx++; } + /* The hot friction effect. */ + if (supported & SDL_HAPTIC_FRICTION) { + SDL_Log(" effect %d: Condition Friction\n", nefx); + efx[nefx].type = SDL_HAPTIC_FRICTION; + efx[nefx].condition.length = 5000; + for (i = 0; i < SDL_HapticNumAxes(haptic); i++) { + efx[nefx].condition.right_sat[i] = 0xFFFF; + efx[nefx].condition.left_sat[i] = 0xFFFF; + efx[nefx].condition.right_coeff[i] = 0x2000; + efx[nefx].condition.left_coeff[i] = 0x2000; + } + id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); + if (id[nefx] < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + abort_execution(); + } + nefx++; + } + + /* Now we'll try a ramp effect */ + if (supported & SDL_HAPTIC_RAMP) { + SDL_Log(" effect %d: Ramp\n", nefx); + efx[nefx].type = SDL_HAPTIC_RAMP; + efx[nefx].ramp.direction.type = SDL_HAPTIC_CARTESIAN; + efx[nefx].ramp.direction.dir[0] = 1; /* Force comes from */ + efx[nefx].ramp.direction.dir[1] = -1; /* the north-east. */ + efx[nefx].ramp.length = 5000; + efx[nefx].ramp.start = 0x4000; + efx[nefx].ramp.end = -0x4000; + efx[nefx].ramp.attack_length = 1000; + efx[nefx].ramp.fade_length = 1000; + id[nefx] = SDL_HapticNewEffect(haptic, &efx[nefx]); + if (id[nefx] < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "UPLOADING EFFECT ERROR: %s\n", SDL_GetError()); + abort_execution(); + } + nefx++; + } /* Finally we'll try a left/right effect. */ if (supported & SDL_HAPTIC_LEFTRIGHT) { From 2afb7573b6e570da28390fe0f6b68ae96ed190aa Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 15:18:21 -0700 Subject: [PATCH 23/50] Fixed building on Windows with CMake --- CMakeLists.txt | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e690ba523..792f26c6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -805,6 +805,7 @@ elseif(WINDOWS) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) check_include_file(xaudio2.h HAVE_XAUDIO2_H) + check_include_file(xinput.h HAVE_XINPUT_H) check_include_file(dxgi.h HAVE_DXGI_H) if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H) set(HAVE_DIRECTX TRUE) @@ -910,21 +911,31 @@ elseif(WINDOWS) endif() if(SDL_JOYSTICK) + file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) if(HAVE_DINPUT_H) set(SDL_JOYSTICK_DINPUT 1) - set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_dxjoystick.c) list(APPEND EXTRA_LIBS dinput8 dxguid dxerr) - else() + endif() + if(HAVE_XINPUT_H) + set(SDL_JOYSTICK_XINPUT 1) + endif() + if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H) set(SDL_JOYSTICK_WINMM 1) - set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c) endif() set(HAVE_SDL_JOYSTICK TRUE) - endif() - if(SDL_HAPTIC AND HAVE_DINPUT_H) - set(SDL_HAPTIC_DINPUT 1) - set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c) - set(HAVE_SDL_HAPTIC TRUE) + if(SDL_HAPTIC) + file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES}) + if(HAVE_DINPUT_H) + set(SDL_HAPTIC_DINPUT 1) + endif() + if(HAVE_XINPUT_H) + set(SDL_HAPTIC_XINPUT 1) + endif() + set(HAVE_SDL_HAPTIC TRUE) + endif() endif() file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc) From 561952180518571d9352f8a9ac9043cb20d138d0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 23:17:47 -0700 Subject: [PATCH 24/50] Fixed bugs 2677 and 2625, made it possible to lock render targets in D3D --- src/render/direct3d/SDL_render_d3d.c | 68 ++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 69279859e..be88da3c8 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -193,6 +193,9 @@ typedef struct typedef struct { SDL_bool dirty; + int w, h; + DWORD usage; + Uint32 format; IDirect3DTexture9 *texture; IDirect3DTexture9 *staging; } D3D_TextureRep; @@ -819,6 +822,10 @@ D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD us HRESULT result; texture->dirty = SDL_FALSE; + texture->w = w; + texture->h = h; + texture->usage = usage; + texture->format = format; result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage, PixelFormatToD3DFMT(format), @@ -826,10 +833,18 @@ D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD us if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); } + return 0; +} - if (usage != D3DUSAGE_RENDERTARGET) { - result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage, - PixelFormatToD3DFMT(format), + +static int +D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture) +{ + HRESULT result; + + if (texture->staging == NULL) { + result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage, + PixelFormatToD3DFMT(texture->format), D3DPOOL_SYSTEMMEM, &texture->staging, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result); @@ -845,14 +860,8 @@ D3D_BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD samp if (texture->dirty && texture->staging) { if (!texture->texture) { - D3DSURFACE_DESC desc; - result = IDirect3DTexture9_GetLevelDesc(texture->staging, 0, &desc); - if (FAILED(result)) { - return D3D_SetError("GetLevelDesc", result); - } - - result = IDirect3DDevice9_CreateTexture(device, desc.Width, desc.Height, 1, 0, - desc.Format, D3DPOOL_DEFAULT, &texture->texture, NULL); + result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage, + PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture, NULL); if (FAILED(result)) { return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); } @@ -878,8 +887,10 @@ D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 IDirect3DTexture9_Release(texture->texture); texture->texture = NULL; } - IDirect3DTexture9_AddDirtyRect(texture->staging, NULL); - texture->dirty = SDL_TRUE; + if (texture->staging) { + IDirect3DTexture9_AddDirtyRect(texture->staging, NULL); + texture->dirty = SDL_TRUE; + } return 0; } @@ -893,10 +904,15 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 f int row, length; HRESULT result; + if (D3D_CreateStagingTexture(device, texture) < 0) { + return -1; + } + d3drect.left = x; d3drect.right = x + w; d3drect.top = y; d3drect.bottom = y + h; + result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0); if (FAILED(result)) { return D3D_SetError("LockRect()", result); @@ -1068,7 +1084,9 @@ static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) { + D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; + IDirect3DDevice9 *device = data->device; if (!texturedata) { SDL_SetError("Texture is not currently available"); @@ -1095,6 +1113,10 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3DLOCKED_RECT locked; HRESULT result; + if (D3D_CreateStagingTexture(device, &texturedata->texture) < 0) { + return -1; + } + d3drect.left = rect->x; d3drect.right = rect->x + rect->w; d3drect.top = rect->y; @@ -1137,7 +1159,9 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; D3D_TextureData *texturedata; + D3D_TextureRep *texturerep; HRESULT result; + IDirect3DDevice9 *device = data->device; /* Release the previous render target if it wasn't the default one */ if (data->currentRenderTarget != NULL) { @@ -1156,6 +1180,24 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) return -1; } + /* Make sure the render target is updated if it was locked and written to */ + texturerep = &texturedata->texture; + if (texturerep->dirty && texturerep->staging) { + if (!texturerep->texture) { + result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage, + PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture, NULL); + if (FAILED(result)) { + return D3D_SetError("CreateTexture(D3DPOOL_DEFAULT)", result); + } + } + + result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texturerep->staging, (IDirect3DBaseTexture9 *)texturerep->texture); + if (FAILED(result)) { + return D3D_SetError("UpdateTexture()", result); + } + texturerep->dirty = SDL_FALSE; + } + result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget); if(FAILED(result)) { return D3D_SetError("GetSurfaceLevel()", result); From 5acb7c63d1e65ffa85fb760b797ba01e422e9222 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 23:23:15 -0700 Subject: [PATCH 25/50] Added SDL_round(), contributed by Benoit Pierre - thanks! --- CMakeLists.txt | 4 ++-- configure | 2 +- configure.in | 2 +- include/SDL_config.h.cmake | 1 + include/SDL_config.h.in | 1 + include/SDL_config_android.h | 1 + include/SDL_config_iphoneos.h | 1 + include/SDL_config_macosx.h | 1 + include/SDL_config_pandora.h | 1 + include/SDL_config_psp.h | 1 + include/SDL_config_windows.h | 1 + include/SDL_config_winrt.h | 1 + include/SDL_config_wiz.h | 1 + include/SDL_stdinc.h | 1 + src/dynapi/SDL_dynapi_overrides.h | 1 + src/dynapi/SDL_dynapi_procs.h | 1 + src/libm/math_libm.h | 1 + src/libm/math_private.h | 1 + src/stdlib/SDL_stdlib.c | 10 ++++++++++ 19 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 792f26c6b..bd6055cc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,7 +495,7 @@ if(LIBC) strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos - cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf) + cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf) string(TOUPPER ${_FN} _UPPER) set(HAVE_${_UPPER} 1) endforeach() @@ -541,7 +541,7 @@ if(LIBC) if(HAVE_LIBM) set(CMAKE_REQUIRED_LIBRARIES m) foreach(_FN - atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin + atan atan2 ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf) string(TOUPPER ${_FN} _UPPER) set(_HAVEVAR "HAVE_${_UPPER}") diff --git a/configure b/configure index 08ecfbf35..beb7b8e9a 100755 --- a/configure +++ b/configure @@ -16641,7 +16641,7 @@ if test "x$ac_cv_lib_m_pow" = xyes; then : LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" fi - for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf + for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 3c87ea754..1464d7eb0 100644 --- a/configure.in +++ b/configure.in @@ -271,7 +271,7 @@ if test x$enable_libc = xyes; then AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname) AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"]) - AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf) + AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf) AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"]) AC_CHECK_FUNCS(iconv) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 9bcf6e909..c149ee8b0 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -140,6 +140,7 @@ #cmakedefine HAVE_FLOOR 1 #cmakedefine HAVE_LOG 1 #cmakedefine HAVE_POW 1 +#cmakedefine HAVE_ROUND 1 #cmakedefine HAVE_SCALBN 1 #cmakedefine HAVE_SIN 1 #cmakedefine HAVE_SINF 1 diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 145a7b772..96c69451d 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -150,6 +150,7 @@ #undef HAVE_FLOOR #undef HAVE_LOG #undef HAVE_POW +#undef HAVE_ROUND #undef HAVE_SCALBN #undef HAVE_SIN #undef HAVE_SINF diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 569ff1d5e..8300b46da 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -96,6 +96,7 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index 4e3eb2c92..75ec3c151 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -94,6 +94,7 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index b6af492d4..ebb63cb5f 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -92,6 +92,7 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index aead1ff9f..2851ada68 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -91,6 +91,7 @@ #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 617d691f2..354dc3f7c 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -94,6 +94,7 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 8bc7ffe09..1b329e214 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -133,6 +133,7 @@ typedef unsigned int uintptr_t; #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h index d70a0bcd6..aa634764b 100644 --- a/include/SDL_config_winrt.h +++ b/include/SDL_config_winrt.h @@ -135,6 +135,7 @@ typedef unsigned int uintptr_t; #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 +#define HAVE_ROUND 1 //#define HAVE_SCALBN 1 #define HAVE__SCALB 1 #define HAVE_SIN 1 diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h index 9204567c6..46bc816f0 100644 --- a/include/SDL_config_wiz.h +++ b/include/SDL_config_wiz.h @@ -85,6 +85,7 @@ #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 +#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 78d3402e7..47a5ca9d4 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -428,6 +428,7 @@ extern DECLSPEC double SDLCALL SDL_fabs(double x); extern DECLSPEC double SDLCALL SDL_floor(double x); extern DECLSPEC double SDLCALL SDL_log(double x); extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +extern DECLSPEC double SDLCALL SDL_round(double x); extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); extern DECLSPEC double SDLCALL SDL_sin(double x); extern DECLSPEC float SDLCALL SDL_sinf(float x); diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 8bcde6312..d88796425 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -591,3 +591,4 @@ #define SDL_QueueAudio SDL_QueueAudio_REAL #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL +#define SDL_round SDL_round_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index c41cdc9f0..0b8546d73 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -623,3 +623,4 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return) SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),) +SDL_DYNAPI_PROC(double,SDL_round,(double a),(a),return) diff --git a/src/libm/math_libm.h b/src/libm/math_libm.h index 6b479f44d..88f785267 100644 --- a/src/libm/math_libm.h +++ b/src/libm/math_libm.h @@ -30,6 +30,7 @@ double SDL_uclibc_fabs(double x); double SDL_uclibc_floor(double x); double SDL_uclibc_log(double x); double SDL_uclibc_pow(double x, double y); +double SDL_uclibc_round(double x); double SDL_uclibc_scalbn(double x, int n); double SDL_uclibc_sin(double x); double SDL_uclibc_sqrt(double x); diff --git a/src/libm/math_private.h b/src/libm/math_private.h index 74c8b3d45..78b62408e 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -37,6 +37,7 @@ typedef unsigned int u_int32_t; #define floor SDL_uclibc_floor #define __ieee754_log SDL_uclibc_log #define __ieee754_pow SDL_uclibc_pow +#define round SDL_uclibc_round #define scalbn SDL_uclibc_scalbn #define sin SDL_uclibc_sin #define __ieee754_sqrt SDL_uclibc_sqrt diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index b1de63d2a..493bebe44 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -169,6 +169,16 @@ SDL_pow(double x, double y) #endif /* HAVE_POW */ } +double +SDL_round(double x) +{ +#if defined(HAVE_ROUND) + return round(x); +#else + return SDL_uclibc_round(x); +#endif /* HAVE_ROUND */ +} + double SDL_scalbn(double x, int n) { From 7ad267339556611ee34b7c9d600a3c547c8b8a20 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 23:25:02 -0700 Subject: [PATCH 26/50] Fixed bug 2687 - SDL_BlitScaled does not handle clipping correctly Patch from Benoit Pierre: video: fix clipping handling in SDL_UpperBlitScaled - honor destination clipping rectangle - update both destination and source rectangles when clipping source rectangle to source surface and destination rectangle to destination clip rectangle - don't change scaling factors when clipping N.B.: - when no scaling is involved (source and destination width/height are the same), SDL_UpperBlit is used (so SDL_BlitScaled behaves like SDL_BlitSurface) - the final destination rectangle after all clipping is performed is saved back to dstrect (like for SDL_UpperBlit) --- src/video/SDL_surface.c | 234 ++++++++++++++++++++++------------------ 1 file changed, 129 insertions(+), 105 deletions(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 421e2b806..3f4244b76 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -26,7 +26,6 @@ #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" - /* Public routines */ /* * Create an empty RGB surface of the appropriate depth @@ -623,7 +622,12 @@ int SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { - SDL_Rect final_src, final_dst, fulldst; + double src_x0, src_y0, src_x1, src_y1; + double dst_x0, dst_y0, dst_x1, dst_y1; + SDL_Rect final_src, final_dst; + double scaling_w, scaling_h; + int src_w, src_h; + int dst_w, dst_h; /* Make sure the surfaces aren't locked */ if (!src || !dst) { @@ -633,78 +637,135 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, return SDL_SetError("Surfaces must not be locked during blit"); } - /* If the destination rectangle is NULL, use the entire dest surface */ - if (dstrect == NULL) { - fulldst.x = fulldst.y = 0; - fulldst.w = dst->w; - fulldst.h = dst->h; - dstrect = &fulldst; - } - - /* clip the source rectangle to the source surface */ - if (srcrect) { - int maxw, maxh; - - final_src.x = srcrect->x; - final_src.w = srcrect->w; - if (final_src.x < 0) { - final_src.w += final_src.x; - final_src.x = 0; - } - maxw = src->w - final_src.x; - if (maxw < final_src.w) - final_src.w = maxw; - - final_src.y = srcrect->y; - final_src.h = srcrect->h; - if (final_src.y < 0) { - final_src.h += final_src.y; - final_src.y = 0; - } - maxh = src->h - final_src.y; - if (maxh < final_src.h) - final_src.h = maxh; - + if (NULL == srcrect) { + src_w = src->w; + src_h = src->h; } else { - final_src.x = final_src.y = 0; - final_src.w = src->w; - final_src.h = src->h; + src_w = srcrect->w; + src_h = srcrect->h; } - /* clip the destination rectangle against the clip rectangle */ - if (dstrect) { - int maxw, maxh; - - final_dst.x = dstrect->x; - final_dst.w = dstrect->w; - if (final_dst.x < 0) { - final_dst.w += final_dst.x; - final_dst.x = 0; - } - maxw = dst->w - final_dst.x; - if (maxw < final_dst.w) - final_dst.w = maxw; - - final_dst.y = dstrect->y; - final_dst.h = dstrect->h; - if (final_dst.y < 0) { - final_dst.h += final_dst.y; - final_dst.y = 0; - } - maxh = dst->h - final_dst.y; - if (maxh < final_dst.h) - final_dst.h = maxh; + if (NULL == dstrect) { + dst_w = dst->w; + dst_h = dst->h; } else { - final_dst.x = final_dst.y = 0; - final_dst.w = dst->w; - final_dst.h = dst->h; + dst_w = dstrect->w; + dst_h = dstrect->h; } - if (final_dst.w > 0 && final_dst.h > 0) { - return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst); + if (dst_w == src_w && dst_h == src_h) { + /* No scaling, defer to regular blit */ + return SDL_BlitSurface(src, srcrect, dst, dstrect); } - return 0; + scaling_w = (double)dst_w / src_w; + scaling_h = (double)dst_h / src_h; + + if (NULL == dstrect) { + dst_x0 = 0; + dst_y0 = 0; + dst_x1 = dst_w - 1; + dst_y1 = dst_h - 1; + } else { + dst_x0 = dstrect->x; + dst_y0 = dstrect->y; + dst_x1 = dst_x0 + dst_w - 1; + dst_y1 = dst_y0 + dst_h - 1; + } + + if (NULL == srcrect) { + src_x0 = 0; + src_y0 = 0; + src_x1 = src_w - 1; + src_y1 = src_h - 1; + } else { + src_x0 = srcrect->x; + src_y0 = srcrect->y; + src_x1 = src_x0 + src_w - 1; + src_y1 = src_y0 + src_h - 1; + + /* Clip source rectangle to the source surface */ + + if (src_x0 < 0) { + dst_x0 -= src_x0 * scaling_w; + src_x0 = 0; + } + + if (src_x1 >= src->w) { + dst_x1 -= (src_x1 - src->w + 1) * scaling_w; + src_x1 = src->w - 1; + } + + if (src_y0 < 0) { + dst_y0 -= src_y0 * scaling_h; + src_y0 = 0; + } + + if (src_y1 >= src->h) { + dst_y1 -= (src_y1 - src->h + 1) * scaling_h; + src_y1 = src->h - 1; + } + } + + /* Clip destination rectangle to the clip rectangle */ + + /* Translate to clip space for easier calculations */ + dst_x0 -= dst->clip_rect.x; + dst_x1 -= dst->clip_rect.x; + dst_y0 -= dst->clip_rect.y; + dst_y1 -= dst->clip_rect.y; + + if (dst_x0 < 0) { + src_x0 -= dst_x0 / scaling_w; + dst_x0 = 0; + } + + if (dst_x1 >= dst->clip_rect.w) { + src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w; + dst_x1 = dst->clip_rect.w - 1; + } + + if (dst_y0 < 0) { + src_y0 -= dst_y0 / scaling_h; + dst_y0 = 0; + } + + if (dst_y1 >= dst->clip_rect.h) { + src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h; + dst_y1 = dst->clip_rect.h - 1; + } + + /* Translate back to surface coordinates */ + dst_x0 += dst->clip_rect.x; + dst_x1 += dst->clip_rect.x; + dst_y0 += dst->clip_rect.y; + dst_y1 += dst->clip_rect.y; + + final_src.x = SDL_round(src_x0); + final_src.y = SDL_round(src_y0); + final_src.w = SDL_round(src_x1 - src_x0 + 1); + final_src.h = SDL_round(src_y1 - src_y0 + 1); + + final_dst.x = SDL_round(dst_x0); + final_dst.y = SDL_round(dst_y0); + final_dst.w = SDL_round(dst_x1 - dst_x0 + 1); + final_dst.h = SDL_round(dst_y1 - dst_y0 + 1); + + if (final_dst.w < 0) + final_dst.w = 0; + if (final_dst.h < 0) + final_dst.h = 0; + + if (dstrect) + *dstrect = final_dst; + + if (final_dst.w == 0 || final_dst.h == 0 || + final_src.w <= 0 || final_src.h <= 0) { + /* No-op. */ + return 0; + } + + return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst); } /** @@ -721,43 +782,6 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_COPY_COLORKEY ); - /* Save off the original dst width, height */ - int dstW = dstrect->w; - int dstH = dstrect->h; - SDL_Rect full_rect; - SDL_Rect final_dst = *dstrect; - SDL_Rect final_src = *srcrect; - - /* Clip the dst surface to the dstrect */ - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = dst->w; - full_rect.h = dst->h; - if (!SDL_IntersectRect(&final_dst, &full_rect, &final_dst)) { - return 0; - } - - /* Did the dst width change? */ - if ( dstW != final_dst.w ) { - /* scale the src width appropriately */ - final_src.w = final_src.w * dst->clip_rect.w / dstW; - } - - /* Did the dst height change? */ - if ( dstH != final_dst.h ) { - /* scale the src width appropriately */ - final_src.h = final_src.h * dst->clip_rect.h / dstH; - } - - /* Clip the src surface to the srcrect */ - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = src->w; - full_rect.h = src->h; - if (!SDL_IntersectRect(&final_src, &full_rect, &final_src)) { - return 0; - } - if (!(src->map->info.flags & SDL_COPY_NEAREST)) { src->map->info.flags |= SDL_COPY_NEAREST; SDL_InvalidateMap(src->map); @@ -766,9 +790,9 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { - return SDL_SoftStretch( src, &final_src, dst, &final_dst ); + return SDL_SoftStretch( src, srcrect, dst, dstrect ); } else { - return SDL_LowerBlit( src, &final_src, dst, &final_dst ); + return SDL_LowerBlit( src, srcrect, dst, dstrect ); } } From 67228e5e8cbf5edd83803e111c0fef324d8e8527 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 23:28:40 -0700 Subject: [PATCH 27/50] Fixed bug 2683 - Raspberry PI support using CMake Tobias Himmer this patch adds a check to the CMake build script to detect whether the VideoCore API is available. If it is found, it enables SDL_VIDEO_DRIVER_RPI and will also add the needed include/library directory flags to CMAKE_C_FLAGS so the subsequent check for GLES succeeds in picking up the headers. Seems to work fine on Raspbian. --- CMakeLists.txt | 3 +++ cmake/sdlchecks.cmake | 29 +++++++++++++++++++++++++++++ include/SDL_config.h.cmake | 1 + 3 files changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd6055cc8..2f6c4ca10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,7 @@ set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SY set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS}) set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS}) set_option(VIDEO_MIR "Use Mir video driver" ${UNIX_SYS}) +set_option(VIDEO_RPI "Use Raspberry Pi video driver" ${UNIX_SYS}) dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF) set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm) foreach(_SUB ${SDL_X11_OPTIONS}) @@ -658,6 +659,8 @@ if(UNIX AND NOT APPLE) endif() if(SDL_VIDEO) + # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails! + CheckRPI() CheckX11() CheckMir() CheckDirectFB() diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 08347ece2..fa8aa396e 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -917,3 +917,32 @@ macro(CheckUSBHID) set(CMAKE_REQUIRED_FLAGS) endif(HAVE_USBHID) endmacro(CheckUSBHID) + +# Requires: +# - n/a +macro(CheckRPI) + if(VIDEO_RPI) + set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" ) + set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" ) + set(VIDEO_RPI_LIBS bcm_host ) + listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I") + listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L") + + set(CMAKE_REQUIRED_FLAGS "${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}") + set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBS}") + check_c_source_compiles(" + #include + int main(int argc, char **argv) {}" HAVE_VIDEO_RPI) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_LIBRARIES) + + if(SDL_VIDEO AND HAVE_VIDEO_RPI) + set(HAVE_SDL_VIDEO TRUE) + set(SDL_VIDEO_DRIVER_RPI 1) + file(GLOB VIDEO_RPI_SOURCES ${SDL2_SOURCE_DIR}/src/video/raspberry/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_RPI_SOURCES}) + list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBS}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}") + endif(SDL_VIDEO AND HAVE_VIDEO_RPI) + endif(VIDEO_RPI) +endmacro(CheckRPI) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index c149ee8b0..c59bdb70a 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -264,6 +264,7 @@ #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ +#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ #if 0 /* !!! FIXME: in configure script version, missing here: */ From 3d8224313ff49f8dc29abd1df1a78edbdc6e8444 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 16 Aug 2014 23:30:44 -0700 Subject: [PATCH 28/50] Fixed bug 2681 - dereference a NULL pointer dst_fmt in SDL_CreateTextureFromSurface function Nitz In SDL_CreateTextureFromSurface: SDL_PixelFormat *dst_fmt; /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); temp = SDL_ConvertSurface(surface, dst_fmt, 0); Here is need of NULL check for dst_fmt because there are chances of NULL return from SDL_AllocFormat(format); --- src/render/SDL_render.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 3aea6bcbd..1201b0e21 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -540,6 +540,10 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); + if (!dst_fmt) { + SDL_DestroyTexture(texture); + return NULL; + } temp = SDL_ConvertSurface(surface, dst_fmt, 0); SDL_FreeFormat(dst_fmt); if (temp) { From 00b70124b6db7a0622a5720e8e3e8f4e8e7c2936 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 10:10:41 -0700 Subject: [PATCH 29/50] Fixed bug 2688 - failure to build test/loopwavequeue.c on Linux --- test/loopwavequeue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c index a70e516dd..8ca31dd03 100644 --- a/test/loopwavequeue.c +++ b/test/loopwavequeue.c @@ -15,12 +15,12 @@ #include #include +#include "SDL.h" + #if HAVE_SIGNAL_H #include #endif -#include "SDL.h" - struct { SDL_AudioSpec spec; From b3e4782510b69f52e5ce1023fa39ecf626ed77cd Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 13:11:55 -0700 Subject: [PATCH 30/50] Removed SDL_round() because the license wasn't compatible with zlib --- CMakeLists.txt | 4 ++-- configure | 2 +- configure.in | 2 +- include/SDL_config.h.cmake | 1 - include/SDL_config.h.in | 1 - include/SDL_config_android.h | 1 - include/SDL_config_iphoneos.h | 1 - include/SDL_config_macosx.h | 1 - include/SDL_config_pandora.h | 1 - include/SDL_config_psp.h | 1 - include/SDL_config_windows.h | 1 - include/SDL_config_winrt.h | 1 - include/SDL_config_wiz.h | 1 - include/SDL_stdinc.h | 1 - src/dynapi/SDL_dynapi_overrides.h | 1 - src/dynapi/SDL_dynapi_procs.h | 1 - src/libm/math_libm.h | 1 - src/libm/math_private.h | 1 - src/stdlib/SDL_stdlib.c | 10 ---------- src/video/SDL_surface.c | 16 ++++++++-------- 20 files changed, 12 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f6c4ca10..11aa5e91f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -496,7 +496,7 @@ if(LIBC) strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos - cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf) + cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf) string(TOUPPER ${_FN} _UPPER) set(HAVE_${_UPPER} 1) endforeach() @@ -542,7 +542,7 @@ if(LIBC) if(HAVE_LIBM) set(CMAKE_REQUIRED_LIBRARIES m) foreach(_FN - atan atan2 ceil copysign cos cosf fabs floor log pow round scalbn sin + atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf) string(TOUPPER ${_FN} _UPPER) set(_HAVEVAR "HAVE_${_UPPER}") diff --git a/configure b/configure index beb7b8e9a..08ecfbf35 100755 --- a/configure +++ b/configure @@ -16641,7 +16641,7 @@ if test "x$ac_cv_lib_m_pow" = xyes; then : LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" fi - for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf + for ac_func in atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/configure.in b/configure.in index 1464d7eb0..3c87ea754 100644 --- a/configure.in +++ b/configure.in @@ -271,7 +271,7 @@ if test x$enable_libc = xyes; then AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname) AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"]) - AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow round scalbn sin sinf sqrt sqrtf tan tanf) + AC_CHECK_FUNCS(atan atan2 acos asin ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf) AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"]) AC_CHECK_FUNCS(iconv) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index c59bdb70a..51500fb2b 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -140,7 +140,6 @@ #cmakedefine HAVE_FLOOR 1 #cmakedefine HAVE_LOG 1 #cmakedefine HAVE_POW 1 -#cmakedefine HAVE_ROUND 1 #cmakedefine HAVE_SCALBN 1 #cmakedefine HAVE_SIN 1 #cmakedefine HAVE_SINF 1 diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 96c69451d..145a7b772 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -150,7 +150,6 @@ #undef HAVE_FLOOR #undef HAVE_LOG #undef HAVE_POW -#undef HAVE_ROUND #undef HAVE_SCALBN #undef HAVE_SIN #undef HAVE_SINF diff --git a/include/SDL_config_android.h b/include/SDL_config_android.h index 8300b46da..569ff1d5e 100644 --- a/include/SDL_config_android.h +++ b/include/SDL_config_android.h @@ -96,7 +96,6 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index 75ec3c151..4e3eb2c92 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -94,7 +94,6 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index ebb63cb5f..b6af492d4 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -92,7 +92,6 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index 2851ada68..aead1ff9f 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -91,7 +91,6 @@ #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 354dc3f7c..617d691f2 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -94,7 +94,6 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 1b329e214..8bc7ffe09 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -133,7 +133,6 @@ typedef unsigned int uintptr_t; #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h index aa634764b..d70a0bcd6 100644 --- a/include/SDL_config_winrt.h +++ b/include/SDL_config_winrt.h @@ -135,7 +135,6 @@ typedef unsigned int uintptr_t; #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_POW 1 -#define HAVE_ROUND 1 //#define HAVE_SCALBN 1 #define HAVE__SCALB 1 #define HAVE_SIN 1 diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h index 46bc816f0..9204567c6 100644 --- a/include/SDL_config_wiz.h +++ b/include/SDL_config_wiz.h @@ -85,7 +85,6 @@ #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 -#define HAVE_ROUND 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 47a5ca9d4..78d3402e7 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -428,7 +428,6 @@ extern DECLSPEC double SDLCALL SDL_fabs(double x); extern DECLSPEC double SDLCALL SDL_floor(double x); extern DECLSPEC double SDLCALL SDL_log(double x); extern DECLSPEC double SDLCALL SDL_pow(double x, double y); -extern DECLSPEC double SDLCALL SDL_round(double x); extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); extern DECLSPEC double SDLCALL SDL_sin(double x); extern DECLSPEC float SDLCALL SDL_sinf(float x); diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index d88796425..8bcde6312 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -591,4 +591,3 @@ #define SDL_QueueAudio SDL_QueueAudio_REAL #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL -#define SDL_round SDL_round_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 0b8546d73..c41cdc9f0 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -623,4 +623,3 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return) SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),) -SDL_DYNAPI_PROC(double,SDL_round,(double a),(a),return) diff --git a/src/libm/math_libm.h b/src/libm/math_libm.h index 88f785267..6b479f44d 100644 --- a/src/libm/math_libm.h +++ b/src/libm/math_libm.h @@ -30,7 +30,6 @@ double SDL_uclibc_fabs(double x); double SDL_uclibc_floor(double x); double SDL_uclibc_log(double x); double SDL_uclibc_pow(double x, double y); -double SDL_uclibc_round(double x); double SDL_uclibc_scalbn(double x, int n); double SDL_uclibc_sin(double x); double SDL_uclibc_sqrt(double x); diff --git a/src/libm/math_private.h b/src/libm/math_private.h index 78b62408e..74c8b3d45 100644 --- a/src/libm/math_private.h +++ b/src/libm/math_private.h @@ -37,7 +37,6 @@ typedef unsigned int u_int32_t; #define floor SDL_uclibc_floor #define __ieee754_log SDL_uclibc_log #define __ieee754_pow SDL_uclibc_pow -#define round SDL_uclibc_round #define scalbn SDL_uclibc_scalbn #define sin SDL_uclibc_sin #define __ieee754_sqrt SDL_uclibc_sqrt diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 493bebe44..b1de63d2a 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -169,16 +169,6 @@ SDL_pow(double x, double y) #endif /* HAVE_POW */ } -double -SDL_round(double x) -{ -#if defined(HAVE_ROUND) - return round(x); -#else - return SDL_uclibc_round(x); -#endif /* HAVE_ROUND */ -} - double SDL_scalbn(double x, int n) { diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 3f4244b76..fcd78870e 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -741,15 +741,15 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, dst_y0 += dst->clip_rect.y; dst_y1 += dst->clip_rect.y; - final_src.x = SDL_round(src_x0); - final_src.y = SDL_round(src_y0); - final_src.w = SDL_round(src_x1 - src_x0 + 1); - final_src.h = SDL_round(src_y1 - src_y0 + 1); + final_src.x = SDL_floor(src_x0 + 0.5); + final_src.y = SDL_floor(src_y0 + 0.5); + final_src.w = SDL_floor(src_x1 - src_x0 + 1.5); + final_src.h = SDL_floor(src_y1 - src_y0 + 1.5); - final_dst.x = SDL_round(dst_x0); - final_dst.y = SDL_round(dst_y0); - final_dst.w = SDL_round(dst_x1 - dst_x0 + 1); - final_dst.h = SDL_round(dst_y1 - dst_y0 + 1); + final_dst.x = SDL_floor(dst_x0 + 0.5); + final_dst.y = SDL_floor(dst_y0 + 0.5); + final_dst.w = SDL_floor(dst_x1 - dst_x0 + 1.5); + final_dst.h = SDL_floor(dst_y1 - dst_y0 + 1.5); if (final_dst.w < 0) final_dst.w = 0; From 3c747234b3753232a5f4fd9ed5a2d6889b7264a6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 13:15:09 -0700 Subject: [PATCH 31/50] cmake: add -Wall/-Wshadow to GCC compilation flags --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11aa5e91f..fcf7c18fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -331,11 +331,15 @@ if(USE_GCC OR USE_CLANG) check_c_compiler_flag(-Wall HAVE_GCC_WALL) if(HAVE_GCC_WALL) + list(APPEND EXTRA_CFLAGS "-Wall") if(HAIKU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar") endif() endif() - #check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW) + check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW) + if(HAVE_GCC_WSHADOW) + list(APPEND EXTRA_CFLAGS "-Wshadow") + endif() endif() if(ASSEMBLY) From a8d9c26db25c6f7255ef2877472adb312eab398e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 13:15:45 -0700 Subject: [PATCH 32/50] cmake: add -Wl,--no-undefined to GCC linker flags This way unresolved symbols will be detected when linking the shared library version. --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcf7c18fb..8f408c70f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -340,6 +340,12 @@ if(USE_GCC OR USE_CLANG) if(HAVE_GCC_WSHADOW) list(APPEND EXTRA_CFLAGS "-Wshadow") endif() + + set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") + check_c_compiler_flag("" HAVE_NO_UNDEFINED) + if(HAVE_NO_UNDEFINED) + list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") + endif() endif() if(ASSEMBLY) From e49acc1f5b173f722fdfc94d70eb6c114629dabe Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 13:49:53 -0700 Subject: [PATCH 33/50] Reset CMAKE_REQUIRED_FLAGS after test --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f408c70f..4fc2b396f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,6 +343,7 @@ if(USE_GCC OR USE_CLANG) set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") check_c_compiler_flag("" HAVE_NO_UNDEFINED) + set(CMAKE_REQUIRED_FLAGS) if(HAVE_NO_UNDEFINED) list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") endif() From cf895bf696cd37b9e59b1e3b43dcac2f0fcac487 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 14:34:41 -0700 Subject: [PATCH 34/50] Fixed bug where the render target is updated instead of the default output when the window is resized. --- src/render/SDL_render.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1201b0e21..4480d7152 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -115,6 +115,12 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) } if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Make sure we're operating on the default render target */ + SDL_Texture *saved_target = SDL_GetRenderTarget(renderer); + if (saved_target) { + SDL_SetRenderTarget(renderer, NULL); + } + if (renderer->logical_w) { UpdateLogicalSize(renderer); } else { @@ -140,6 +146,10 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) renderer->UpdateViewport(renderer); } } + + if (saved_target) { + SDL_SetRenderTarget(renderer, saved_target); + } } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) { renderer->hidden = SDL_TRUE; } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) { @@ -916,12 +926,12 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, SDL_assert(!texture->native); renderer = texture->renderer; SDL_assert(renderer->UpdateTextureYUV); - if (renderer->UpdateTextureYUV) { - return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); - } else { - return SDL_Unsupported(); - } - } + if (renderer->UpdateTextureYUV) { + return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + } else { + return SDL_Unsupported(); + } + } } static int From cba9f4958726d355eb5022b37728ac7f052716c3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 14:44:53 -0700 Subject: [PATCH 35/50] Fixed bug 2685 - SDL_RenderReadPixels() doesn't work with offscreen targets Andreas Falkenhahn SDL_RenderReadPixels() doesn't seem to work when trying to read pixels from a texture that has been created using SDL_TEXTUREACCESS_TARGET and has been selected as the render target using SDL_SetRenderTarget(). I am attaching a small program that demonstrates the issue. I get the following result here: READ PIXEL RETURN: 0 --- COLOR CHECK: ff000000 But it should be: READ PIXEL RETURN: 0 --- COLOR CHECK: ffff0000 Tested with SDL 2.0.3 on Windows 7. --- src/render/direct3d/SDL_render_d3d.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index be88da3c8..d96522e71 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1831,9 +1831,10 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, D3DLOCKED_RECT locked; HRESULT result; - result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); - if (FAILED(result)) { - return D3D_SetError("GetBackBuffer()", result); + if (data->currentRenderTarget) { + backBuffer = data->currentRenderTarget; + } else { + backBuffer = data->defaultRenderTarget; } result = IDirect3DSurface9_GetDesc(backBuffer, &desc); @@ -1874,7 +1875,6 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, IDirect3DSurface9_UnlockRect(surface); IDirect3DSurface9_Release(surface); - IDirect3DSurface9_Release(backBuffer); return 0; } From 6d927d747263ad882220f1ff075ff89d31e0a250 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 14:57:52 -0700 Subject: [PATCH 36/50] Fixed bug 2655 - OSX: Window position and global mouse coord spaces are different Tim McDaniel On OSX, with revision 8729, the coordinate space for window position and the coordinate space for global mouse position don't match. For a non-fullscreen window, the window position is global relative to the bottom of the menubar. The global mouse position is relative to the top of the screen. This affects Cocoa_WarpMouse and potentially other things as well. Further, the coordinate system for window position is now affected by what screen it is on. For example, if I have two equal size screens oriented side by side such that the tops of the screens are equal in global space, with the menubar on one screen, and a window straddles the two screens, the window's y position makes no sense. The window's y position depends on what screen "most" of the window is on. So if I move the window horizontally just a bit, the y position of my window is now different by the size of the menubar, even though the window was not moved vertically. I'd like to reiterate that this was a fairly fundamental change (and a breaking change for us). If SDL OSX is to really support multi-display configurations, this is especially problematic. If the real concern is preventing windows from going under the menubar, then perhaps a solution involving something like overriding [NSWindow constrainFrameRect] would be less problematic than redefining the global window coord space for the main display. --- src/video/cocoa/SDL_cocoamouse.m | 46 ++++++++++--------------------- src/video/cocoa/SDL_cocoawindow.m | 17 ++++++------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 4ea420d22..f0480603d 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -207,42 +207,18 @@ Cocoa_ShowCursor(SDL_Cursor * cursor) return 0; } -static void -Cocoa_WarpMouse(SDL_Window * window, int x, int y) -{ - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - if ([data->listener isMoving]) { - DLog("Postponing warp, window being moved."); - [data->listener setPendingMoveX:x - Y:y]; - return; - } - - SDL_Mouse *mouse = SDL_GetMouse(); - CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y); - - Cocoa_HandleMouseWarp(point.x, point.y); - - /* According to the docs, this was deprecated in 10.6, but it's still - * around. The substitute requires a CGEventSource, but I'm not entirely - * sure how we'd procure the right one for this event. - */ - CGSetLocalEventsSuppressionInterval(0.0); - CGWarpMouseCursorPosition(point); - CGSetLocalEventsSuppressionInterval(0.25); - - if (!mouse->relative_mode) { - /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our - * other implementations' APIs. - */ - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y); - } -} - static void Cocoa_WarpMouseGlobal(int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); + if (mouse->focus) { + SDL_WindowData *data = (SDL_WindowData *) mouse->focus->driverdata; + if ([data->listener isMoving]) { + DLog("Postponing warp, window being moved."); + [data->listener setPendingMoveX:x Y:y]; + return; + } + } CGPoint point = CGPointMake((float)x, (float)y); Cocoa_HandleMouseWarp(point.x, point.y); @@ -263,6 +239,12 @@ Cocoa_WarpMouseGlobal(int x, int y) } } +static void +Cocoa_WarpMouse(SDL_Window * window, int x, int y) +{ + Cocoa_WarpMouseGlobal(x + window->x, y + window->y); +} + static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) { diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 63d6f211d..29bba457c 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -103,8 +103,7 @@ static Uint32 s_moveHack; static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r) { - NSRect visibleScreen = fullscreen ? [screen frame] : [screen visibleFrame]; - r->origin.y = (visibleScreen.origin.y + visibleScreen.size.height) - r->origin.y - r->size.height; + r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; } static void @@ -389,11 +388,11 @@ SetWindowStyle(SDL_Window * window, unsigned int style) isMoving = NO; SDL_Mouse *mouse = SDL_GetMouse(); - if (pendingWindowWarpX >= 0 && pendingWindowWarpY >= 0) { - mouse->WarpMouse(_data->window, pendingWindowWarpX, pendingWindowWarpY); - pendingWindowWarpX = pendingWindowWarpY = -1; + if (pendingWindowWarpX != INT_MAX && pendingWindowWarpY != INT_MAX) { + mouse->WarpMouseGlobal(pendingWindowWarpX, pendingWindowWarpY); + pendingWindowWarpX = pendingWindowWarpY = INT_MAX; } - if (mouse->relative_mode && SDL_GetMouseFocus() == _data->window) { + if (mouse->relative_mode && !mouse->relative_mode_warp && mouse->focus == _data->window) { mouse->SetRelativeMouseMode(SDL_TRUE); } } @@ -413,7 +412,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style) - (void)windowWillMove:(NSNotification *)aNotification { if ([_data->nswindow isKindOfClass:[SDLWindow class]]) { - pendingWindowWarpX = pendingWindowWarpY = -1; + pendingWindowWarpX = pendingWindowWarpY = INT_MAX; isMoving = YES; } } @@ -500,7 +499,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style) { SDL_Window *window = _data->window; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse->relative_mode && ![self isMoving]) { + if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) { mouse->SetRelativeMouseMode(SDL_TRUE); } @@ -532,7 +531,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style) - (void)windowDidResignKey:(NSNotification *)aNotification { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse->relative_mode) { + if (mouse->relative_mode && !mouse->relative_mode_warp) { mouse->SetRelativeMouseMode(SDL_FALSE); } From cf85a26a3033268ea8241578b6e0b5b87068c98d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 17 Aug 2014 15:07:00 -0700 Subject: [PATCH 37/50] Fixed 2680 - OSX: Replace NSAutoreleasePool with @autoreleasepool Tim McDaniel This patch replaces all use of NSAutoreleasePool with the Apple recommended @autoreleasepool. @autoreleasepool is supposedly more efficient, and since it is scope based it can't be accidentally not released. --- src/file/cocoa/SDL_rwopsbundlesupport.m | 8 ++---- src/filesystem/cocoa/SDL_sysfilesystem.m | 10 +++----- src/video/cocoa/SDL_cocoaclipboard.m | 24 +++++------------- src/video/cocoa/SDL_cocoaevents.m | 13 +++------- src/video/cocoa/SDL_cocoakeyboard.m | 11 +++----- src/video/cocoa/SDL_cocoamessagebox.m | 7 ++---- src/video/cocoa/SDL_cocoamodes.m | 7 ++---- src/video/cocoa/SDL_cocoamouse.m | 32 ++++++++---------------- 8 files changed, 34 insertions(+), 78 deletions(-) diff --git a/src/file/cocoa/SDL_rwopsbundlesupport.m b/src/file/cocoa/SDL_rwopsbundlesupport.m index f6a65a99a..1ae399c2d 100644 --- a/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -33,6 +33,7 @@ Also, note the bundle layouts are different for iPhone and Mac. */ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) +{ @autoreleasepool { FILE* fp = NULL; @@ -41,9 +42,6 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) return fopen(file, mode); } - NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init]; - - NSFileManager* file_manager = [NSFileManager defaultManager]; NSString* resource_path = [[NSBundle mainBundle] resourcePath]; @@ -57,10 +55,8 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) fp = fopen(file, mode); } - [autorelease_pool drain]; - return fp; -} +}} #endif /* __MACOSX__ */ diff --git a/src/filesystem/cocoa/SDL_sysfilesystem.m b/src/filesystem/cocoa/SDL_sysfilesystem.m index adcebd68b..dab51c501 100644 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -35,8 +35,8 @@ char * SDL_GetBasePath(void) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSBundle *bundle = [NSBundle mainBundle]; const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; const char *base = NULL; @@ -62,14 +62,13 @@ SDL_GetBasePath(void) } } - [pool release]; return retval; -} +}} char * SDL_GetPrefPath(const char *org, const char *app) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSArray *array = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); char *retval = NULL; @@ -96,9 +95,8 @@ SDL_GetPrefPath(const char *org, const char *app) } } - [pool release]; return retval; -} +}} #endif /* SDL_FILESYSTEM_COCOA */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index c2f3be73c..bf3b90955 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -37,34 +37,28 @@ GetTextFormat(_THIS) int Cocoa_SetClipboardText(_THIS, const char *text) +{ @autoreleasepool { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - NSAutoreleasePool *pool; NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); - pool = [[NSAutoreleasePool alloc] init]; - pasteboard = [NSPasteboard generalPasteboard]; data->clipboard_count = [pasteboard declareTypes:[NSArray arrayWithObject:format] owner:nil]; [pasteboard setString:[NSString stringWithUTF8String:text] forType:format]; - [pool release]; - return 0; -} +}} char * Cocoa_GetClipboardText(_THIS) +{ @autoreleasepool { - NSAutoreleasePool *pool; NSPasteboard *pasteboard; NSString *format = GetTextFormat(_this); NSString *available; char *text; - pool = [[NSAutoreleasePool alloc] init]; - pasteboard = [NSPasteboard generalPasteboard]; available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; if ([available isEqualToString:format]) { @@ -82,10 +76,8 @@ Cocoa_GetClipboardText(_THIS) text = SDL_strdup(""); } - [pool release]; - return text; -} +}} SDL_bool Cocoa_HasClipboardText(_THIS) @@ -101,13 +93,11 @@ Cocoa_HasClipboardText(_THIS) void Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) +{ @autoreleasepool { - NSAutoreleasePool *pool; NSPasteboard *pasteboard; NSInteger count; - pool = [[NSAutoreleasePool alloc] init]; - pasteboard = [NSPasteboard generalPasteboard]; count = [pasteboard changeCount]; if (count != data->clipboard_count) { @@ -116,9 +106,7 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) } data->clipboard_count = count; } - - [pool release]; -} +}} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index 3474d159a..13aeb4502 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -248,17 +248,16 @@ CreateApplicationMenus(void) void Cocoa_RegisterApp(void) +{ @autoreleasepool { /* This can get called more than once! Be careful what you initialize! */ ProcessSerialNumber psn; - NSAutoreleasePool *pool; if (!GetCurrentProcess(&psn)) { TransformProcessType(&psn, kProcessTransformToForegroundApplication); SetFrontProcess(&psn); } - pool = [[NSAutoreleasePool alloc] init]; if (NSApp == nil) { [SDLApplication sharedApplication]; SDL_assert(NSApp != nil); @@ -287,14 +286,12 @@ Cocoa_RegisterApp(void) appDelegate->seenFirstActivate = YES; } } - [pool release]; -} +}} void Cocoa_PumpEvents(_THIS) +{ @autoreleasepool { - NSAutoreleasePool *pool; - /* Update activity every 30 seconds to prevent screensaver */ if (_this->suspend_screensaver) { SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; @@ -306,7 +303,6 @@ Cocoa_PumpEvents(_THIS) } } - pool = [[NSAutoreleasePool alloc] init]; for ( ; ; ) { NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; if ( event == nil ) { @@ -338,8 +334,7 @@ Cocoa_PumpEvents(_THIS) /* Pass through to NSApp to make sure everything stays in sync */ [NSApp sendEvent:event]; } - [pool release]; -} +}} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 53f58866c..c621182b8 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -479,9 +479,9 @@ Cocoa_InitKeyboard(_THIS) void Cocoa_StartTextInput(_THIS) +{ @autoreleasepool { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; SDL_Window *window = SDL_GetKeyboardFocus(); NSWindow *nswindow = nil; if (window) { @@ -506,23 +506,20 @@ Cocoa_StartTextInput(_THIS) [parentView addSubview: data->fieldEdit]; [nswindow makeFirstResponder: data->fieldEdit]; } - - [pool release]; -} +}} void Cocoa_StopTextInput(_THIS) +{ @autoreleasepool { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (data && data->fieldEdit) { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [data->fieldEdit removeFromSuperview]; [data->fieldEdit release]; data->fieldEdit = nil; - [pool release]; } -} +}} void Cocoa_SetTextInputRect(_THIS, SDL_Rect *rect) diff --git a/src/video/cocoa/SDL_cocoamessagebox.m b/src/video/cocoa/SDL_cocoamessagebox.m index 2ed7d9057..5a8f78050 100644 --- a/src/video/cocoa/SDL_cocoamessagebox.m +++ b/src/video/cocoa/SDL_cocoamessagebox.m @@ -79,11 +79,10 @@ /* Display a Cocoa message box */ int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +{ @autoreleasepool { Cocoa_RegisterApp(); - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSAlert* alert = [[[NSAlert alloc] init] autorelease]; if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) { @@ -125,10 +124,8 @@ Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) returnValue = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked); } - [pool release]; - return returnValue; -} +}} #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index a98d376ff..5f460589e 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -214,8 +214,8 @@ Cocoa_GetDisplayName(CGDirectDisplayID displayID) void Cocoa_InitModes(_THIS) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; CGDisplayErr result; CGDirectDisplayID *displays; CGDisplayCount numDisplays; @@ -224,7 +224,6 @@ Cocoa_InitModes(_THIS) result = CGGetOnlineDisplayList(0, NULL, &numDisplays); if (result != kCGErrorSuccess) { CG_SetError("CGGetOnlineDisplayList()", result); - [pool release]; return; } displays = SDL_stack_alloc(CGDirectDisplayID, numDisplays); @@ -232,7 +231,6 @@ Cocoa_InitModes(_THIS) if (result != kCGErrorSuccess) { CG_SetError("CGGetOnlineDisplayList()", result); SDL_stack_free(displays); - [pool release]; return; } @@ -297,8 +295,7 @@ Cocoa_InitModes(_THIS) } } SDL_stack_free(displays); - [pool release]; -} +}} int Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index f0480603d..8b933c27d 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -66,8 +66,8 @@ static SDL_Cursor * Cocoa_CreateDefaultCursor() +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSCursor *nscursor; SDL_Cursor *cursor = NULL; @@ -81,15 +81,13 @@ Cocoa_CreateDefaultCursor() } } - [pool release]; - return cursor; -} +}} static SDL_Cursor * Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSImage *nsimage; NSCursor *nscursor = NULL; SDL_Cursor *cursor = NULL; @@ -108,15 +106,13 @@ Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) } } - [pool release]; - return cursor; -} +}} static SDL_Cursor * Cocoa_CreateSystemCursor(SDL_SystemCursor id) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSCursor *nscursor = NULL; SDL_Cursor *cursor = NULL; @@ -169,28 +165,23 @@ Cocoa_CreateSystemCursor(SDL_SystemCursor id) } } - [pool release]; - return cursor; -} +}} static void Cocoa_FreeCursor(SDL_Cursor * cursor) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSCursor *nscursor = (NSCursor *)cursor->driverdata; [nscursor release]; SDL_free(cursor); - - [pool release]; -} +}} static int Cocoa_ShowCursor(SDL_Cursor * cursor) +{ @autoreleasepool { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - SDL_VideoDevice *device = SDL_GetVideoDevice(); SDL_Window *window = (device ? device->windows : NULL); for (; window != NULL; window = window->next) { @@ -201,11 +192,8 @@ Cocoa_ShowCursor(SDL_Cursor * cursor) waitUntilDone:NO]; } } - - [pool release]; - return 0; -} +}} static void Cocoa_WarpMouseGlobal(int x, int y) From 342b854e9c954ebeab952bfef31c201f3b593abb Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 18 Aug 2014 14:05:02 -0400 Subject: [PATCH 38/50] Don't use the system OpenGL headers, ever. (the replacement header is from Mesa, under what the MIT license.) --HG-- extra : amend_source : eaaafee6cce788d6770e819fc155fe969ba97cbe --- include/SDL_opengl.h | 2179 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 2134 insertions(+), 45 deletions(-) diff --git a/include/SDL_opengl.h b/include/SDL_opengl.h index ff7a587f2..35e9f308e 100644 --- a/include/SDL_opengl.h +++ b/include/SDL_opengl.h @@ -25,50 +25,6 @@ * This is a simple file to encapsulate the OpenGL API headers. */ -#ifndef _SDL_opengl_h -#define _SDL_opengl_h - -#include "SDL_config.h" - -#ifndef __IPHONEOS__ - -#ifdef __WIN32__ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX -#define NOMINMAX /* Don't defined min() and max() */ -#endif -#include -#endif - -#ifdef __glext_h_ -/* Someone has already included glext.h */ -#define NO_SDL_GLEXT -#else -#define _SDL_CLEAR_GLEXT_HEADERGUARD -#define __glext_h_ /* Don't let gl.h include glext.h */ -#endif -#if defined(__MACOSX__) -#include /* Header File For The OpenGL Library */ -#define __X_GL_H -#else -#include /* Header File For The OpenGL Library */ -#endif -#ifdef _SDL_CLEAR_GLEXT_HEADERGUARD -#undef __glext_h_ -#endif - -/** - * \file SDL_opengl.h - * - * This file is included because glext.h is not available on some systems. - * If you don't want this version included, simply define ::NO_SDL_GLEXT. - * - * The latest version is available from: - * http://www.opengl.org/registry/ - */ - /** * \def NO_SDL_GLEXT * @@ -76,9 +32,2142 @@ * version included in SDL_opengl.h. */ +#ifndef _SDL_opengl_h +#define _SDL_opengl_h + +#include "SDL_config.h" + +#ifndef __IPHONEOS__ /* No OpenGL on iOS. */ + +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +#if defined(USE_MGL_NAMESPACE) +#include "gl_mangle.h" +#endif + + +/********************************************************************** + * Begin system-specific stuff. + */ + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if defined(__WIN32__) && !defined(__CYGWIN__) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000FFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ #if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) #include "SDL_opengl_glext.h" -#endif /* NO_SDL_GLEXT */ +#endif /* GL_GLEXT_LEGACY */ + + + +/* + * ???. GL_MESA_packed_depth_stencil + * XXX obsolete + */ +#ifndef GL_MESA_packed_depth_stencil +#define GL_MESA_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_MESA 0x8750 +#define GL_UNSIGNED_INT_24_8_MESA 0x8751 +#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 +#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 +#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 + +#endif /* GL_MESA_packed_depth_stencil */ + + +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 + +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D + +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); + +#endif /* GL_ATI_blend_equation_separate */ + + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +/** + ** NOTE!!!!! If you add new functions to this file, or update + ** glext.h be sure to regenerate the gl_mangle.h file. See comments + ** in that file for details. + **/ + + + +/********************************************************************** + * Begin system-specific stuff + */ +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export off +#endif + +/* + * End system-specific stuff + **********************************************************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ #endif /* !__IPHONEOS__ */ From e12894a4997f4ac51943aa5f5a80ae60fc8862b4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Aug 2014 11:28:16 -0700 Subject: [PATCH 39/50] Fixed UV texture coordinate scale when using GL_ARB_texture_non_power_of_two --- src/render/opengl/SDL_shaders_gl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index d8f60d4a0..a831890ca 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -150,7 +150,7 @@ static const char *shader_source[NUM_SHADERS][2] = " yuv.x = texture2D(tex0, tcoord).r;\n" "\n" " // Get the U and V values \n" -" tcoord *= 0.5;\n" +" tcoord *= UVCoordScale;\n" " yuv.y = texture2D(tex1, tcoord).r;\n" " yuv.z = texture2D(tex2, tcoord).r;\n" "\n" @@ -201,7 +201,7 @@ static const char *shader_source[NUM_SHADERS][2] = " yuv.x = texture2D(tex0, tcoord).r;\n" "\n" " // Get the U and V values \n" -" tcoord *= 0.5;\n" +" tcoord *= UVCoordScale;\n" " yuv.yz = texture2D(tex1, tcoord).ra;\n" "\n" " // Do the color transform \n" @@ -251,7 +251,7 @@ static const char *shader_source[NUM_SHADERS][2] = " yuv.x = texture2D(tex0, tcoord).r;\n" "\n" " // Get the U and V values \n" -" tcoord *= 0.5;\n" +" tcoord *= UVCoordScale;\n" " yuv.yz = texture2D(tex1, tcoord).ar;\n" "\n" " // Do the color transform \n" @@ -318,7 +318,11 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) if (ctx->GL_ARB_texture_rectangle_supported) { frag_defines = "#define sampler2D sampler2DRect\n" -"#define texture2D texture2DRect\n"; +"#define texture2D texture2DRect\n" +"#define UVCoordScale 0.5\n"; + } else { + frag_defines = +"#define UVCoordScale 1.0\n"; } /* Create one program object to rule them all */ From 6473b279adffbaaf2775bdc357f0d2bed138b383 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Aug 2014 18:16:45 -0700 Subject: [PATCH 40/50] SDL - fix fullscreen desktop windows not restoring to fullscreen state if focus changes happen due to programtic window changes (and not user alt-tabbing) --- src/video/x11/SDL_x11events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 77471325f..2bfc2812f 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1073,7 +1073,8 @@ X11_DispatchEvent(_THIS) because they use the NETWM protocol to notify us of changes. */ Uint32 flags = X11_GetNetWMState(_this, xevent.xproperty.window); - if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) { + if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN || + (flags^data->window->flags) & SDL_WINDOW_FULLSCREEN ) { if (flags & SDL_WINDOW_HIDDEN) { X11_DispatchUnmapNotify(data); } else { From 179a0e565fe5494dac3a635181c6691f3b94da0a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Aug 2014 18:17:03 -0700 Subject: [PATCH 41/50] Fixed Mac OS X build --- include/SDL_opengl_glext.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/SDL_opengl_glext.h b/include/SDL_opengl_glext.h index d520a8acd..d59fc090d 100644 --- a/include/SDL_opengl_glext.h +++ b/include/SDL_opengl_glext.h @@ -465,8 +465,13 @@ GLAPI void APIENTRY glBlendEquation (GLenum mode); #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 #include +#ifdef __MACOSX__ +typedef ssize_t GLsizeiptr; +typedef ssize_t GLintptr; +#else typedef ptrdiff_t GLsizeiptr; typedef ptrdiff_t GLintptr; +#endif #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 From c1e53ee38c0b431c80a7976bd287af1a53ffce34 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 18 Aug 2014 18:44:08 -0700 Subject: [PATCH 42/50] Better Mac OS X build fix - actually match the SDK OpenGL headers. --- include/SDL_opengl_glext.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_opengl_glext.h b/include/SDL_opengl_glext.h index d59fc090d..7e840f72a 100644 --- a/include/SDL_opengl_glext.h +++ b/include/SDL_opengl_glext.h @@ -466,8 +466,8 @@ GLAPI void APIENTRY glBlendEquation (GLenum mode); #define GL_VERSION_1_5 1 #include #ifdef __MACOSX__ -typedef ssize_t GLsizeiptr; -typedef ssize_t GLintptr; +typedef long GLsizeiptr; +typedef long GLintptr; #else typedef ptrdiff_t GLsizeiptr; typedef ptrdiff_t GLintptr; From 755f4ad22e63191d29f29821935e737f9b18ce3b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Aug 2014 21:13:07 -0700 Subject: [PATCH 43/50] Fixed bug 2691 - Disabling shared library prevent cmake configuration hotgloupi Configuring using "cmake -DSDL_STATIC=1 -DSDL_SHARED=0" generate and error in CMakeLists.txt at line 1334: CMake Error at CMakeLists.txt:1334 (install): install TARGETS given target "SDL2" which does not exist in this directory. This install rule shouldn't be present when the DLL has been disabled --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fc2b396f..bbcb87b1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1331,7 +1331,9 @@ if(NOT WINDOWS OR CYGWIN) # TODO: what about the .spec file? Is it only needed for RPM creation? install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal") else() - install(TARGETS SDL2 RUNTIME DESTINATION bin) + if(SDL_SHARED) + install(TARGETS SDL2 RUNTIME DESTINATION bin) + endif() endif() ##### Uninstall target ##### From 4d4e7b1085ecfb22e27747032b9df03e5e722cf0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Aug 2014 21:17:21 -0700 Subject: [PATCH 44/50] Fixed bug 2694 - configure bug __has_feature macro not detected skaller using gcc 4.2 (the default) on Mac OSX 10.6.8 CC build/SDL_dynapi.lo In file included from /Users/johnskaller/SDL/src/dynapi/SDL_dynapi.c:31: include/SDL_syswm.h:211:39: error: missing binary operator before token "(" The fault appears to be here: #if defined(__OBJC__) && __has_feature(objc_arc) that the __has_feature macro is not supported by gcc 4.2. The code works fine with my clang 3.3svn. --- include/SDL_syswm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index c81cd48de..2f4d5a4f5 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -208,7 +208,7 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_COCOA) struct { -#if defined(__OBJC__) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__clang__) && __has_feature(objc_arc) NSWindow __unsafe_unretained *window; /* The Cocoa window */ #else NSWindow *window; /* The Cocoa window */ @@ -218,7 +218,7 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_UIKIT) struct { -#if defined(__OBJC__) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__clang__) && __has_feature(objc_arc) UIWindow __unsafe_unretained *window; /* The UIKit window */ #else UIWindow *window; /* The UIKit window */ From 64ba943a56a7594f1bf4224c182e44e1805a48e5 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Tue, 19 Aug 2014 22:28:53 +0100 Subject: [PATCH 45/50] Take the window border size into account when positioning the IBus candidate list. --- src/core/linux/SDL_ibus.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 9583b098c..3c4ff5c6f 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -22,10 +22,16 @@ #ifdef HAVE_IBUS_IBUS_H #include "SDL.h" +#include "SDL_syswm.h" #include "SDL_ibus.h" #include "SDL_dbus.h" #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" + +#if SDL_VIDEO_DRIVER_X11 + #include "../../video/x11/SDL_x11video.h" +#endif + #include #include #include @@ -545,9 +551,31 @@ SDL_IBus_UpdateTextRect(SDL_Rect *rect) SDL_Window *focused_win = SDL_GetFocusWindow(); if(!focused_win) return; - + + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + + if(!SDL_GetWindowWMInfo(focused_win, &info)) return; + int x = 0, y = 0; + SDL_GetWindowPosition(focused_win, &x, &y); + +#if SDL_VIDEO_DRIVER_X11 + if(info.subsystem == SDL_SYSWM_X11){ + SDL_DisplayData *displaydata = + (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; + + Display *x_disp = info.info.x11.display; + Window x_win = info.info.x11.window; + int x_screen = displaydata->screen; + Window unused; + + X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), + 0, 0, &x, &y, &unused); + } +#endif + x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; From 1d874154409317f93afaa86215b80fd53cef8550 Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Tue, 19 Aug 2014 23:17:28 +0100 Subject: [PATCH 46/50] Improvements to the IBus related code: + Handle HidePreeditText IBus signal. + Use SDL_GetKeyboardFocus instead of SDL_GetFocusWindow. + Move the X11 IBus SetFocus calls to the X11_DispatchFocus functions. + Simplify the IBus ifdefs when handling X11 KeyEvents. + Remove inotify watch when SDL_IBus_Quit is called. --- src/core/linux/SDL_ibus.c | 28 +++++++++++++++++++--------- src/video/x11/SDL_x11events.c | 31 +++++++++++-------------------- src/video/x11/SDL_x11keyboard.c | 4 +--- 3 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 3c4ff5c6f..bad75242f 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -45,7 +45,7 @@ static char *input_ctx_path = NULL; static SDL_Rect ibus_cursor_rect = {0}; static DBusConnection *ibus_conn = NULL; static char *ibus_addr_file = NULL; -int inotify_fd = -1; +int inotify_fd = -1, inotify_wd = -1; static Uint32 IBus_ModState(void) @@ -166,8 +166,6 @@ IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data) i += sz; cursor += chars; } - } else { - SDL_SendEditingText("", 0, 0); } SDL_IBus_UpdateTextRect(NULL); @@ -175,6 +173,11 @@ IBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data) return DBUS_HANDLER_RESULT_HANDLED; } + if(dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "HidePreeditText")){ + SDL_SendEditingText("", 0, 0); + return DBUS_HANDLER_RESULT_HANDLED; + } + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -360,7 +363,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) dbus->connection_flush(ibus_conn); } - SDL_IBus_SetFocus(SDL_GetFocusWindow() != NULL); + SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL); SDL_IBus_UpdateTextRect(NULL); return result; @@ -375,7 +378,7 @@ IBus_CheckConnection(SDL_DBusContext *dbus) return SDL_TRUE; } - if(inotify_fd != -1){ + if(inotify_fd > 0 && inotify_wd > 0){ char buf[1024]; ssize_t readsize = read(inotify_fd, buf, sizeof(buf)); if(readsize > 0){ @@ -428,15 +431,17 @@ SDL_IBus_Init(void) char *addr = IBus_ReadAddressFromFile(addr_file); - inotify_fd = inotify_init(); - fcntl(inotify_fd, F_SETFL, O_NONBLOCK); + if(inotify_fd < 0){ + inotify_fd = inotify_init(); + fcntl(inotify_fd, F_SETFL, O_NONBLOCK); + } char *addr_file_dir = SDL_strrchr(addr_file, '/'); if(addr_file_dir){ *addr_file_dir = 0; } - inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY); + inotify_wd = inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY); SDL_free(addr_file); result = IBus_SetupConnection(dbus, addr); @@ -466,6 +471,11 @@ SDL_IBus_Quit(void) dbus->connection_unref(ibus_conn); } + if(inotify_fd > 0 && inotify_wd > 0){ + inotify_rm_watch(inotify_fd, inotify_wd); + inotify_wd = -1; + } + SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); } @@ -548,7 +558,7 @@ SDL_IBus_UpdateTextRect(SDL_Rect *rect) SDL_memcpy(&ibus_cursor_rect, rect, sizeof(ibus_cursor_rect)); } - SDL_Window *focused_win = SDL_GetFocusWindow(); + SDL_Window *focused_win = SDL_GetKeyboardFocus(); if(!focused_win) return; diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 2bfc2812f..c67fc38e3 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -347,6 +347,9 @@ X11_DispatchFocusIn(SDL_WindowData *data) X11_XSetICFocus(data->ic); } #endif +#ifdef SDL_USE_IBUS + SDL_IBus_SetFocus(SDL_TRUE); +#endif } static void @@ -367,6 +370,9 @@ X11_DispatchFocusOut(SDL_WindowData *data) X11_XUnsetICFocus(data->ic); } #endif +#ifdef SDL_USE_IBUS + SDL_IBus_SetFocus(SDL_FALSE); +#endif } static void @@ -646,11 +652,6 @@ X11_DispatchEvent(_THIS) } #ifdef DEBUG_XEVENTS printf("window %p: FocusIn!\n", data); -#endif -#ifdef SDL_USE_IBUS - if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){ - SDL_IBus_SetFocus(SDL_TRUE); - } #endif if (data->pending_focus == PENDING_FOCUS_OUT && data->window == SDL_GetKeyboardFocus()) { @@ -688,11 +689,6 @@ X11_DispatchEvent(_THIS) } #ifdef DEBUG_XEVENTS printf("window %p: FocusOut!\n", data); -#endif -#ifdef SDL_USE_IBUS - if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){ - SDL_IBus_SetFocus(SDL_FALSE); - } #endif data->pending_focus = PENDING_FOCUS_OUT; data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_OUT_TIME; @@ -725,16 +721,11 @@ X11_DispatchEvent(_THIS) KeySym keysym = NoSymbol; char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; Status status = 0; -#ifdef SDL_USE_IBUS - Bool handled = False; -#endif + SDL_bool handled_by_ime = SDL_FALSE; #ifdef DEBUG_XEVENTS printf("window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode); #endif -#ifndef SDL_USE_IBUS - SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); -#endif #if 1 if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) { int min_keycode, max_keycode; @@ -762,7 +753,7 @@ X11_DispatchEvent(_THIS) #endif #ifdef SDL_USE_IBUS if(SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE){ - if(!(handled = SDL_IBus_ProcessKeyEvent(keysym, keycode))){ + if(!(handled_by_ime = SDL_IBus_ProcessKeyEvent(keysym, keycode))){ #endif if(*text){ SDL_SendKeyboardText(text); @@ -770,11 +761,11 @@ X11_DispatchEvent(_THIS) #ifdef SDL_USE_IBUS } } - - if (!handled) { +#endif + if (!handled_by_ime) { SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); } -#endif + } break; diff --git a/src/video/x11/SDL_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 7ac7d7c62..53866ab55 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -332,9 +332,7 @@ X11_QuitKeyboard(_THIS) void X11_StartTextInput(_THIS) { -#ifdef SDL_USE_IBUS - SDL_IBus_SetFocus(SDL_GetFocusWindow() != NULL); -#endif + } void From 417f3be8cdacc2001f332b13c12cd87e263ec10b Mon Sep 17 00:00:00 2001 From: Alex Baines Date: Tue, 19 Aug 2014 23:31:50 +0100 Subject: [PATCH 47/50] Add a SDL_IM_INTERNAL_EDITING event to make IMs like iBus render editing text in its own UI instead of sending TEXTEDITING events. This is useful for applications that handle TEXTINPUT events but not TEXTEDITING events. --- include/SDL_hints.h | 12 +++++++++ src/core/linux/SDL_ibus.c | 57 +++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index e0fce669f..b1feef660 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -477,6 +477,18 @@ extern "C" { */ #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION" +/** + * \brief A variable to control whether certain IMs should handle text editing internally instead of sending TEXTEDITING events. + * + * + * The variable can be set to the following values: + * "0" - TEXTEDITING events are sent, and it is the application's + * responsibility to render the text from these events and + * differentiate it somehow from committed text. (default) + * "1" - If supported by the IM then TEXTEDITING events are not sent, + * and text that is being composed will be rendered in its own UI. + */ +#define SDL_HINT_IM_INTERNAL_EDITING "SDL_IM_INTERNAL_EDITING" /** * \brief An enumeration of hint priorities diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index bad75242f..203a12368 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -288,6 +288,41 @@ IBus_GetDBusAddressFilename(void) return SDL_strdup(file_path); } +static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus); + +static void +IBus_SetCapabilities(void *data, const char *name, const char *old_val, + const char *internal_editing) +{ + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + + if(IBus_CheckConnection(dbus)){ + + DBusMessage *msg = dbus->message_new_method_call(IBUS_SERVICE, + input_ctx_path, + IBUS_INPUT_INTERFACE, + "SetCapabilities"); + if(msg){ + Uint32 caps = IBUS_CAP_FOCUS; + if(!(internal_editing && *internal_editing == '1')){ + caps |= IBUS_CAP_PREEDIT_TEXT; + } + + dbus->message_append_args(msg, + DBUS_TYPE_UINT32, &caps, + DBUS_TYPE_INVALID); + } + + if(msg){ + if(dbus->connection_send(ibus_conn, msg, NULL)){ + dbus->connection_flush(ibus_conn); + } + dbus->message_unref(msg); + } + } +} + + static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) { @@ -340,23 +375,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) } if(result){ - msg = dbus->message_new_method_call(IBUS_SERVICE, - input_ctx_path, - IBUS_INPUT_INTERFACE, - "SetCapabilities"); - if(msg){ - Uint32 caps = IBUS_CAP_FOCUS | IBUS_CAP_PREEDIT_TEXT; - dbus->message_append_args(msg, - DBUS_TYPE_UINT32, &caps, - DBUS_TYPE_INVALID); - } - - if(msg){ - if(dbus->connection_send(ibus_conn, msg, NULL)){ - dbus->connection_flush(ibus_conn); - } - dbus->message_unref(msg); - } + SDL_AddHintCallback(SDL_HINT_IM_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL); dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL); @@ -476,6 +495,8 @@ SDL_IBus_Quit(void) inotify_wd = -1; } + SDL_DelHintCallback(SDL_HINT_IM_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); + SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); } @@ -548,6 +569,8 @@ SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode) } + SDL_IBus_UpdateTextRect(NULL); + return result; } From c34f97dd89a3cb2967fe566d9d8000dbe61d247c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Aug 2014 21:59:56 -0700 Subject: [PATCH 48/50] Changed the name of the IME hint to match the naming convention in SDL --- include/SDL_hints.h | 2 +- src/core/linux/SDL_ibus.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index b1feef660..5c9185e22 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -488,7 +488,7 @@ extern "C" { * "1" - If supported by the IM then TEXTEDITING events are not sent, * and text that is being composed will be rendered in its own UI. */ -#define SDL_HINT_IM_INTERNAL_EDITING "SDL_IM_INTERNAL_EDITING" +#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" /** * \brief An enumeration of hint priorities diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 203a12368..2a538b1b1 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -375,7 +375,7 @@ IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) } if(result){ - SDL_AddHintCallback(SDL_HINT_IM_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); + SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL); dbus->connection_add_filter(ibus_conn, &IBus_MessageFilter, dbus, NULL); @@ -495,7 +495,7 @@ SDL_IBus_Quit(void) inotify_wd = -1; } - SDL_DelHintCallback(SDL_HINT_IM_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); + SDL_DelHintCallback(SDL_HINT_IME_INTERNAL_EDITING, &IBus_SetCapabilities, NULL); SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); } From 13c9e77b67f199f9f4d5663ea9786ea7b1ce2733 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Aug 2014 22:04:54 -0700 Subject: [PATCH 49/50] Better check for __has_feature --- include/SDL_syswm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_syswm.h b/include/SDL_syswm.h index 2f4d5a4f5..3b5ac50fd 100644 --- a/include/SDL_syswm.h +++ b/include/SDL_syswm.h @@ -208,7 +208,7 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_COCOA) struct { -#if defined(__OBJC__) && defined(__clang__) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) NSWindow __unsafe_unretained *window; /* The Cocoa window */ #else NSWindow *window; /* The Cocoa window */ @@ -218,7 +218,7 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_UIKIT) struct { -#if defined(__OBJC__) && defined(__clang__) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) UIWindow __unsafe_unretained *window; /* The UIKit window */ #else UIWindow *window; /* The UIKit window */ From 9efa4ff286db2ab99a6c969f5aba59cd01a48f8f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 20 Aug 2014 01:21:45 -0400 Subject: [PATCH 50/50] Fixed the cmake-guided static analysis and use it by default. The configure script fails on it on Mac OS X, now, for whatever reason. Hopefully gets our static analysis buildslave running again! --HG-- extra : rebase_source : 57f2c5512c5be3b7233132c9ec5d0bb1cbd86c6c --- build-scripts/checker-buildbot.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-scripts/checker-buildbot.sh b/build-scripts/checker-buildbot.sh index 4ecce6154..682e7fbbb 100755 --- a/build-scripts/checker-buildbot.sh +++ b/build-scripts/checker-buildbot.sh @@ -61,13 +61,13 @@ mkdir checker-buildbot cd checker-buildbot # You might want to do this for CMake-backed builds instead... -#cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER="$CHECKERDIR/libexec/ccc-analyzer" .. +PATH="$CHECKERDIR:$PATH" scan-build -o analysis cmake -DCMAKE_BUILD_TYPE=Debug .. # ...or run configure without the scan-build wrapper... #CC="$CHECKERDIR/libexec/ccc-analyzer" CFLAGS="-O0" ../configure -# ...but this works for our buildbots just fine. -CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure +# ...but this works for our buildbots just fine (EXCEPT ON LATEST MAC OS X). +#CFLAGS="-O0" PATH="$CHECKERDIR:$PATH" scan-build -o analysis ../configure rm -rf analysis PATH="$CHECKERDIR:$PATH" scan-build -o analysis $MAKE