Skip to content

Commit

Permalink
Fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Apr 21, 2024
1 parent d41e72c commit cdc8b0c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Sources/nCine/Audio/AudioLoaderWav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace nCine
WavHeader header;
fileHandle_->Read(&header, sizeof(WavHeader));

RETURN_ASSERT_MSG(strncmp(header.chunkId, "RIFF", 4) == 0 && strncmp(header.format, "WAVE", 4) == 0, "Invalid a WAV file");
RETURN_ASSERT_MSG(strncmp(header.subchunk1Id, "fmt ", 4) == 0, "Invalid WAV file");
RETURN_ASSERT_MSG(strncmp(header.chunkId, "RIFF", 4) == 0 && strncmp(header.format, "WAVE", 4) == 0, "Invalid WAV signature");
RETURN_ASSERT_MSG(strncmp(header.subchunk1Id, "fmt ", 4) == 0, "Invalid WAV signature");
RETURN_ASSERT_MSG(Stream::Uint16FromLE(header.audioFormat) == 1, "Data is not in PCM format");

bytesPerSample_ = Stream::Uint16FromLE(header.bitsPerSample) / 8;
Expand Down
35 changes: 14 additions & 21 deletions Sources/nCine/Graphics/TextureLoaderPkm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,24 @@ namespace nCine
TextureLoaderPkm::TextureLoaderPkm(std::unique_ptr<Stream> fileHandle)
: ITextureLoader(std::move(fileHandle))
{
RETURN_ASSERT_MSG(fileHandle_->IsValid(), "File \"%s\" cannot be opened", fileHandle_->GetPath().data());
RETURN_ASSERT(fileHandle_->IsValid());

PkmHeader header;
// PKM header is 16 bytes long
fileHandle_->Read(&header, 16);
fileHandle_->Read(&header, 16); // PKM header is 16 bytes long

// Checking for the header presence
if (Stream::Uint32FromBE(header.magicId) == 0x504B4D20) // "PKM 10"
{
if (Stream::Uint16FromBE(header.version) != 0x3130) { // "10"
RETURN_MSG("PKM version not supported: 0x%04x", header.version);
}
if (Stream::Uint16FromBE(header.dataType) != 0) {
RETURN_MSG("PKM data type not supported: 0x%04x", header.dataType);
}

headerSize_ = 16;
width_ = Stream::Uint16FromBE(header.width);
height_ = Stream::Uint16FromBE(header.height);

const int extWidth = Stream::Uint16FromBE(header.extendedWidth);
const int extHeight = Stream::Uint16FromBE(header.extendedHeight);

LOGI("Header found: w:%d h:%d, xw:%d xh:%d", width_, height_, extWidth, extHeight);
}
RETURN_ASSERT_MSG(Stream::Uint32FromBE(header.magicId) == 0x504B4D20 /* "PKM 10" */, "Invalid PKM signature");
RETURN_ASSERT_MSG(Stream::Uint16FromBE(header.version) == 0x3130 /* "10" */, "PKM version not supported: 0x%04x", header.version);
RETURN_ASSERT_MSG(Stream::Uint16FromBE(header.dataType) == 0, "PKM data type not supported: 0x%04x", header.dataType);

headerSize_ = 16;
width_ = Stream::Uint16FromBE(header.width);
height_ = Stream::Uint16FromBE(header.height);

const int extWidth = Stream::Uint16FromBE(header.extendedWidth);
const int extHeight = Stream::Uint16FromBE(header.extendedHeight);

LOGI("Header found: w:%d h:%d, xw:%d xh:%d", width_, height_, extWidth, extHeight);

loadPixels(GL_ETC1_RGB8_OES);
hasLoaded_ = true;
Expand Down
2 changes: 1 addition & 1 deletion Sources/nCine/Graphics/TextureLoaderQoi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace nCine
TextureLoaderQoi::TextureLoaderQoi(std::unique_ptr<Stream> fileHandle)
: ITextureLoader(std::move(fileHandle))
{
RETURN_ASSERT_MSG(fileHandle_->IsValid(), "File \"%s\" cannot be opened", fileHandle_->GetPath().data());
RETURN_ASSERT(fileHandle_->IsValid());

auto fileSize = fileHandle_->GetSize();
if (fileSize < QOI_HEADER_SIZE || fileSize > 64 * 1024 * 1024) {
Expand Down

0 comments on commit cdc8b0c

Please sign in to comment.