Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 8cf0c634 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Fixed various warnings and CppCheck issues.

parent 340fdebf
......@@ -285,9 +285,9 @@ namespace campvis {
const ImageData* id = static_cast<const ImageData*>(_textures[texIndx].getData());
const cgt::Texture* tex = id->getRepresentation<ImageRepresentationGL>()->getTexture();
const ImageRepresentationLocal* localRep = id->getRepresentation<ImageRepresentationLocal>();
cgt::ivec2 imageSize = id->getSize().xy();
cgt::svec2 imageSize = id->getSize().xy();
cgt::vec2 lookupTexelFloat = cgt::vec2((e->coord() % _quadSize) * imageSize) / cgt::vec2(_quadSize);
cgt::vec2 lookupTexelFloat = cgt::vec2((e->coord() % _quadSize) * cgt::ivec2(imageSize)) / cgt::vec2(_quadSize);
// compute transformation matrices
float renderTargetRatio = static_cast<float>(_quadSize.x) / static_cast<float>(_quadSize.y);
......
......@@ -103,7 +103,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
return 0;
}
int bpp = header[4];
size_t bpp = static_cast<size_t>(header[4]);
bpp /= 8; // divide by 8 to get the bytes per pixel
GLint format = GL_RGBA;
......@@ -128,7 +128,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
GLenum dataType = GL_UNSIGNED_BYTE;
int numBytes = bpp * cgt::hmul(dimensions);
size_t numBytes = static_cast<size_t>(bpp * cgt::hmul(dimensions));
GLubyte* buffer = new GLubyte[numBytes];
if (TGAheader[2] == 2) {
......@@ -137,6 +137,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
if (file->read(buffer, numBytes) != numBytes) {
LERROR("Failed to read uncompressed image! file: " << filename);
delete file;
delete [] buffer;
return 0;
}
}
......@@ -147,7 +148,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
//TODO: error handling
unsigned char chunk[4];
unsigned char* at = buffer;
for (int bytesDone=0; bytesDone < numBytes; /* nothing here */) {
for (size_t bytesDone = 0; bytesDone < numBytes; /* nothing here */) {
unsigned char packetHead;
file->read(reinterpret_cast<char*>(&packetHead), 1);
if (packetHead > 128) {
......@@ -175,7 +176,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
// switch r & b
if (bpp >= 3) {
GLubyte* at = buffer;
while (at - buffer < numBytes) {
while (at - buffer < static_cast<ptrdiff_t>(numBytes)) {
std::swap(at[0], at[2]);
at += bpp;
}
......@@ -185,6 +186,7 @@ Texture* TextureReaderTga::loadTexture(const std::string& filename, Texture::Fil
t->uploadTexture(buffer, format, dataType);
t->setName(filename);
delete [] buffer;
return t;
}
......
......@@ -76,7 +76,6 @@ namespace campvis {
ImageRepresentationGL::ScopedRepresentation img(data, p_inputImage.getValue());
if (img != 0) {
cgt::ivec3 inputSize = img->getSize();
cgt::ivec3 outputSize = cgt::abs(p_urb.getValue() - p_llf.getValue());
cgt::TextureUnit inputUnit;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment