mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 08:48:43 +02:00
REcompiling for windows...
This commit is contained in:
parent
387621e586
commit
569378bdeb
3 changed files with 40 additions and 48 deletions
|
@ -15,10 +15,6 @@ namespace image {
|
|||
}
|
||||
|
||||
template <> void compress(const PB_RGB32& src, CB_BC1& dst) {
|
||||
|
||||
for (auto& b : dst.bytes) {
|
||||
b = 12;
|
||||
}
|
||||
}
|
||||
|
||||
template <> void uncompress(const CB_BC1& src, PB_RGB32& dst) {
|
||||
|
@ -27,7 +23,7 @@ template <> void uncompress(const CB_BC1& src, PB_RGB32& dst) {
|
|||
auto c0 = bc1.color0.val;
|
||||
auto c1 = bc1.color1.val;
|
||||
|
||||
for (int i = 0; i < PB_RGB32::SIZE; ++i) {
|
||||
for (int i = 0; i < PB_RGB32::LENGTH; ++i) {
|
||||
//dst.pixels[i] = ;
|
||||
auto r = pixel::mix(
|
||||
c0,
|
||||
|
|
|
@ -82,40 +82,37 @@ namespace image {
|
|||
public:
|
||||
using Format = F;
|
||||
using Storage = S;
|
||||
|
||||
union {
|
||||
Storage raw;
|
||||
Format val{ Format() }; // Format last to be initialized by Format's default constructor
|
||||
};
|
||||
|
||||
Pixel() {};
|
||||
|
||||
Format val { Format() };
|
||||
|
||||
Pixel() : val(Format()) {};
|
||||
Pixel(Format v) : val(v) {}
|
||||
Pixel(Storage s) : raw(s) {}
|
||||
Pixel(Storage s) : val(*static_cast<Format> (&s)) {}
|
||||
|
||||
const Storage* storage() const { return static_cast<Storage> (&val); }
|
||||
};
|
||||
|
||||
|
||||
template <typename P, int length> class PixelBlock {
|
||||
public:
|
||||
using Format = typename P::Format;
|
||||
using Storage = typename P::Storage;
|
||||
|
||||
constexpr uint16_t getLength() const { return length; }
|
||||
uint32_t getSize() const { return length * sizeof(P); }
|
||||
|
||||
|
||||
static const uint16_t LENGTH { length };
|
||||
static const uint32_t SIZE { length * sizeof(P) };
|
||||
|
||||
P pixels[length];
|
||||
|
||||
|
||||
PixelBlock() {}
|
||||
|
||||
|
||||
|
||||
PixelBlock(const P* srcPixels) {
|
||||
setPixels(srcPixels);
|
||||
}
|
||||
|
||||
|
||||
void setPixels(const P* srcPixels) {
|
||||
memcpy(pixels, srcPixels, getSize());
|
||||
}
|
||||
|
||||
const Storage* getStorage() const { return static_cast<const Storage*> (&pixels->raw); }
|
||||
|
||||
const Storage* storage() const { return pixels->storage(); }
|
||||
};
|
||||
|
||||
template <typename P, int tileW, int tileH> class Tile {
|
||||
|
@ -123,12 +120,12 @@ namespace image {
|
|||
using Format = typename P::Format;
|
||||
using Storage = typename P::Storage;
|
||||
using Block = typename PixelBlock<P, tileW * tileH>;
|
||||
|
||||
constexpr uint16_t getWidth() const { return tileW; }
|
||||
constexpr uint16_t getHeight() const { return tileH; }
|
||||
|
||||
|
||||
uint16_t getWidth() const { return tileW; }
|
||||
uint16_t getHeight() const { return tileH; }
|
||||
|
||||
Block _block;
|
||||
|
||||
|
||||
Tile() {}
|
||||
Tile(const P* srcPixels) : _block(srcPixels) {}
|
||||
|
||||
|
@ -162,15 +159,18 @@ namespace image {
|
|||
};
|
||||
};
|
||||
|
||||
template <typename T> class CompressedBlock {
|
||||
template <typename F, typename S = typename storage<sizeof(F)>::type> class CompressedBlock {
|
||||
public:
|
||||
static const uint32_t SIZE { sizeof(T) };
|
||||
union {
|
||||
Byte bytes[SIZE];
|
||||
T bc;
|
||||
};
|
||||
|
||||
using Format = F;
|
||||
using Storage = S;
|
||||
|
||||
static const uint32_t SIZE { sizeof(F) };
|
||||
|
||||
Format bc;
|
||||
|
||||
CompressedBlock() {}
|
||||
|
||||
const Storage* storage() const { return static_cast<Storage> (&bc); }
|
||||
};
|
||||
|
||||
|
||||
|
@ -250,9 +250,10 @@ namespace image {
|
|||
class Pixmap {
|
||||
public:
|
||||
using Tile = T;
|
||||
|
||||
using Block = typename T::Block;
|
||||
|
||||
Grid _grid;
|
||||
PixelBlockArray<T::Block> _blocks;
|
||||
PixelBlockArray<Block> _blocks;
|
||||
|
||||
void resize(const Grid::Coord2& widthHeight) {
|
||||
_grid = Grid(widthHeight, Coord2(Tile::getWidth(), Tile::getHeight()));
|
||||
|
|
|
@ -265,7 +265,6 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
|
|||
image::PixRGB565 pix3;
|
||||
|
||||
image::PB_RGB32 pb0;
|
||||
image::CB_BC1 cb;
|
||||
image::PB_RGB32 pb1;
|
||||
|
||||
auto pix0_s = sizeof(pix0);
|
||||
|
@ -274,15 +273,11 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
|
|||
auto pix3_s = sizeof(pix3);
|
||||
|
||||
auto pb0_s = sizeof(pb0);
|
||||
auto cb_s = sizeof(cb);
|
||||
|
||||
auto cb_bytes = pb0.getStorage();
|
||||
image::compress(pb0, cb);
|
||||
image::uncompress(cb, pb1);
|
||||
|
||||
image::Grid grid;
|
||||
grid.
|
||||
|
||||
|
||||
image::Pixmap<image::PixRGB32> theMap();
|
||||
|
||||
// theMap(image.width(), image.height(), image.byteCount(), image.constBits());
|
||||
|
||||
if (generateMips) {
|
||||
::generateMips(theTexture, image, formatMip);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue