OSDN Git Service

Surface から Texture へのグラフィックリソース移行中。 In moving of graphic resource from Surface to...
authorDeskull <desull@users.sourceforge.jp>
Sun, 11 Jan 2015 06:36:43 +0000 (15:36 +0900)
committerDeskull <desull@users.sourceforge.jp>
Sun, 11 Jan 2015 06:36:43 +0000 (15:36 +0900)
Deeangband/GameSurfaceSDL.cpp
Deeangband/GameSurfaceSDL.h

index 572e7c8..fe78943 100644 (file)
@@ -80,7 +80,8 @@ namespace Deeangband
 
        void GameSurfaceSDL::fpsProcess()
        {
-               SDL_Rect windowRect = {0, 0, 120, 20};
+               SDL_Rect windowRect = {0, 0, 60, 10};
+               SDL_Surface *surface;
                char fpsBuf[12];
         int getTicks;
         int i;
@@ -96,10 +97,12 @@ namespace Deeangband
                        frameTimeLast = getTicks;
                        framesPerSecond = 1000.f * FPS_UPDATE / frameTime;
                        sprintf_s(fpsBuf, 12, "fps:%d", framesPerSecond); 
-                       fpsSurface = TTF_RenderUTF8_Blended(fontSmall, fpsBuf, color);
+                       surface = TTF_RenderUTF8_Blended(fontSmall, fpsBuf, color);
+                       fpsTexture = SDL_CreateTextureFromSurface(renderer, surface);
+                       SDL_FreeSurface(surface);
                }
 
-               SDL_BlitSurface(fpsSurface, &windowRect, windowSurface, &windowRect); 
+               SDL_RenderCopy(renderer, fpsTexture, NULL, &windowRect); 
 
        }
 
@@ -222,9 +225,8 @@ namespace Deeangband
                SDL_RenderClear(renderer);
 
                SDL_GetWindowSize(window, &rect.w, &rect.h);
-               SDL_SetRenderDrawColor(renderer, 50, 50, 0, 255);
+               SDL_SetRenderDrawColor(renderer, 50, 20, 0, 255);
                SDL_FillRect(windowSurface, &rect, SDL_MapRGBA(windowSurface->format, 50, 20, 10, 255));
-               //SDL_RenderCopy(renderer, titleTexture, &rectTitleSrc, &rectTitleDst); 
                SDL_RenderCopy(renderer, titleTexture, &rectTitleSrc, &rectTitleDst); 
 
                if(this->viewFieldPtr)
@@ -247,7 +249,6 @@ namespace Deeangband
                this->fpsProcess();
                SDL_Delay(16 - frameDeltaTime > 0 ? 16 - frameDeltaTime : 0);
 
-
 //             SDL_UpdateWindowSurfaceRects(window, &rect, 1);
 //             SDL_UpdateWindowSurface(window);
                SDL_RenderPresent(renderer);
index 0f89b41..a4d5772 100644 (file)
@@ -67,7 +67,7 @@ namespace Deeangband
                SDL_Surface *creatureStatusSurface;  //!< \83N\83\8a\81[\83`\83\83\81[\83X\83e\81[\83^\83X\95\\8e¦\82ÌSurface\8eQ\8fÆ
                SDL_Surface *creatureSideStatusSurface;  //!< \83T\83C\83h\83N\83\8a\81[\83`\83\83\81[\83X\83e\81[\83^\83X\95\\8e¦\82ÌSurface\8eQ\8fÆ
                SDL_Surface *gameTimeStatusSurface;  //!< \83Q\81[\83\80\8e\9e\8aÔ\95\\8e¦\82ÌSurface\8eQ\8fÆ
-               SDL_Surface *fpsSurface;
+               SDL_Texture *fpsTexture;
 
 
                std::map<TAG, SDL_Surface*> floorSurfaces; //!< \83t\83\8d\83A\83O\83\89\83t\83B\83b\83N\82ÌSurface\8eQ\8fÆ\83\8a\83X\83g