提交 6b3295f8 编写于 作者: S Simon Fels

Only attempt to create a renderer when we don't have one already

上级 b7173ac9
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "anbox/ui/splash_screen.h" #include "anbox/ui/splash_screen.h"
#include "anbox/config.h" #include "anbox/config.h"
#include "anbox/utils.h" #include "anbox/utils.h"
#include "anbox/logger.h"
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
...@@ -44,9 +45,15 @@ SplashScreen::SplashScreen() { ...@@ -44,9 +45,15 @@ SplashScreen::SplashScreen() {
SDL_FillRect(surface, nullptr, SDL_MapRGB(surface->format, 0xee, 0xee, 0xee)); SDL_FillRect(surface, nullptr, SDL_MapRGB(surface->format, 0xee, 0xee, 0xee));
SDL_UpdateWindowSurface(window_); SDL_UpdateWindowSurface(window_);
auto renderer = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED); auto renderer = SDL_GetRenderer(window_);
if (!renderer) if (!renderer) {
BOOST_THROW_EXCEPTION(std::runtime_error("Could not create renderer")); DEBUG("Window has no associated renderer yet, creating one ...");
renderer = SDL_CreateRenderer(window_, -1, SDL_RENDERER_ACCELERATED);
if (!renderer) {
const auto msg = utils::string_format("Could not create renderer: %s", SDL_GetError());
BOOST_THROW_EXCEPTION(std::runtime_error(msg));
}
}
const auto icon_path = utils::string_format("%s/ui/loading-screen.png", SystemConfiguration::instance().resource_dir()); const auto icon_path = utils::string_format("%s/ui/loading-screen.png", SystemConfiguration::instance().resource_dir());
auto img = IMG_LoadTexture(renderer, icon_path.c_str()); auto img = IMG_LoadTexture(renderer, icon_path.c_str());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册