Skip to content

Commit

Permalink
Fix PVRTC sprite transport effect
Browse files Browse the repository at this point in the history
  • Loading branch information
TrajansRow committed Aug 21, 2024
1 parent 165f236 commit da9a142
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 0 additions & 2 deletions Source_Files/RenderMain/ImageLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class ImageDescriptor
int MipMapCount;

public:
int ContentLength; //Might be needed for PVR support. If so, create appropriate accessors

bool IsPresent() const {return (Pixels != NULL); }
bool IsPremultiplied() const { return (IsPresent() ? PremultipliedAlpha : false); }

Expand Down
12 changes: 10 additions & 2 deletions Source_Files/RenderMain/ImageLoader_Shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int ImageDescriptor::GetMipMapSize(int level) const
case ImageDescriptor::PVRTC2:
case ImageDescriptor::PVRTC4:
if (level == 0) {
return ContentLength;
return Size;
}
fprintf(stderr, "PVRTC not yet implemented for mipmap level %d!\n", level);
return 0;
Expand Down Expand Up @@ -313,6 +313,9 @@ bool ImageDescriptor::LoadMipMapFromFile(OpenedFile& file, int flags, int level,
return false;
}
}
} else if (Format == PVRTC2 || Format == PVRTC2)
{
fprintf(stderr, "PVRTC LoadMipMapFromFile not yet supported\n");
}

return true;
Expand Down Expand Up @@ -451,7 +454,10 @@ bool ImageDescriptor::LoadPVTCFromFile (FileSpecifier& File, int flags, int actu
uint32_t metadataLength = SDL_SwapLE32(header->metadataLength);
uint32_t header_and_metadata_size = 52 + metadataLength; //Header is always 52 bytes
uint32_t dataLength = length - header_and_metadata_size;
ContentLength = dataLength;

//ContentLength = dataLength; //Maybe don't need this as a seperate public value in the ImageDescriptor, expecially if always mipmap 0
Size = dataLength;

uint8_t *bytes = ((uint8_t *)contents) + header_and_metadata_size;

// How many 4-byte ints do we need (padded by 2)?
Expand Down Expand Up @@ -731,6 +737,8 @@ bool ImageDescriptor::MakeRGBA()
if (!DecompressDXTC3(RGBADesc.GetMipMapPtr(i), MAX(1, Width >> i), MAX(1, Height >> i), GetMipMapPtr(i))) return false;
} else if (Format == DXTC5) {
if (!DecompressDXTC5(RGBADesc.GetMipMapPtr(i), MAX(1, Width >> i), MAX(1, Height >> i), GetMipMapPtr(i))) return false;
} else if (Format == PVRTC2 || Format == PVRTC4) {
fprintf(stderr, "PVRTC not yet supported by MakeRGBA\n");
} else {
return false;
}
Expand Down
8 changes: 7 additions & 1 deletion Source_Files/RenderMain/OGL_Textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,9 @@ void LoadModelSkin(ImageDescriptor& SkinImage, short Collection, short CLUT)
}
else if (Image.get()->GetFormat() == ImageDescriptor::DXTC1 ||
Image.get()->GetFormat() == ImageDescriptor::DXTC3 ||
Image.get()->GetFormat() == ImageDescriptor::DXTC5)
Image.get()->GetFormat() == ImageDescriptor::DXTC5||
Image.get()->GetFormat() == ImageDescriptor::PVRTC2 ||
Image.get()->GetFormat() == ImageDescriptor::PVRTC4)
{
#if ( defined(GL_ARB_texture_compression) && defined(GL_COMPRESSED_RGB_S3TC_DXT1_EXT) ) || ( defined(GL_ANGLE_texture_compression_dxt3) && defined(GL_ANGLE_texture_compression_dxt5)) || defined(GL_IMG_texture_compression_pvrtc)
if (Image.get()->GetFormat() == ImageDescriptor::DXTC1)
Expand Down Expand Up @@ -1864,7 +1866,11 @@ void FindSilhouetteVersion(ImageDescriptorManager &imageManager)
else if (imageManager.get()->GetFormat() == ImageDescriptor::DXTC3 || imageManager.get()->GetFormat() == ImageDescriptor::DXTC5)
{
FindSilhouetteVersionDXTC35(imageManager.edit()->GetBufferSize(), (unsigned char *) imageManager.edit()->GetBuffer());
} else if (imageManager.get()->GetFormat() == ImageDescriptor::PVRTC2 || imageManager.get()->GetFormat() == ImageDescriptor::PVRTC2)
{
printf("FindSilhouetteVersion not implemented for PVRTC of size %d\n", imageManager.edit()->GetBufferSize());
}

imageManager.edit()->PremultipliedAlpha = false;
}

Expand Down

0 comments on commit da9a142

Please sign in to comment.