Skip to content

Commit

Permalink
xrEngine: implement splash on linux
Browse files Browse the repository at this point in the history
eagleivg committed Nov 6, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3efd515 commit af4959a
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/xrEngine/splash.cpp
Original file line number Diff line number Diff line change
@@ -2,24 +2,29 @@
#include "xr_3da/resource.h"
#include "splash.h"

#if defined(WINDOWS)
HWND logoWindow = nullptr;
#else
SDL_Window* logoWindow = nullptr;
SDL_Renderer *logoRenderer;
#endif

#if defined(WINDOWS)
static INT_PTR CALLBACK LogoWndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
{
switch (msg)
{
#if defined(WINDOWS)
case WM_DESTROY: break;
case WM_CLOSE: DestroyWindow(hw); break;
case WM_COMMAND:
if (LOWORD(wp) == IDCANCEL)
DestroyWindow(hw);
break;
#endif
default: return false;
}
return true;
}
#endif

namespace splash
{
@@ -36,6 +41,28 @@ void show(const bool topmost)
SetWindowPos(logoWindow, prevWindow, 0, 0, logoRect.right - logoRect.left, logoRect.bottom - logoRect.top,
SWP_NOMOVE | SWP_SHOWWINDOW);
UpdateWindow(logoWindow);
#else
SDL_CreateWindowAndRenderer(320, 240, SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN, &logoWindow, &logoRenderer);

SDL_Surface *surface = SDL_LoadBMP("logo.bmp"); // need placed logo.bmp beside of fsgame.ltx
if (!surface) {
Msg("Couldn't create surface from image: %s", SDL_GetError());
return;
}

SDL_Rect rect;
SDL_GetClipRect(surface, &rect);
SDL_SetWindowSize(logoWindow, rect.w, rect.h);
SDL_Texture *texture = SDL_CreateTextureFromSurface(logoRenderer, surface);
SDL_FreeSurface(surface);
SDL_ShowWindow(logoWindow);

SDL_SetRenderDrawColor(logoRenderer, 0x00, 0x00, 0x00, 0x00);
SDL_RenderClear(logoRenderer);
SDL_RenderCopy(logoRenderer, texture, NULL, NULL);
SDL_RenderPresent(logoRenderer);
SDL_UpdateWindowSurface(logoWindow);

#endif
}

@@ -45,6 +72,8 @@ void hide()
{
#if defined(WINDOWS)
DestroyWindow(logoWindow);
#else
SDL_DestroyWindow(logoWindow);
#endif
logoWindow = nullptr;
}

0 comments on commit af4959a

Please sign in to comment.