Skip to content

Commit

Permalink
Add a function that loads a texture.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Jun 11, 2014
1 parent 03c0efe commit 66fdc79
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/image.cpp
Expand Up @@ -31,6 +31,7 @@
#include "gettext.hpp"
#include "sdl/rect.hpp"
#include "serialization/string_utils.hpp"
#include "video.hpp"

#include "SDL_image.h"

Expand Down Expand Up @@ -615,6 +616,15 @@ surface load_from_disk(const locator &loc)
}
}

sdl::ttexture load_texture(const locator &loc, const int access)
{
surface img = load_from_disk(loc);
if (!img.null()) {
return CVideo::get_window()->create_texture(access, img);
} else {
return sdl::ttexture();
}
}

manager::manager() {}

Expand Down
4 changes: 4 additions & 0 deletions src/image.hpp
Expand Up @@ -17,6 +17,7 @@

#include "map_location.hpp"
#include "sdl/utils.hpp"
#include "sdl/texture.hpp"
#include "terrain_translation.hpp"
#include "game_config.hpp"

Expand Down Expand Up @@ -125,6 +126,9 @@ namespace image {

surface load_from_disk(const locator &loc);

sdl::ttexture load_texture(const locator &loc,
const int access = SDL_TEXTUREACCESS_STATIC);

size_t hash_value(const locator::value&);


Expand Down

0 comments on commit 66fdc79

Please sign in to comment.