|
@@ -1,15 +1,42 @@
|
|
|
#include "rendering/Texture.h"
|
|
|
#include "io/ImageReader.h"
|
|
|
|
|
|
-Texture::Texture()
|
|
|
- : format(TextureFormat::unknown()), texture(0), maxMipMaps(0) {
|
|
|
+Texture::Format::Format(const GL::TextureFormat& tf, bool linear, bool depth)
|
|
|
+ : format(tf), linear(linear), depth(depth) {
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::color8(int channels, bool linear) {
|
|
|
+ return Format(GL::TextureFormat::color8(channels), linear);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::float16(int channels, bool linear) {
|
|
|
+ return Format(GL::TextureFormat::float16(channels), linear);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::float32(int channels, bool linear) {
|
|
|
+ return Format(GL::TextureFormat::float32(channels), linear);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::depth16(bool linear) {
|
|
|
+ return Format(GL::TextureFormat::depth16(), linear, true);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::depth32(bool linear) {
|
|
|
+ return Format(GL::TextureFormat::depth32(), linear, true);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Format Texture::Format::unknown() {
|
|
|
+ return Format(GL::TextureFormat::unknown(), false, false);
|
|
|
+}
|
|
|
+
|
|
|
+Texture::Texture() : format(Format::unknown()), texture(0), maxMipMaps(0) {
|
|
|
}
|
|
|
|
|
|
Texture::~Texture() {
|
|
|
GL::deleteTexture(texture);
|
|
|
}
|
|
|
|
|
|
-void Texture::init(const TextureFormat& format, int maxMipMaps) {
|
|
|
+void Texture::init(const Format& format, int maxMipMaps) {
|
|
|
if(texture != 0) {
|
|
|
return;
|
|
|
}
|
|
@@ -82,7 +109,7 @@ Error Texture::load(const char* path, int maxMipMaps) {
|
|
|
error.message.append(path).append("' is not 8");
|
|
|
return error;
|
|
|
}
|
|
|
- init(TextureFormat::color8(image.channels), maxMipMaps);
|
|
|
+ init(Format::color8(image.channels), maxMipMaps);
|
|
|
setData(image.width, image.height, image.data);
|
|
|
return {};
|
|
|
}
|