39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <fstream>
|
|
#include <unordered_map>
|
|
#include <map>
|
|
#include <string>
|
|
#include "../../inc/gl/glew.h"
|
|
|
|
template<typename T>
|
|
class CompressedTexture
|
|
{
|
|
public:
|
|
virtual ~CompressedTexture() {}
|
|
|
|
// Uncompress and retrieve the texture (possibly from a certain index)
|
|
virtual T operator[](size_t i) const = 0;
|
|
virtual unsigned64 size() const = 0;
|
|
|
|
virtual std::vector<T> GetTexture(size_t fromIndex = 0) = 0;
|
|
// Compresses the texture, replacing everything after fromIndex by whatever is in texture
|
|
virtual void SetTexture(const std::vector<T>& texture, size_t fromIndex = 0) = 0;
|
|
// Replace all materials by other colors. This could be useful as some methods don't need to fully decompress and compress the whole texture to do this.
|
|
virtual void ReplaceMaterials(const std::unordered_map<T, T>& replacers) = 0;
|
|
virtual void Recompress() { SetTexture(GetTexture()); }
|
|
|
|
virtual void ReadFromFile(std::istream& file) = 0;
|
|
virtual void WriteToFile(std::ostream& file) const = 0;
|
|
|
|
// Use this method to output the compressed texture as a vector of one byte characters
|
|
virtual std::vector<unsigned8> GetTexturePool() const = 0;
|
|
virtual size_t GetTexturePoolSize() const = 0;
|
|
|
|
// Use this method to output any addition information that might be needed.
|
|
virtual std::vector<unsigned8> GetAdditionalTexturePool() const { return std::vector<unsigned8>(); };
|
|
virtual size_t GetAdditionalTexturePoolSize() const { return 0; };
|
|
|
|
virtual std::map<std::string, std::string> GetAdditionalProperties() const = 0;
|
|
}; |