- more code cleanup based on cppcheck results and valgrind
- added -h option to build-mg.sh to show parameter usage.
This commit is contained in:
parent
2d3e04f413
commit
3a24531ba7
14
build-mg.sh
14
build-mg.sh
|
@ -18,7 +18,7 @@ CMAKE_ONLY=0
|
|||
MAKE_ONLY=0
|
||||
CLANG_FORCED=0
|
||||
|
||||
while getopts "c:m:n:f:" option; do
|
||||
while getopts "c:m:n:f:h" option; do
|
||||
case "${option}" in
|
||||
c)
|
||||
CPU_COUNT=${OPTARG}
|
||||
|
@ -37,6 +37,18 @@ while getopts "c:m:n:f:" option; do
|
|||
CLANG_FORCED=${OPTARG}
|
||||
# echo "${option} value: ${OPTARG}"
|
||||
;;
|
||||
h)
|
||||
echo "Usage: $0 <option>"
|
||||
echo " where <option> can be: -c=x, -m=1, -n=1, -f=1, -h"
|
||||
echo " option descriptions:"
|
||||
echo " -c=x : Force the cpu / cores count to x - example: -c=4"
|
||||
echo " -m=1 : Force running CMAKE only to create Make files (do not compile)"
|
||||
echo " -n=1 : Force running MAKE only to compile (assume CMAKE already built make files)"
|
||||
echo " -f=1 : Force using CLANG compiler"
|
||||
echo " -h : Display this help usage"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ void Game::endGame() {
|
|||
|
||||
Unit::setGame(NULL);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== END GAME ====\n");
|
||||
|
||||
FileCRCPreCacheThread * &preCacheCRCThreadPtr = CacheManager::getCachedItem< FileCRCPreCacheThread * >(GameConstants::preCacheThreadCacheLookupKey);
|
||||
|
@ -457,7 +457,7 @@ Game::~Game() {
|
|||
preCacheCRCThreadPtr->setPauseForGame(false);
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== END GAME ==== getCurrentPixelByteCount() = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== END GAME ====\n");
|
||||
|
||||
//this->program->reInitGl();
|
||||
|
@ -1596,7 +1596,7 @@ void Game::init(bool initForPreviewOnly) {
|
|||
printf("*Note: Monitoring Network CRC NORMAL synchronization...\n");
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = %llu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(long long unsigned int)renderer.getCurrentPixelByteCount());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ==== START GAME ==== getCurrentPixelByteCount() = " MG_SIZE_T_SPECIFIER "\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderer.getCurrentPixelByteCount());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"=============================================\n");
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugWorldSynch).enabled) SystemFlags::OutputDebug(SystemFlags::debugWorldSynch,"==== START GAME ====\n");
|
||||
|
|
|
@ -3831,17 +3831,6 @@ void Renderer::MapRenderer::Layer::load_vbos(bool vboEnabled) {
|
|||
}
|
||||
}
|
||||
|
||||
//int32 CalculatePixelsCRC(const Texture2DGl *texture) {
|
||||
// const uint8 *pixels = static_cast<const Pixmap2D *>(texture->getPixmapConst())->getPixels();
|
||||
// uint64 pixelByteCount = static_cast<const Pixmap2D *>(texture->getPixmapConst())->getPixelByteCount();
|
||||
// Checksum crc;
|
||||
// for(uint64 i = 0; i < pixelByteCount; ++i) {
|
||||
// crc.addByte(pixels[i]);
|
||||
// }
|
||||
//
|
||||
// return crc.getSum();
|
||||
//}
|
||||
|
||||
void Renderer::MapRenderer::loadVisibleLayers(float coordStep,VisibleQuadContainerCache &qCache) {
|
||||
int totalCellCount = 0;
|
||||
// we create a layer for each visible texture in the map
|
||||
|
@ -9254,8 +9243,8 @@ void Renderer::setLastRenderFps(int value) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64 Renderer::getCurrentPixelByteCount(ResourceScope rs) const {
|
||||
uint64 result = 0;
|
||||
std::size_t Renderer::getCurrentPixelByteCount(ResourceScope rs) const {
|
||||
std::size_t result = 0;
|
||||
for(int i = (rs == rsCount ? 0 : rs); i < rsCount; ++i) {
|
||||
if(textureManager[i] != NULL) {
|
||||
const ::Shared::Graphics::TextureContainer &textures = textureManager[i]->getTextures();
|
||||
|
|
|
@ -627,7 +627,7 @@ public:
|
|||
void removeObjectFromQuadCache(const Object *o);
|
||||
void removeUnitFromQuadCache(const Unit *unit);
|
||||
|
||||
uint64 getCurrentPixelByteCount(ResourceScope rs=rsGame) const;
|
||||
std::size_t getCurrentPixelByteCount(ResourceScope rs=rsGame) const;
|
||||
unsigned int getSaveScreenQueueSize();
|
||||
|
||||
Texture2D *saveScreenToTexture(int x, int y, int width, int height);
|
||||
|
|
|
@ -134,7 +134,7 @@ Minimap::~Minimap() {
|
|||
|
||||
// ==================== set ====================
|
||||
|
||||
void Minimap::incFowTextureAlphaSurface(const Vec2i &sPos, float alpha,
|
||||
void Minimap::incFowTextureAlphaSurface(const Vec2i sPos, float alpha,
|
||||
bool isIncrementalUpdate) {
|
||||
if(fowPixmap1) {
|
||||
assert(sPos.x < fowPixmap1->getW() && sPos.y < fowPixmap1->getH());
|
||||
|
@ -301,11 +301,11 @@ void Minimap::saveGame(XmlNode *rootNode) {
|
|||
XmlNode *minimapNode = rootNode->addChild("Minimap");
|
||||
|
||||
if(fowPixmap1 != NULL) {
|
||||
for(unsigned int i = 0; i < fowPixmap1->getPixelByteCount(); ++i) {
|
||||
if(fowPixmap1->getPixels()[i] != 0) {
|
||||
for(std::size_t index = 0; index < fowPixmap1->getPixelByteCount(); ++index) {
|
||||
if(fowPixmap1->getPixels()[index] != 0) {
|
||||
XmlNode *fowPixmap1Node = minimapNode->addChild("fowPixmap1");
|
||||
fowPixmap1Node->addAttribute("index",intToStr(i), mapTagReplacements);
|
||||
fowPixmap1Node->addAttribute("pixel",intToStr(fowPixmap1->getPixels()[i]), mapTagReplacements);
|
||||
fowPixmap1Node->addAttribute("index",intToStr(index), mapTagReplacements);
|
||||
fowPixmap1Node->addAttribute("pixel",intToStr(fowPixmap1->getPixels()[index]), mapTagReplacements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
const Texture2D *getFowTexture() const {return fowTex;}
|
||||
const Texture2D *getTexture() const {return tex;}
|
||||
|
||||
void incFowTextureAlphaSurface(const Vec2i &sPos, float alpha, bool isIncrementalUpdate=false);
|
||||
void incFowTextureAlphaSurface(const Vec2i sPos, float alpha, bool isIncrementalUpdate=false);
|
||||
void resetFowTex();
|
||||
void updateFowTex(float t);
|
||||
void setFogOfWar(bool value);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
virtual int getTextureWidth() const = 0;
|
||||
virtual int getTextureHeight() const = 0;
|
||||
|
||||
void OutputTextureDebugInfo(Texture::Format format, int components, const string path,uint64 rawSize,GLenum texType);
|
||||
void OutputTextureDebugInfo(Texture::Format format, int components, const string path,std::size_t rawSize,GLenum texType);
|
||||
};
|
||||
|
||||
// =====================================================
|
||||
|
|
|
@ -26,7 +26,6 @@ using Shared::Platform::int16;
|
|||
using Shared::Platform::uint16;
|
||||
using Shared::Platform::int32;
|
||||
using Shared::Platform::uint32;
|
||||
using Shared::Platform::uint64;
|
||||
using Shared::Platform::float32;
|
||||
using Shared::Util::Checksum;
|
||||
|
||||
|
@ -212,7 +211,7 @@ public:
|
|||
uint8 *getPixels() const {return pixels;}
|
||||
void deletePixels();
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
std::size_t getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
@ -295,7 +294,7 @@ public:
|
|||
void subCopy(int x, int y, const Pixmap2D *sourcePixmap);
|
||||
void copyImagePart(int x, int y, const Pixmap2D *sourcePixmap);
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
std::size_t getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
|
||||
|
@ -343,7 +342,7 @@ public:
|
|||
uint8 *getPixels() const {return pixels;}
|
||||
void deletePixels();
|
||||
string getPath() const { return path;}
|
||||
uint64 getPixelByteCount() const;
|
||||
std::size_t getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
@ -386,7 +385,7 @@ public:
|
|||
const Pixmap2D *getFace(int face) const {return &faces[face];}
|
||||
void deletePixels();
|
||||
string getPath(int face) const { return path[face];}
|
||||
uint64 getPixelByteCount() const;
|
||||
std::size_t getPixelByteCount() const;
|
||||
|
||||
Checksum * getCRC() { return &crc; }
|
||||
};
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
using std::string;
|
||||
using Shared::Platform::uint8;
|
||||
using Shared::Platform::uint64;
|
||||
|
||||
struct SDL_Surface;
|
||||
|
||||
|
@ -90,7 +89,7 @@ public:
|
|||
virtual void end(bool deletePixelBuffer=true)=0;
|
||||
virtual string getPath() const = 0;
|
||||
virtual void deletePixels() = 0;
|
||||
virtual uint64 getPixelByteCount() const = 0;
|
||||
virtual std::size_t getPixelByteCount() const = 0;
|
||||
|
||||
virtual void reseInitState() { inited = false; }
|
||||
|
||||
|
@ -116,7 +115,7 @@ public:
|
|||
const Pixmap1D *getPixmap() const {return &pixmap;}
|
||||
virtual string getPath() const;
|
||||
virtual void deletePixels();
|
||||
virtual uint64 getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
virtual std::size_t getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return -1;}
|
||||
|
@ -139,7 +138,7 @@ public:
|
|||
const Pixmap2D *getPixmapConst() const {return &pixmap;}
|
||||
virtual string getPath() const;
|
||||
virtual void deletePixels();
|
||||
virtual uint64 getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
virtual std::size_t getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return pixmap.getH();}
|
||||
|
@ -164,7 +163,7 @@ public:
|
|||
const Pixmap3D *getPixmap() const {return &pixmap;}
|
||||
virtual string getPath() const;
|
||||
virtual void deletePixels();
|
||||
virtual uint64 getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
virtual std::size_t getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
|
||||
virtual int getTextureWidth() const {return pixmap.getW();}
|
||||
virtual int getTextureHeight() const {return pixmap.getH();}
|
||||
|
@ -187,7 +186,7 @@ public:
|
|||
const PixmapCube *getPixmap() const {return &pixmap;}
|
||||
virtual string getPath() const;
|
||||
virtual void deletePixels();
|
||||
virtual uint64 getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
virtual std::size_t getPixelByteCount() const {return pixmap.getPixelByteCount();}
|
||||
|
||||
virtual int getTextureWidth() const {return -1;}
|
||||
virtual int getTextureHeight() const {return -1;}
|
||||
|
|
|
@ -78,7 +78,7 @@ int pot(int x) {
|
|||
return val;
|
||||
}
|
||||
|
||||
const uint64 MIN_BYTES_TO_COMPRESS = 12;
|
||||
const std::size_t MIN_BYTES_TO_COMPRESS = 12;
|
||||
|
||||
static std::string getSupportCompressedTextureFormatString(int format) {
|
||||
std::string result = intToStr(format) + "[" + intToHex(format) + "]";
|
||||
|
@ -1261,7 +1261,7 @@ void TextureCubeGl::end(bool deletePixelBuffer) {
|
|||
}
|
||||
}
|
||||
|
||||
void TextureGl::OutputTextureDebugInfo(Texture::Format format, int components,const string path,uint64 rawSize,GLenum texType) {
|
||||
void TextureGl::OutputTextureDebugInfo(Texture::Format format, int components,const string path,std::size_t rawSize,GLenum texType) {
|
||||
if(Texture::useTextureCompression == true) {
|
||||
GLint glFormat= toFormatGl(format, components);
|
||||
|
||||
|
|
|
@ -1807,7 +1807,7 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col
|
|||
GLubyte* src = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
|
||||
if(src) {
|
||||
pixmapScreenShot = new Pixmap2D(w, h, colorComponents);
|
||||
memcpy(pixmapScreenShot->getPixels(),src,(size_t)pixmapScreenShot->getPixelByteCount());
|
||||
memcpy(pixmapScreenShot->getPixels(),src,pixmapScreenShot->getPixelByteCount());
|
||||
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer
|
||||
//pixmapScreenShot->save("debugPBO.png");
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ struct TargaFileHeader{
|
|||
const int tgaUncompressedRgb= 2;
|
||||
const int tgaUncompressedBw= 3;
|
||||
|
||||
void CalculatePixelsCRC(uint8 *pixels,uint64 pixelByteCount, Checksum &crc) {
|
||||
void CalculatePixelsCRC(uint8 *pixels,std::size_t pixelByteCount, Checksum &crc) {
|
||||
// crc = Checksum();
|
||||
// for(uint64 i = 0; i < pixelByteCount; ++i) {
|
||||
// for(std::size_t i = 0; i < pixelByteCount; ++i) {
|
||||
// crc.addByte(pixels[i]);
|
||||
// }
|
||||
}
|
||||
|
@ -797,12 +797,12 @@ void Pixmap1D::init(int components){
|
|||
void Pixmap1D::init(int w, int components){
|
||||
this->w= w;
|
||||
this->components= components;
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap1D::getPixelByteCount() const {
|
||||
return ((uint64)w * (uint64)components);
|
||||
std::size_t Pixmap1D::getPixelByteCount() const {
|
||||
return (w * components);
|
||||
}
|
||||
|
||||
void Pixmap1D::deletePixels() {
|
||||
|
@ -850,7 +850,7 @@ void Pixmap1D::loadBmp(const string &path) {
|
|||
components= 3;
|
||||
}
|
||||
if(pixels == NULL) {
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
}
|
||||
|
||||
//data
|
||||
|
@ -880,7 +880,7 @@ void Pixmap1D::loadTga(const string &path) {
|
|||
components= fileComponents;
|
||||
}
|
||||
if(pixels == NULL) {
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
}
|
||||
|
||||
//read data
|
||||
|
@ -950,12 +950,12 @@ void Pixmap2D::init(int w, int h, int components) {
|
|||
snprintf(szBuf,8096,"Invalid pixmap dimensions for [%s], h = %d, w = %d, components = %d\n",path.c_str(),h,w,components);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap2D::getPixelByteCount() const {
|
||||
return ((uint64)h * (uint64)w * (uint64)components);
|
||||
std::size_t Pixmap2D::getPixelByteCount() const {
|
||||
return (h * w * components);
|
||||
}
|
||||
|
||||
void Pixmap2D::deletePixels() {
|
||||
|
@ -1061,10 +1061,10 @@ void Pixmap2D::savePng(const string &path) {
|
|||
|
||||
void Pixmap2D::getPixel(int x, int y, uint8 *value) const {
|
||||
for(int i=0; i<components; ++i){
|
||||
int index = (w*y+x)*components+i;
|
||||
if((unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1074,10 +1074,10 @@ void Pixmap2D::getPixel(int x, int y, uint8 *value) const {
|
|||
|
||||
void Pixmap2D::getPixel(int x, int y, float32 *value) const {
|
||||
for(int i=0; i<components; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
if((unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1086,10 +1086,10 @@ void Pixmap2D::getPixel(int x, int y, float32 *value) const {
|
|||
}
|
||||
|
||||
void Pixmap2D::getComponent(int x, int y, int component, uint8 &value) const {
|
||||
int index = (w*y+x)*components+component;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+component;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1097,10 +1097,10 @@ void Pixmap2D::getComponent(int x, int y, int component, uint8 &value) const {
|
|||
}
|
||||
|
||||
void Pixmap2D::getComponent(int x, int y, int component, float32 &value) const {
|
||||
int index = (w*y+x)*components+component;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+component;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1111,10 +1111,10 @@ void Pixmap2D::getComponent(int x, int y, int component, float32 &value) const {
|
|||
Vec4f Pixmap2D::getPixel4f(int x, int y) const {
|
||||
Vec4f v(0.f);
|
||||
for(int i=0; i<components && i<4; ++i){
|
||||
int index = (w*y+x)*components+i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1126,10 +1126,10 @@ Vec4f Pixmap2D::getPixel4f(int x, int y) const {
|
|||
Vec3f Pixmap2D::getPixel3f(int x, int y) const {
|
||||
Vec3f v(0.f);
|
||||
for(int i=0; i<components && i<3; ++i){
|
||||
int index = (w*y+x)*components+i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1139,10 +1139,10 @@ Vec3f Pixmap2D::getPixel3f(int x, int y) const {
|
|||
}
|
||||
|
||||
float Pixmap2D::getPixelf(int x, int y) const {
|
||||
int index = (w*y+x)*components;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
return pixels[index]/255.f;
|
||||
|
@ -1161,10 +1161,10 @@ void Pixmap2D::setPixel(int x, int y, const uint8 *value, int arraySize) {
|
|||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
for(int i = 0; i < components; ++i) {
|
||||
int index = (w * y + x) * components + i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w * y + x) * components + i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1181,10 +1181,10 @@ void Pixmap2D::setPixel(int x, int y, const float32 *value, int arraySize) {
|
|||
}
|
||||
|
||||
for(int i = 0; i < components; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(value[i]*255.f);
|
||||
|
@ -1193,10 +1193,10 @@ void Pixmap2D::setPixel(int x, int y, const float32 *value, int arraySize) {
|
|||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, uint8 value) {
|
||||
int index = (w*y+x)*components+component;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+component;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1205,10 +1205,10 @@ void Pixmap2D::setComponent(int x, int y, int component, uint8 value) {
|
|||
}
|
||||
|
||||
void Pixmap2D::setComponent(int x, int y, int component, float32 value) {
|
||||
int index = (w*y+x)*components+component;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+component;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1219,10 +1219,10 @@ void Pixmap2D::setComponent(int x, int y, int component, float32 value) {
|
|||
//vector set
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec3f &p) {
|
||||
for(int i = 0; i < components && i < 3; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
|
@ -1232,10 +1232,10 @@ void Pixmap2D::setPixel(int x, int y, const Vec3f &p) {
|
|||
|
||||
void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
||||
for(int i = 0; i < components && i < 4; ++i) {
|
||||
int index = (w*y+x)*components+i;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w*y+x)*components+i;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
pixels[index]= static_cast<uint8>(p.ptr()[i]*255.f);
|
||||
|
@ -1244,10 +1244,10 @@ void Pixmap2D::setPixel(int x, int y, const Vec4f &p) {
|
|||
}
|
||||
|
||||
void Pixmap2D::setPixel(int x, int y, float p) {
|
||||
int index = (w*y+x)*components;
|
||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||
std::size_t index = (w * y + x) * components;
|
||||
if(index >= getPixelByteCount()) {
|
||||
char szBuf[8096];
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
snprintf(szBuf,8096,"Invalid pixmap index: " MG_SIZE_T_SPECIFIER " for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
|
@ -1462,12 +1462,12 @@ void Pixmap3D::init(int w, int h, int d, int components){
|
|||
this->h= h;
|
||||
this->d= d;
|
||||
this->components= components;
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
CalculatePixelsCRC(pixels,0, crc);
|
||||
}
|
||||
|
||||
uint64 Pixmap3D::getPixelByteCount() const {
|
||||
return ((uint64)h * (uint64)w * (uint64)d * (uint64)components);
|
||||
std::size_t Pixmap3D::getPixelByteCount() const {
|
||||
return (h * w * d * components);
|
||||
}
|
||||
|
||||
void Pixmap3D::init(int d, int components){
|
||||
|
@ -1538,7 +1538,7 @@ void Pixmap3D::loadSliceBmp(const string &path, int slice){
|
|||
components= 3;
|
||||
}
|
||||
if(pixels==NULL){
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
pixels= new uint8[getPixelByteCount()];
|
||||
}
|
||||
|
||||
//data
|
||||
|
@ -1551,27 +1551,6 @@ void Pixmap3D::loadSliceTga(const string &path, int slice){
|
|||
//deletePixels();
|
||||
FileReader<Pixmap3D>::readPath(path,this);
|
||||
//printf("Loading 3D pixmap TGA [%s] this [%p]\n",path.c_str(),this);
|
||||
|
||||
/*
|
||||
PixmapIoTga plt;
|
||||
plt.openRead(path);
|
||||
|
||||
//header
|
||||
int fileComponents= plt.getComponents();
|
||||
|
||||
//init
|
||||
w= plt.getW();
|
||||
h= plt.getH();
|
||||
if(components==-1){
|
||||
components= fileComponents;
|
||||
}
|
||||
if(pixels==NULL){
|
||||
pixels= new uint8[(std::size_t)getPixelByteCount()];
|
||||
}
|
||||
|
||||
//read data
|
||||
plt.read(&pixels[slice*w*h*components], components);
|
||||
*/
|
||||
}
|
||||
|
||||
// =====================================================
|
||||
|
@ -1600,8 +1579,8 @@ void PixmapCube::init(int components) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64 PixmapCube::getPixelByteCount() const {
|
||||
uint64 result = 0;
|
||||
std::size_t PixmapCube::getPixelByteCount() const {
|
||||
std::size_t result = 0;
|
||||
for(int i=0; i<6; ++i) {
|
||||
result += faces[i].getPixelByteCount();
|
||||
}
|
||||
|
|
|
@ -1470,7 +1470,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
|||
MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; }
|
||||
r->m_table_sizes[2] = 19;
|
||||
}
|
||||
for ( ; (int)r->m_type >= 0; r->m_type--)
|
||||
for ( ; ; )
|
||||
{
|
||||
int tree_next, tree_cur; tinfl_huff_table *pTable;
|
||||
mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree);
|
||||
|
@ -1513,6 +1513,13 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
|
|||
}
|
||||
TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]);
|
||||
}
|
||||
|
||||
if(r->m_type == 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
r->m_type--;
|
||||
}
|
||||
}
|
||||
for ( ; ; )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue