1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
xn65/framework/platform/content-readers/texture2Dreader-dx.hpp

31 lines
941 B
C++
Raw Normal View History

2024-05-05 15:50:17 -03:00
#ifndef XNA_PLATFORM_CONTENTREADERS_TEXTURE2D_HPP
#define XNA_PLATFORM_CONTENTREADERS_TEXTURE2D_HPP
#include "../../content/reader.hpp"
#include "../texture-dx.hpp"
namespace xna {
class Texture2DReader : public ContentTypeReaderT<Texture2D> {
public:
Texture2DReader() : ContentTypeReaderT(typeof<Texture2D>()){}
2024-05-05 15:50:17 -03:00
Texture2D Read(ContentReader& input, Texture2D& existingInstance) override{
const auto format = static_cast<SurfaceFormat>(input.ReadInt32());
const auto width = input.ReadInt32();
const auto height = input.ReadInt32();
const auto mipMaps = input.ReadInt32();
auto texture2D = Texture2D(nullptr, width, height, mipMaps, format);
2024-05-05 15:50:17 -03:00
for (size_t level = 0; level < mipMaps; ++level) {
auto elementCount = input.ReadInt32();
std::vector<Byte> data = input.ReadByteBuffer(elementCount);
texture2D.SetData(level, nullptr, data, 0, elementCount);
}
2024-05-05 15:50:17 -03:00
return texture2D;
}
};
}
#endif