SDL2: Implement cross platform splash screen

--HG--
branch : sdl2
hg/feature/sdl2
kaetemi 11 years ago
parent 72655cd71b
commit 7223a4d208

@ -78,6 +78,7 @@ IF(APPLE)
ENDIF(APPLE)
INCLUDE_DIRECTORIES(
${SDL2_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
@ -97,6 +98,7 @@ TARGET_LINK_LIBRARIES(ryzom_client
ryzom_clientsheets
ryzom_gameshare
nelpacs
${SDL2_LIBRARY}
${LIBXML2_LIBRARIES}
${LUA_LIBRARIES}
${LUABIND_LIBRARIES}

@ -32,6 +32,8 @@
#include <csignal>
#endif
#include <SDL.h>
#ifdef NL_OS_MAC
#include <stdio.h>
#include <sys/resource.h>
@ -119,6 +121,41 @@ static void sigHandler(int Sig)
}
#endif
extern const unsigned char splash_screen[];
extern const unsigned int splash_screenSize;
SDL_Window *s_SplashScreen = NULL;
SDL_Renderer *s_SplashRenderer = NULL;
void createSplashScreen()
{
SDL_RWops *rw = SDL_RWFromMem(const_cast<void *>((const void *)splash_screen), splash_screenSize);
SDL_Surface *surf = SDL_LoadBMP_RW(rw, 1); // 1 releases rw stream on surface free
s_SplashScreen = SDL_CreateWindow("Ryzom Core", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 435, 362, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);
s_SplashRenderer = SDL_CreateRenderer(s_SplashScreen, -1, SDL_RENDERER_SOFTWARE);
SDL_Texture *tex = SDL_CreateTextureFromSurface(s_SplashRenderer, surf);
SDL_FreeSurface(surf);
SDL_RenderCopy(s_SplashRenderer, tex, NULL, NULL);
SDL_RenderPresent(s_SplashRenderer);
SDL_DestroyTexture(tex);
}
void pumpSplashScreen()
{
SDL_PumpEvents();
SDL_RenderPresent(s_SplashRenderer);
}
void destroySplashScreen()
{
if (s_SplashScreen)
{
SDL_DestroyRenderer(s_SplashRenderer);
s_SplashRenderer = NULL;
SDL_DestroyWindow(s_SplashScreen);
s_SplashScreen = NULL;
}
}
//---------------------------------------------------
// MAIN :
// Entry for the Application.
@ -361,6 +398,11 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR cm
int main(int argc, char **argv)
#endif
{
// TODO: Test new splash screen on Windows
#ifndef NL_OS_WINDOW
createSplashScreen();
#endif
// init the Nel context
CApplicationContext *appContext = new CApplicationContext;
@ -519,7 +561,7 @@ int main(int argc, char **argv)
#else
// TODO for Linux : splashscreen
pumpSplashScreen();
if (argc >= 4)
{

@ -105,6 +105,8 @@
#include <windows.h>
extern HINSTANCE HInstance;
extern HWND SlashScreen;
#else
void destroySplashScreen();
#endif // NL_OS_WINDOWS
#include "app_bundle_utils.h"
@ -944,6 +946,10 @@ void prelogInit()
if (SlashScreen)
DestroyWindow (SlashScreen);
#else
destroySplashScreen();
#endif // NL_OS_WINDOW
// Set the title

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
ADD_SUBDIRECTORY(bin2c)

@ -0,0 +1,10 @@
FILE(GLOB SRC *.cpp *.h)
ADD_EXECUTABLE(bin2c ${SRC})
TARGET_LINK_LIBRARIES(bin2c)
NL_DEFAULT_PROPS(bin2c "NeL, Tools: bin2c")
NL_ADD_RUNTIME_FLAGS(bin2c)
INSTALL(TARGETS bin2c RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT toolsmisc)
Loading…
Cancel
Save