Skip to content

Commit af4959a

Browse files
committed
xrEngine: implement splash on linux
1 parent 3efd515 commit af4959a

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

src/xrEngine/splash.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,29 @@
22
#include "xr_3da/resource.h"
33
#include "splash.h"
44

5+
#if defined(WINDOWS)
56
HWND logoWindow = nullptr;
7+
#else
8+
SDL_Window* logoWindow = nullptr;
9+
SDL_Renderer *logoRenderer;
10+
#endif
611

12+
#if defined(WINDOWS)
713
static INT_PTR CALLBACK LogoWndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp)
814
{
915
switch (msg)
1016
{
11-
#if defined(WINDOWS)
1217
case WM_DESTROY: break;
1318
case WM_CLOSE: DestroyWindow(hw); break;
1419
case WM_COMMAND:
1520
if (LOWORD(wp) == IDCANCEL)
1621
DestroyWindow(hw);
1722
break;
18-
#endif
1923
default: return false;
2024
}
2125
return true;
2226
}
27+
#endif
2328

2429
namespace splash
2530
{
@@ -36,6 +41,28 @@ void show(const bool topmost)
3641
SetWindowPos(logoWindow, prevWindow, 0, 0, logoRect.right - logoRect.left, logoRect.bottom - logoRect.top,
3742
SWP_NOMOVE | SWP_SHOWWINDOW);
3843
UpdateWindow(logoWindow);
44+
#else
45+
SDL_CreateWindowAndRenderer(320, 240, SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN, &logoWindow, &logoRenderer);
46+
47+
SDL_Surface *surface = SDL_LoadBMP("logo.bmp"); // need placed logo.bmp beside of fsgame.ltx
48+
if (!surface) {
49+
Msg("Couldn't create surface from image: %s", SDL_GetError());
50+
return;
51+
}
52+
53+
SDL_Rect rect;
54+
SDL_GetClipRect(surface, &rect);
55+
SDL_SetWindowSize(logoWindow, rect.w, rect.h);
56+
SDL_Texture *texture = SDL_CreateTextureFromSurface(logoRenderer, surface);
57+
SDL_FreeSurface(surface);
58+
SDL_ShowWindow(logoWindow);
59+
60+
SDL_SetRenderDrawColor(logoRenderer, 0x00, 0x00, 0x00, 0x00);
61+
SDL_RenderClear(logoRenderer);
62+
SDL_RenderCopy(logoRenderer, texture, NULL, NULL);
63+
SDL_RenderPresent(logoRenderer);
64+
SDL_UpdateWindowSurface(logoWindow);
65+
3966
#endif
4067
}
4168

@@ -45,6 +72,8 @@ void hide()
4572
{
4673
#if defined(WINDOWS)
4774
DestroyWindow(logoWindow);
75+
#else
76+
SDL_DestroyWindow(logoWindow);
4877
#endif
4978
logoWindow = nullptr;
5079
}

0 commit comments

Comments
 (0)