]> git.localhorst.tv Git - orbi.git/commitdiff
resolve data path relative to executable
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 22 Apr 2014 14:30:17 +0000 (16:30 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 22 Apr 2014 14:30:17 +0000 (16:30 +0200)
src/app/SDL.h
src/graphics/Canvas.h
src/orbi.cpp

index ce116d5d576bad0339627aa7754cc17d3021546b..c18f7c2fad3f7ae0db0f38343f6da3cb3a23ff15 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef ORBI_SDL_H_
 #define ORBI_SDL_H_
 
+#include <memory>
+#include <string>
 #include <SDL.h>
 
 
@@ -15,6 +17,11 @@ public:
        SDL(const SDL &) = delete;
        SDL &operator =(const SDL &) = delete;
 
+       std::string GetBasePath() const {
+               std::unique_ptr<char, decltype(&SDL_free)> base{SDL_GetBasePath(), &SDL_free};
+               return std::string(base.get());
+       }
+
 };
 
 }
index f399b364dca60a8290ae9a5f5713b55c5abc1d9b..021bcedff936c4f5d2655ff977c2b9f80e26592b 100644 (file)
@@ -5,6 +5,7 @@
 #include "Texture.h"
 #include "Vector.h"
 
+#include <string>
 #include <SDL.h>
 
 
@@ -30,6 +31,9 @@ public:
 
        Texture CreateStaticTexture(Vector<int> size);
        Texture LoadTexture(const char *file);
+       Texture LoadTexture(const std::string &file) {
+               return LoadTexture(file.c_str());
+       }
 
        void Copy(Texture &, Vector<int> to);
        void Copy(Texture &, Rect<int> clip, Vector<int> to);
index f410a40bcab41c612dd8a9c1b4dabe355a8fb7b0..42ee9109f450c8f4e3e61dd11be42cdb49bfb077 100644 (file)
@@ -31,7 +31,7 @@ int main(int argc, const char *argv[]) {
        ));
 
        Tileset tiles(
-               canv.LoadTexture("/home/holy/projects/orbi/data/test-tile.png"),
+               canv.LoadTexture(sdl.GetBasePath() + "../../data/test-tile.png"),
                Vector<int>(32, 32)
        );