Bladeren bron

Add the three default textures.

Sam Jaffe 6 jaren geleden
bovenliggende
commit
e53a2b62bb

+ 1 - 1
graphics/include/game/graphics/texture.hpp

@@ -23,7 +23,7 @@ namespace graphics {
     math::vec2i const size;
 
   private:
-    static texture create(unsigned char *, math::vec2i);
+    static texture create(char const *, math::vec2i);
     texture(unsigned int, math::vec2i = math::vec2i{{0, 0}});
   };
 }

+ 1 - 1
graphics/src/helper.hpp

@@ -24,7 +24,7 @@ namespace std {
 namespace graphics {
   namespace textures {
     enum class format { RGB, RGBA };
-    unsigned int init(format, math::vec2i, unsigned char *);
+    unsigned int init(format, math::vec2i, void const *);
   }
   namespace shaders {
     unsigned int init(unsigned int, std::string const &);

+ 1 - 1
graphics/src/opengl_helper.cxx

@@ -115,7 +115,7 @@ namespace graphics { namespace textures {
   }
 
   unsigned int init(format color_fmt, math::vec2i dimension,
-                    unsigned char * data) {
+                    void const * data) {
     unsigned int id;
     // Enable texturings
     //    glEnable( GL_TEXTURE_2D );

+ 7 - 1
graphics/src/texture.cpp

@@ -51,10 +51,16 @@ namespace graphics {
     return g_textures.emplace(imagefile, std::move(tex)).first->second;
   }
 
-  texture texture::create(unsigned char * data, math::vec2i size) {
+  texture texture::create(char const * data, math::vec2i size) {
     return {textures::init(format(4), size, data), size};
   }
 
   texture::texture(unsigned int id, math::vec2i sz)
       : identity<graphics::texture>(id), size(sz) {}
+
+  texture const texture::WHITE = texture::create("\xFF\xFF\xFF\xFF", {{1, 1}});
+  texture const texture::DARK_YELLOW =
+      texture::create("\x80\x80\x00\xFF", {{1, 1}});
+  texture const texture::LIGHT_BLUE =
+      texture::create("\x80\x80\xFF\xFF", {{1, 1}});
 }