Commit c8eea02071f9106f74e7cbb2d3ae71b42afabad4

Cameron Cawley 2022-05-18T21:14:20

Fix C89 build errors in Windows builds

diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 477f4e9..51f6c77 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1079,7 +1079,13 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
 
     if (data->drawstate.viewport_dirty) {
         const SDL_Rect *viewport = &data->drawstate.viewport;
-        const D3DVIEWPORT9 d3dviewport = { viewport->x, viewport->y, viewport->w, viewport->h, 0.0f, 1.0f };
+        D3DVIEWPORT9 d3dviewport;
+        d3dviewport.X = viewport->x;
+        d3dviewport.Y = viewport->y;
+        d3dviewport.Width = viewport->w;
+        d3dviewport.Height = viewport->h;
+        d3dviewport.MinZ = 0.0f;
+        d3dviewport.MaxZ = 1.0f;
         IDirect3DDevice9_SetViewport(data->device, &d3dviewport);
 
         /* Set an orthographic projection matrix */
@@ -1106,7 +1112,11 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
     if (data->drawstate.cliprect_dirty) {
         const SDL_Rect *viewport = &data->drawstate.viewport;
         const SDL_Rect *rect = &data->drawstate.cliprect;
-        const RECT d3drect = { viewport->x + rect->x, viewport->y + rect->y, viewport->x + rect->x + rect->w, viewport->y + rect->y + rect->h };
+        RECT d3drect;
+        d3drect.left = viewport->x + rect->x;
+        d3drect.top = viewport->y + rect->y;
+        d3drect.right = viewport->x + rect->x + rect->w;
+        d3drect.bottom = viewport->y + rect->y + rect->h;
         IDirect3DDevice9_SetScissorRect(data->device, &d3drect);
         data->drawstate.cliprect_dirty = SDL_FALSE;
     }
@@ -1221,7 +1231,9 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
                     IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
                 } else {
                     /* Clear is defined to clear the entire render target */
-                    const D3DVIEWPORT9 wholeviewport = { 0, 0, backw, backh, 0.0f, 1.0f };
+                    D3DVIEWPORT9 wholeviewport = { 0, 0, 0, 0, 0.0f, 1.0f };
+                    wholeviewport.Width = backw;
+                    wholeviewport.Height = backh;
                     IDirect3DDevice9_SetViewport(data->device, &wholeviewport);
                     data->drawstate.viewport_dirty = SDL_TRUE;  /* we still need to (re)set orthographic projection, so always mark it dirty. */
                     IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0);
diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c
index e62fe99..ce9a213 100644
--- a/src/video/SDL_egl.c
+++ b/src/video/SDL_egl.c
@@ -1250,10 +1250,12 @@ EGLSurface
 SDL_EGL_CreateOffscreenSurface(_THIS, int width, int height)
 {
     EGLint attributes[] = {
-        EGL_WIDTH, width,
-        EGL_HEIGHT, height,
+        EGL_WIDTH, 0,
+        EGL_HEIGHT, 0,
         EGL_NONE
     };
+    attributes[1] = width;
+    attributes[3] = height;
 
     if (SDL_EGL_ChooseConfig(_this) != 0) {
         return EGL_NO_SURFACE;
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index cf6a7c5..084bb9a 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -1371,10 +1371,15 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         {
             SDL_Window *window = data->window;
             if (window->hit_test) {
-                POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+                POINT winpoint;
+                winpoint.x = GET_X_LPARAM(lParam);
+                winpoint.y = GET_Y_LPARAM(lParam);
                 if (ScreenToClient(hwnd, &winpoint)) {
-                    const SDL_Point point = { (int) winpoint.x, (int) winpoint.y };
-                    const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
+                    SDL_Point point;
+                    SDL_HitTestResult rc;
+                    point.x = winpoint.x;
+                    point.y = winpoint.y;
+                    rc = window->hit_test(window, &point, window->hit_test_data);
                     switch (rc) {
                         #define POST_HIT_TEST(ret) { SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); return ret; }
                         case SDL_HITTEST_DRAGGABLE: POST_HIT_TEST(HTCAPTION);