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) ENDIF(APPLE)
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${SDL2_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
${LIBXML2_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}
${LUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}
@ -97,6 +98,7 @@ TARGET_LINK_LIBRARIES(ryzom_client
ryzom_clientsheets ryzom_clientsheets
ryzom_gameshare ryzom_gameshare
nelpacs nelpacs
${SDL2_LIBRARY}
${LIBXML2_LIBRARIES} ${LIBXML2_LIBRARIES}
${LUA_LIBRARIES} ${LUA_LIBRARIES}
${LUABIND_LIBRARIES} ${LUABIND_LIBRARIES}

@ -32,6 +32,8 @@
#include <csignal> #include <csignal>
#endif #endif
#include <SDL.h>
#ifdef NL_OS_MAC #ifdef NL_OS_MAC
#include <stdio.h> #include <stdio.h>
#include <sys/resource.h> #include <sys/resource.h>
@ -119,6 +121,41 @@ static void sigHandler(int Sig)
} }
#endif #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 : // MAIN :
// Entry for the Application. // Entry for the Application.
@ -361,6 +398,11 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR cm
int main(int argc, char **argv) int main(int argc, char **argv)
#endif #endif
{ {
// TODO: Test new splash screen on Windows
#ifndef NL_OS_WINDOW
createSplashScreen();
#endif
// init the Nel context // init the Nel context
CApplicationContext *appContext = new CApplicationContext; CApplicationContext *appContext = new CApplicationContext;
@ -519,7 +561,7 @@ int main(int argc, char **argv)
#else #else
// TODO for Linux : splashscreen pumpSplashScreen();
if (argc >= 4) if (argc >= 4)
{ {

@ -105,6 +105,8 @@
#include <windows.h> #include <windows.h>
extern HINSTANCE HInstance; extern HINSTANCE HInstance;
extern HWND SlashScreen; extern HWND SlashScreen;
#else
void destroySplashScreen();
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
#include "app_bundle_utils.h" #include "app_bundle_utils.h"
@ -713,10 +715,10 @@ void prelogInit()
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
_control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM); _control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
CTime::CTimerInfo timerInfo; CTime::CTimerInfo timerInfo;
NLMISC::CTime::probeTimerInfo(timerInfo); NLMISC::CTime::probeTimerInfo(timerInfo);
FPU_CHECKER_ONCE FPU_CHECKER_ONCE
NLMISC::TTime initStart = ryzomGetLocalTime (); NLMISC::TTime initStart = ryzomGetLocalTime ();
@ -903,7 +905,7 @@ void prelogInit()
Driver->setSwapVBLInterval(1); Driver->setSwapVBLInterval(1);
else else
Driver->setSwapVBLInterval(0); Driver->setSwapVBLInterval(0);
if (StereoDisplay) // VR_CONFIG // VR_DRIVER if (StereoDisplay) // VR_CONFIG // VR_DRIVER
{ {
// override mode TODO // override mode TODO
@ -944,6 +946,10 @@ void prelogInit()
if (SlashScreen) if (SlashScreen)
DestroyWindow (SlashScreen); DestroyWindow (SlashScreen);
#else
destroySplashScreen();
#endif // NL_OS_WINDOW #endif // NL_OS_WINDOW
// Set the title // Set the title
@ -965,7 +971,7 @@ void prelogInit()
filenames.push_back(CPath::lookup("ryzom.png")); filenames.push_back(CPath::lookup("ryzom.png"));
vector<CBitmap> bitmaps; vector<CBitmap> bitmaps;
for(size_t i = 0; i < filenames.size(); ++i) for(size_t i = 0; i < filenames.size(); ++i)
{ {
CIFile file; CIFile file;
@ -1103,7 +1109,7 @@ void prelogInit()
// resetTextContext ("bremenb.ttf", false); // resetTextContext ("bremenb.ttf", false);
resetTextContext ("ryzom.ttf", false); resetTextContext ("ryzom.ttf", false);
CInterfaceManager::getInstance(); CInterfaceManager::getInstance();
// Yoyo: initialize NOW the InputHandler for Event filtering. // Yoyo: initialize NOW the InputHandler for Event filtering.
@ -1152,7 +1158,7 @@ void prelogInit()
// init bloom effect // init bloom effect
CBloomEffect::getInstance().init(driver != UDriver::Direct3d); CBloomEffect::getInstance().init(driver != UDriver::Direct3d);
if (StereoDisplay) // VR_CONFIG if (StereoDisplay) // VR_CONFIG
{ {
// Init stereo display resources // Init stereo display resources

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