浏览代码

SDL2: touch overlay support

Wei Mingzhi 10 年之前
父节点
当前提交
3a0121f001
共有 1 个文件被更改,包括 20 次插入4 次删除
  1. 20 4
      video.c

+ 20 - 4
video.c

@@ -282,6 +282,12 @@ VIDEO_Shutdown(
 
 
 #if SDL_VERSION_ATLEAST(2,0,0)
 #if SDL_VERSION_ATLEAST(2,0,0)
 
 
+   if (gpTouchOverlay)
+   {
+      SDL_DestroyTexture(gpTouchOverlay);
+   }
+   gpTouchOverlay = NULL;
+
    if (gpRenderer)
    if (gpRenderer)
    {
    {
       SDL_DestroyRenderer(gpRenderer);
       SDL_DestroyRenderer(gpRenderer);
@@ -340,6 +346,11 @@ VIDEO_UpdateScreen(
          dstrect.h = (WORD)((DWORD)(lpRect->h) * viewport.h / gpScreen->h);
          dstrect.h = (WORD)((DWORD)(lpRect->h) * viewport.h / gpScreen->h);
 
 
          SDL_RenderCopy(gpRenderer, pTexture, lpRect, &dstrect);
          SDL_RenderCopy(gpRenderer, pTexture, lpRect, &dstrect);
+
+         if (gpTouchOverlay)
+         {
+            SDL_RenderCopy(gpRenderer, gpTouchOverlay, lpRect, &dstrect);
+         }
       }
       }
       else if (g_wShakeTime != 0)
       else if (g_wShakeTime != 0)
       {
       {
@@ -370,15 +381,20 @@ VIDEO_UpdateScreen(
 
 
           SDL_RenderClear(gpRenderer);
           SDL_RenderClear(gpRenderer);
           SDL_RenderCopy(gpRenderer, pTexture, &srcrect, &dstrect);
           SDL_RenderCopy(gpRenderer, pTexture, &srcrect, &dstrect);
+          if (gpTouchOverlay)
+          {
+             SDL_RenderCopy(gpRenderer, gpTouchOverlay, NULL, NULL);
+          }
+
           g_wShakeTime--;
           g_wShakeTime--;
       }
       }
       else
       else
       {
       {
          SDL_RenderCopy(gpRenderer, pTexture, NULL, NULL);
          SDL_RenderCopy(gpRenderer, pTexture, NULL, NULL);
-      }
-      if (gpTouchOverlay)
-      {
-         SDL_RenderCopy(gpRenderer, gpTouchOverlay, NULL, NULL);
+         if (gpTouchOverlay)
+         {
+            SDL_RenderCopy(gpRenderer, gpTouchOverlay, NULL, NULL);
+         }
       }
       }
       SDL_RenderPresent(gpRenderer);
       SDL_RenderPresent(gpRenderer);
       SDL_DestroyTexture(pTexture);
       SDL_DestroyTexture(pTexture);