mirror of
https://github.com/overte-org/overte.git
synced 2025-07-18 02:56:50 +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) {
|
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) {
|
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 c0 = bc1.color0.val;
|
||||||
auto c1 = bc1.color1.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] = ;
|
//dst.pixels[i] = ;
|
||||||
auto r = pixel::mix(
|
auto r = pixel::mix(
|
||||||
c0,
|
c0,
|
||||||
|
|
|
@ -83,30 +83,27 @@ namespace image {
|
||||||
using Format = F;
|
using Format = F;
|
||||||
using Storage = S;
|
using Storage = S;
|
||||||
|
|
||||||
union {
|
Format val { Format() };
|
||||||
Storage raw;
|
|
||||||
Format val{ Format() }; // Format last to be initialized by Format's default constructor
|
|
||||||
};
|
|
||||||
|
|
||||||
Pixel() {};
|
Pixel() : val(Format()) {};
|
||||||
Pixel(Format v) : val(v) {}
|
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 {
|
template <typename P, int length> class PixelBlock {
|
||||||
public:
|
public:
|
||||||
using Format = typename P::Format;
|
using Format = typename P::Format;
|
||||||
using Storage = typename P::Storage;
|
using Storage = typename P::Storage;
|
||||||
|
|
||||||
constexpr uint16_t getLength() const { return length; }
|
static const uint16_t LENGTH { length };
|
||||||
uint32_t getSize() const { return length * sizeof(P); }
|
static const uint32_t SIZE { length * sizeof(P) };
|
||||||
|
|
||||||
P pixels[length];
|
P pixels[length];
|
||||||
|
|
||||||
PixelBlock() {}
|
PixelBlock() {}
|
||||||
|
|
||||||
|
|
||||||
PixelBlock(const P* srcPixels) {
|
PixelBlock(const P* srcPixels) {
|
||||||
setPixels(srcPixels);
|
setPixels(srcPixels);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +112,7 @@ namespace image {
|
||||||
memcpy(pixels, srcPixels, getSize());
|
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 {
|
template <typename P, int tileW, int tileH> class Tile {
|
||||||
|
@ -124,8 +121,8 @@ namespace image {
|
||||||
using Storage = typename P::Storage;
|
using Storage = typename P::Storage;
|
||||||
using Block = typename PixelBlock<P, tileW * tileH>;
|
using Block = typename PixelBlock<P, tileW * tileH>;
|
||||||
|
|
||||||
constexpr uint16_t getWidth() const { return tileW; }
|
uint16_t getWidth() const { return tileW; }
|
||||||
constexpr uint16_t getHeight() const { return tileH; }
|
uint16_t getHeight() const { return tileH; }
|
||||||
|
|
||||||
Block _block;
|
Block _block;
|
||||||
|
|
||||||
|
@ -162,15 +159,18 @@ namespace image {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> class CompressedBlock {
|
template <typename F, typename S = typename storage<sizeof(F)>::type> class CompressedBlock {
|
||||||
public:
|
public:
|
||||||
static const uint32_t SIZE { sizeof(T) };
|
using Format = F;
|
||||||
union {
|
using Storage = S;
|
||||||
Byte bytes[SIZE];
|
|
||||||
T bc;
|
static const uint32_t SIZE { sizeof(F) };
|
||||||
};
|
|
||||||
|
Format bc;
|
||||||
|
|
||||||
CompressedBlock() {}
|
CompressedBlock() {}
|
||||||
|
|
||||||
|
const Storage* storage() const { return static_cast<Storage> (&bc); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,9 +250,10 @@ namespace image {
|
||||||
class Pixmap {
|
class Pixmap {
|
||||||
public:
|
public:
|
||||||
using Tile = T;
|
using Tile = T;
|
||||||
|
using Block = typename T::Block;
|
||||||
|
|
||||||
Grid _grid;
|
Grid _grid;
|
||||||
PixelBlockArray<T::Block> _blocks;
|
PixelBlockArray<Block> _blocks;
|
||||||
|
|
||||||
void resize(const Grid::Coord2& widthHeight) {
|
void resize(const Grid::Coord2& widthHeight) {
|
||||||
_grid = Grid(widthHeight, Coord2(Tile::getWidth(), Tile::getHeight()));
|
_grid = Grid(widthHeight, Coord2(Tile::getWidth(), Tile::getHeight()));
|
||||||
|
|
|
@ -265,7 +265,6 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
|
||||||
image::PixRGB565 pix3;
|
image::PixRGB565 pix3;
|
||||||
|
|
||||||
image::PB_RGB32 pb0;
|
image::PB_RGB32 pb0;
|
||||||
image::CB_BC1 cb;
|
|
||||||
image::PB_RGB32 pb1;
|
image::PB_RGB32 pb1;
|
||||||
|
|
||||||
auto pix0_s = sizeof(pix0);
|
auto pix0_s = sizeof(pix0);
|
||||||
|
@ -274,14 +273,10 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
|
||||||
auto pix3_s = sizeof(pix3);
|
auto pix3_s = sizeof(pix3);
|
||||||
|
|
||||||
auto pb0_s = sizeof(pb0);
|
auto pb0_s = sizeof(pb0);
|
||||||
auto cb_s = sizeof(cb);
|
|
||||||
|
|
||||||
auto cb_bytes = pb0.getStorage();
|
image::Pixmap<image::PixRGB32> theMap();
|
||||||
image::compress(pb0, cb);
|
|
||||||
image::uncompress(cb, pb1);
|
|
||||||
|
|
||||||
image::Grid grid;
|
// theMap(image.width(), image.height(), image.byteCount(), image.constBits());
|
||||||
grid.
|
|
||||||
|
|
||||||
if (generateMips) {
|
if (generateMips) {
|
||||||
::generateMips(theTexture, image, formatMip);
|
::generateMips(theTexture, image, formatMip);
|
||||||
|
|
Loading…
Reference in a new issue