mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Add DXT1 and DXT3 texture compression.
This commit is contained in:
parent
730446fdaa
commit
fb6de5abb1
@ -76,6 +76,7 @@ create_texture(DXScreenData &scrn) {
|
||||
int num_alpha_bits; // number of alpha bits in texture pixfmt
|
||||
D3DFORMAT target_pixel_format = D3DFMT_UNKNOWN;
|
||||
bool needs_luminance = false;
|
||||
bool compress_texture = false;
|
||||
|
||||
nassertr(IS_VALID_PTR(get_texture()), false);
|
||||
|
||||
@ -133,6 +134,24 @@ create_texture(DXScreenData &scrn) {
|
||||
break;
|
||||
}
|
||||
|
||||
// check for texture compression
|
||||
switch (get_texture()->get_texture_type()) {
|
||||
case Texture::TT_1d_texture:
|
||||
case Texture::TT_2d_texture:
|
||||
case Texture::TT_cube_map:
|
||||
// check config setting
|
||||
if (compressed_textures) {
|
||||
// no compression for render target textures
|
||||
if (get_texture()->get_render_to_texture() == false) {
|
||||
compress_texture = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Texture::TT_3d_texture:
|
||||
// not supported by all video chips
|
||||
break;
|
||||
}
|
||||
|
||||
// make sure we handled all the possible cases
|
||||
nassertr(_d3d_format != D3DFMT_UNKNOWN, false);
|
||||
|
||||
@ -288,6 +307,9 @@ create_texture(DXScreenData &scrn) {
|
||||
break; //bail
|
||||
|
||||
if (!dx_force_16bpptextures) {
|
||||
if (compress_texture) {
|
||||
CHECK_FOR_FMT(DXT3, Conv32toDXT3);
|
||||
}
|
||||
if (num_color_channels == 4) {
|
||||
CHECK_FOR_FMT(A8R8G8B8, Conv32to32);
|
||||
} else {
|
||||
@ -342,6 +364,10 @@ create_texture(DXScreenData &scrn) {
|
||||
case 24:
|
||||
nassertr(num_color_channels == 3, false);
|
||||
|
||||
if (compress_texture) {
|
||||
CHECK_FOR_FMT(DXT1, Conv24toDXT1);
|
||||
}
|
||||
|
||||
if (!dx_force_16bpptextures) {
|
||||
CHECK_FOR_FMT(R8G8B8, Conv24to24);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user