From b2e76d860f53d94f8a983963919fae7ab8d312ab Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 19 Mar 2019 16:52:09 -0700 Subject: [PATCH] Fixed Windows RT build --- src/core/winrt/SDL_winrtapp_common.cpp | 1 + src/cpuinfo/SDL_cpuinfo.c | 2 +- src/render/SDL_render.c | 4 ++-- src/render/direct3d/SDL_render_d3d.c | 4 ++-- src/render/direct3d11/SDL_render_d3d11.c | 4 ++-- src/render/opengl/SDL_render_gl.c | 4 ++-- src/render/opengles/SDL_render_gles.c | 4 ++-- src/render/opengles2/SDL_render_gles2.c | 4 ++-- src/render/psp/SDL_render_psp.c | 4 ++-- src/render/software/SDL_render_sw.c | 4 ++-- src/thread/windows/SDL_systhread.c | 1 + src/thread/windows/SDL_systls.c | 7 +++++++ src/video/SDL_bmp.c | 4 ++-- 13 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/core/winrt/SDL_winrtapp_common.cpp b/src/core/winrt/SDL_winrtapp_common.cpp index cee2a2bfb..b35300ccf 100644 --- a/src/core/winrt/SDL_winrtapp_common.cpp +++ b/src/core/winrt/SDL_winrtapp_common.cpp @@ -20,6 +20,7 @@ */ #include "../../SDL_internal.h" +#include "SDL_main.h" #include "SDL_system.h" #include "SDL_winrtapp_direct3d.h" #include "SDL_winrtapp_xaml.h" diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index e17cd4af4..7c050940b 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -25,7 +25,7 @@ #include "SDL_simd.h" #endif -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINRT__) #include "../core/windows/SDL_windows.h" #endif #if defined(__OS2__) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 85d4d691f..81f92969f 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1188,7 +1188,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) const SDL_PixelFormat *fmt; SDL_bool needAlpha; SDL_bool direct_update; - Uint32 i; + int i; Uint32 format; SDL_Texture *texture; @@ -1219,7 +1219,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) } format = renderer->info.texture_formats[0]; - for (i = 0; i < renderer->info.num_texture_formats; ++i) { + for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) { if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { format = renderer->info.texture_formats[i]; diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index a564a1571..4b7618c02 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -791,7 +791,7 @@ D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b); const size_t vertslen = count * sizeof (Vertex); Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -815,7 +815,7 @@ D3D_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FR const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b); const size_t vertslen = count * sizeof (Vertex) * 4; Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 38ac943df..c4345eb9c 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -1559,7 +1559,7 @@ D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL const float g = (float)(cmd->data.draw.g / 255.0f); const float b = (float)(cmd->data.draw.b / 255.0f); const float a = (float)(cmd->data.draw.a / 255.0f); - size_t i; + int i; if (!verts) { return -1; @@ -1591,7 +1591,7 @@ D3D11_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ const float g = (float)(cmd->data.draw.g / 255.0f); const float b = (float)(cmd->data.draw.b / 255.0f); const float a = (float)(cmd->data.draw.a / 255.0f); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index f0a5d9cee..a32ac6e5b 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -805,7 +805,7 @@ static int GL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -824,7 +824,7 @@ static int GL_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 4 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 7dc32ca95..95c8bb9ab 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -533,7 +533,7 @@ static int GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -552,7 +552,7 @@ static int GLES_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 8 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index cfc2708c4..b77779daa 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -766,7 +766,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -785,7 +785,7 @@ static int GLES2_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) { GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 8 * sizeof (GLfloat), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 4f6faec3e..15cbd2427 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -444,7 +444,7 @@ static int PSP_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) { VertV *verts = (VertV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertV), 4, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -465,7 +465,7 @@ static int PSP_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) { VertV *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertV), 4, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 570e0ed1d..8c4820128 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -190,7 +190,7 @@ static int SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) { SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; @@ -219,7 +219,7 @@ static int SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) { SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first); - size_t i; + int i; if (!verts) { return -1; diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 3e1375bd3..2824969aa 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -29,6 +29,7 @@ #include "../SDL_thread_c.h" #include "../SDL_systhread.h" #include "SDL_systhread_c.h" +#include "../../core/windows/SDL_windows.h" #ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD /* We'll use the C library from this DLL */ diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c index 9d8b0479d..efe9f669c 100644 --- a/src/thread/windows/SDL_systls.c +++ b/src/thread/windows/SDL_systls.c @@ -28,6 +28,13 @@ #include "SDL_thread.h" #include "../SDL_thread_c.h" +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#define TLS_OUT_OF_INDEXES FLS_OUT_OF_INDEXES +#define TlsAlloc() FlsAlloc(NULL) +#define TlsSetValue FlsSetValue +#define TlsGetValue FlsGetValue +#endif + static DWORD thread_local_storage = TLS_OUT_OF_INDEXES; static SDL_bool generic_local_storage = SDL_FALSE; diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index c676cc077..0b68918cc 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -321,7 +321,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) SDL_assert(biBitCount <= 8); if (biClrUsed == 0) { biClrUsed = 1 << biBitCount; - } else if (biClrUsed > (1 << biBitCount)) { + } else if (biClrUsed > (Uint32)(1 << biBitCount)) { SDL_SetError("BMP file has an invalid number of colors"); was_error = SDL_TRUE; goto done; @@ -423,7 +423,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) was_error = SDL_TRUE; goto done; } - if (biBitCount == 8 && palette && biClrUsed < (1 << biBitCount)) { + if (biBitCount == 8 && palette && biClrUsed < (Uint32)(1 << biBitCount)) { for (i = 0; i < surface->w; ++i) { if (bits[i] >= biClrUsed) { SDL_SetError("A BMP image contains a pixel with a color out of the palette");