@@ -132,14 +132,21 @@ class Texture
132132
133133 // This tells the shader where to find the texture
134134 static void active_texture (int texture);
135- static Texture::Id load (const std::filesystem::path &path, bool flip = true );
135+ // Loads texture from path, sets [loaded_memory] with the number
136+ // of bytes loaded and returns the id of the loaded texture
137+ static Texture::Id load (const std::filesystem::path &path,
138+ int &loaded_memory, bool flip = true );
136139 static Texture::Id load_solid_color (Color color);
137140 static void bind_id (Texture::Target target, Texture::Id id);
138141 static void bind_id (Texture::Target target, Texture::Id id,
139142 const Texture::Properties &properties);
140143
141144 // Non static
142145
146+ // Used for profiling
147+ int memory = 0 ;
148+ static int tot_memory;
149+
143150 Texture () {}
144151 Texture (const Config &conf);
145152
@@ -153,7 +160,10 @@ class Texture
153160 this ->type = other.type ;
154161 this ->target = other.target ;
155162 this ->properties = other.properties ;
156- other.id = 0 ;
163+ this ->memory = other.memory ;
164+
165+ other.id = 0 ;
166+ other.memory = 0 ;
157167 }
158168
159169 Texture& operator =(Texture&& other) noexcept
@@ -163,7 +173,10 @@ class Texture
163173 this ->path = other.path ;
164174 this ->target = other.target ;
165175 this ->properties = other.properties ;
166- other.id = 0 ;
176+ this ->memory = other.memory ;
177+
178+ other.id = 0 ;
179+ other.memory = 0 ;
167180 return *this ;
168181 }
169182
@@ -184,8 +197,9 @@ class Texture
184197 Texture::Target target;
185198 std::filesystem::path path;
186199 Texture::Properties properties;
187-
188- static void read_image (const std::filesystem::path &path, bool flip);
200+
201+ // Returns the number of bytes loaded
202+ static int read_image (const std::filesystem::path &path, bool flip);
189203
190204};
191205
0 commit comments