From ddc14ea87e87e1963729ba782643228ac1e624e9 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sun, 15 May 2022 16:02:08 +0000 Subject: [PATCH] Merging r6383 through r6403 from trunk to ogl-es branch git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6404 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 5 + include/IAnimatedMeshMD3.h | 4 +- include/IGUIElement.h | 7 +- include/IGUIListBox.h | 19 +- include/IImage.h | 40 +++-- include/IProfiler.h | 10 +- include/ISceneCollisionManager.h | 2 +- include/ISceneNode.h | 2 +- include/ITriangleSelector.h | 2 +- include/IVideoDriver.h | 2 +- include/SMaterial.h | 1 + include/coreutil.h | 6 +- include/irrArray.h | 24 +-- source/Irrlicht/CAnimatedMeshMD3.cpp | 2 +- source/Irrlicht/CAnimatedMeshMD3.h | 2 +- source/Irrlicht/CB3DMeshWriter.cpp | 4 +- source/Irrlicht/CB3DMeshWriter.h | 2 +- source/Irrlicht/CColorConverter.cpp | 178 +++++++++---------- source/Irrlicht/CColorConverter.h | 74 ++++---- source/Irrlicht/CD3D9Driver.cpp | 9 +- source/Irrlicht/CD3D9Driver.h | 2 +- source/Irrlicht/CD3D9Texture.cpp | 4 +- source/Irrlicht/CGUIListBox.cpp | 7 - source/Irrlicht/CGUIListBox.h | 19 +- source/Irrlicht/CGUIMenu.cpp | 5 + source/Irrlicht/CImage.cpp | 12 +- source/Irrlicht/CImageLoaderBMP.cpp | 9 +- source/Irrlicht/CImageLoaderDDS.cpp | 4 +- source/Irrlicht/CImageLoaderJPG.cpp | 23 ++- source/Irrlicht/CImageLoaderPNG.cpp | 3 + source/Irrlicht/CImageLoaderPVR.cpp | 4 +- source/Irrlicht/CImageLoaderTGA.cpp | 6 + source/Irrlicht/CImageWriterBMP.cpp | 2 +- source/Irrlicht/CImageWriterJPG.cpp | 2 +- source/Irrlicht/CImageWriterTGA.cpp | 4 +- source/Irrlicht/CIrrDeviceWin32.cpp | 12 +- source/Irrlicht/CIrrMeshFileLoader.cpp | 10 +- source/Irrlicht/CNullDriver.cpp | 2 +- source/Irrlicht/CNullDriver.h | 7 +- source/Irrlicht/COGLES2Driver.cpp | 4 +- source/Irrlicht/COGLES2Driver.h | 2 +- source/Irrlicht/COGLESDriver.cpp | 4 +- source/Irrlicht/COGLESDriver.h | 2 +- source/Irrlicht/COctreeTriangleSelector.cpp | 4 +- source/Irrlicht/COpenGLCoreTexture.h | 6 +- source/Irrlicht/COpenGLDriver.cpp | 13 +- source/Irrlicht/COpenGLDriver.h | 4 +- source/Irrlicht/CSceneManager.cpp | 2 +- source/Irrlicht/CSoftwareDriver2.cpp | 4 +- source/Irrlicht/CSoftwareDriver2.h | 2 +- source/Irrlicht/CTerrainTriangleSelector.cpp | 6 +- source/Irrlicht/CTextSceneNode.cpp | 15 +- source/Irrlicht/CTriangleSelector.cpp | 8 +- source/Irrlicht/CWebGL1Driver.cpp | 2 +- source/Irrlicht/CWebGL1Driver.h | 2 +- source/Irrlicht/Irrlicht.ruleset | 3 +- tests/tests-last-passed-at.txt | 4 +- 57 files changed, 337 insertions(+), 282 deletions(-) diff --git a/changes.txt b/changes.txt index 1aee101..03b0f88 100644 --- a/changes.txt +++ b/changes.txt @@ -11,6 +11,11 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point) -------------------------- Changes in 1.9 (not yet released) +- core::array::linear_search and linear_reverse_search can now work with any types as long as corresponding operator== is implemented. +- Add checks for sane image sizes in some image loaders (so far: bmp, jpg, tga, png). + Thanks @sfan5 for the original patch (got modified a bit): https://github.com/minetest/irrlicht/commit/dbd39120e7ed8c0c97e48e2df62347627f3c1d42 +- Add IImage::checkDataSizeLimit and make IImage getDataSizeFromFormat return size_t so image loaders can check if sizes are sane. +- Fix crash with large jpg files. Based somewhat on a patch in Minetest from sfan5 https://github.com/minetest/irrlicht/commit/594de9915346a87f67cd94e28c7933993efb5d3b - COSOperator::getSystemMemory now returns some value on OSX (thought same for total and available). Thanks @sfan5 for patch https://irrlicht.sourceforge.io/forum/viewtopic.php?f=2&t=52819 and https://github.com/minetest/irrlicht/commit/e469c54f76f6d24f92389b4e8a27b9cce7152888 - Fix CVertexBuffer::setType switching types for non-empty arrays. Before we had some bad casts which could result in random initializing of some vertex data. diff --git a/include/IAnimatedMeshMD3.h b/include/IAnimatedMeshMD3.h index 1e27fbc..13a42c8 100644 --- a/include/IAnimatedMeshMD3.h +++ b/include/IAnimatedMeshMD3.h @@ -186,7 +186,7 @@ namespace scene SMD3QuaternionTag* get(const core::stringc& name) { SMD3QuaternionTag search ( name ); - s32 index = Container.linear_search ( search ); + const s32 index = Container.linear_search ( search ); if ( index >= 0 ) return &Container[index]; return 0; @@ -199,7 +199,7 @@ namespace scene void set_used(u32 new_size) { - s32 diff = (s32) new_size - (s32) Container.allocated_size(); + const s32 diff = (s32) new_size - (s32) Container.allocated_size(); if ( diff > 0 ) { SMD3QuaternionTag e(""); diff --git a/include/IGUIElement.h b/include/IGUIElement.h index aa1e892..9ad6126 100644 --- a/include/IGUIElement.h +++ b/include/IGUIElement.h @@ -81,7 +81,7 @@ public: { const core::rect& r2 = Parent->getAbsolutePosition(); - core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height)); + const core::dimension2df d((f32)(r2.getSize().Width), (f32)(r2.getSize().Height)); if (AlignLeft == EGUIA_SCALE) ScaleRect.UpperLeftCorner.X = (f32)r.UpperLeftCorner.X / d.Width; @@ -194,9 +194,8 @@ public: if (Parent) { - core::rect r(Parent->getAbsolutePosition()); - - core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); + const core::rect r(Parent->getAbsolutePosition()); + const core::dimension2df d((f32)r.getSize().Width, (f32)r.getSize().Height); if (AlignLeft == EGUIA_SCALE) ScaleRect.UpperLeftCorner.X = (f32)DesiredRect.UpperLeftCorner.X / d.Width; diff --git a/include/IGUIListBox.h b/include/IGUIListBox.h index a74b449..466f286 100644 --- a/include/IGUIListBox.h +++ b/include/IGUIListBox.h @@ -49,14 +49,18 @@ namespace gui //! returns string of a list item. the may id be a value from 0 to itemCount-1 virtual const wchar_t* getListItem(u32 id) const = 0; - //! adds an list item, returns id of item - virtual u32 addItem(const wchar_t* text) = 0; - //! adds an list item with an icon /** \param text Text of list entry \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon \return The id of the new created item */ - virtual u32 addItem(const wchar_t* text, s32 icon) = 0; + virtual u32 addItem(const wchar_t* text, s32 icon=-1) = 0; + + //! Insert the item at the given index + /** \return The index on success or -1 on failure. */ + virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) = 0; + + //! set the item at the given index + virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) = 0; //! Removes an item from the list virtual void removeItem(u32 index) = 0; @@ -114,13 +118,6 @@ namespace gui //! return the default color which is used for the given colorType virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const = 0; - //! set the item at the given index - virtual void setItem(u32 index, const wchar_t* text, s32 icon) = 0; - - //! Insert the item at the given index - /** \return The index on success or -1 on failure. */ - virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) = 0; - //! Swap the items at the given indices virtual void swapItems(u32 index1, u32 index2) = 0; diff --git a/include/IImage.h b/include/IImage.h index 450b3e4..d275f9d 100644 --- a/include/IImage.h +++ b/include/IImage.h @@ -84,7 +84,7 @@ public: } //! Returns image data size in bytes - u32 getImageDataSizeInBytes() const + size_t getImageDataSizeInBytes() const { return getDataSizeFromFormat(Format, Size.Width, Size.Height); } @@ -295,7 +295,7 @@ public: } else { - u32 dataSize = 0; + size_t dataSize = 0; u32 width = Size.Width; u32 height = Size.Height; @@ -445,43 +445,57 @@ public: } } - //! calculate image data size in bytes for selected format, width and height. - static u32 getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height) + //! You should not create images where the result of getDataSizeFromFormat doesn't pass this function + /** Note that CImage does not yet check for this, but going beyond this limit is not supported well. + Image loaders should check for this. + If you don't have the format yet then checking width*height*bytes_per_pixel is mostly fine, but make + sure to work with size_t so it doesn't clip the result to u32 too early. + \return true when dataSize is small enough that it should be fine. */ + static bool checkDataSizeLimit(size_t dataSize) { - u32 imageSize = 0; + // 2gb for now. Could be we could do more on some platforms, but we still will run into + // problems right now then for example in then color converter (which currently still uses + // s32 for sizes). + return (size_t)(s32)(dataSize) == dataSize; + } + + //! calculate image data size in bytes for selected format, width and height. + static size_t getDataSizeFromFormat(ECOLOR_FORMAT format, u32 width, u32 height) + { + size_t imageSize = 0; switch (format) { case ECF_DXT1: - imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 8; + imageSize = (size_t)((width + 3) / 4) * ((height + 3) / 4) * 8; break; case ECF_DXT2: case ECF_DXT3: case ECF_DXT4: case ECF_DXT5: - imageSize = ((width + 3) / 4) * ((height + 3) / 4) * 16; + imageSize = (size_t)((width + 3) / 4) * ((height + 3) / 4) * 16; break; case ECF_PVRTC_RGB2: case ECF_PVRTC_ARGB2: - imageSize = (core::max_(width, 16) * core::max_(height, 8) * 2 + 7) / 8; + imageSize = ((size_t)core::max_(width, 16) * core::max_(height, 8) * 2 + 7) / 8; break; case ECF_PVRTC_RGB4: case ECF_PVRTC_ARGB4: - imageSize = (core::max_(width, 8) * core::max_(height, 8) * 4 + 7) / 8; + imageSize = ((size_t)core::max_(width, 8) * core::max_(height, 8) * 4 + 7) / 8; break; case ECF_PVRTC2_ARGB2: - imageSize = core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8; + imageSize = (size_t)core::ceil32(width / 8.0f) * core::ceil32(height / 4.0f) * 8; break; case ECF_PVRTC2_ARGB4: case ECF_ETC1: case ECF_ETC2_RGB: - imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8; + imageSize = (size_t)core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 8; break; case ECF_ETC2_ARGB: - imageSize = core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16; + imageSize = (size_t)core::ceil32(width / 4.0f) * core::ceil32(height / 4.0f) * 16; break; default: // uncompressed formats - imageSize = getBitsPerPixelFromFormat(format) / 8 * width; + imageSize = (size_t)getBitsPerPixelFromFormat(format) / 8 * width; imageSize *= height; break; } diff --git a/include/IProfiler.h b/include/IProfiler.h index bfc2430..21a5dea 100644 --- a/include/IProfiler.h +++ b/include/IProfiler.h @@ -293,8 +293,8 @@ void IProfiler::stop(s32 id) { if ( Timer ) { - u32 timeNow = Timer->getRealTime(); - s32 idx = ProfileDatas.binary_search(SProfileData(id)); + const u32 timeNow = Timer->getRealTime(); + const s32 idx = ProfileDatas.binary_search(SProfileData(id)); if ( idx >= 0 ) { SProfileData &data = ProfileDatas[idx]; @@ -303,7 +303,7 @@ void IProfiler::stop(s32 id) { // update data for this id ++data.CountCalls; - u32 diffTime = timeNow - data.LastTimeStarted; + const u32 diffTime = timeNow - data.LastTimeStarted; data.TimeSum += diffTime; if ( diffTime > data.LongestTime ) data.LongestTime = diffTime; @@ -336,7 +336,7 @@ s32 IProfiler::add(const core::stringw &name, const core::stringw &groupName) } else { - s32 id = NextAutoId; + const s32 id = NextAutoId; --NextAutoId; add( id, name, groupName ); return id; @@ -400,7 +400,7 @@ bool IProfiler::findDataIndex(u32 & result, const core::stringw &name) const const SProfileData* IProfiler::getProfileDataById(u32 id) { SProfileData data(id); - s32 idx = ProfileDatas.binary_search(data); + const s32 idx = ProfileDatas.binary_search(data); if ( idx >= 0 ) return &ProfileDatas[idx]; return NULL; diff --git a/include/ISceneCollisionManager.h b/include/ISceneCollisionManager.h index 067581f..7e59fdc 100644 --- a/include/ISceneCollisionManager.h +++ b/include/ISceneCollisionManager.h @@ -30,7 +30,7 @@ namespace scene core::triangle3df Triangle; //! Triangle selector which contained the colliding triangle (useful when having MetaTriangleSelector) - ITriangleSelector* TriangleSelector; + const ITriangleSelector* TriangleSelector; //! Node which contained the triangle (is 0 when selector doesn't have that information) ISceneNode* Node; diff --git a/include/ISceneNode.h b/include/ISceneNode.h index f26cc8a..e53d3c6 100644 --- a/include/ISceneNode.h +++ b/include/ISceneNode.h @@ -736,7 +736,7 @@ namespace scene IsVisible = in->getAttributeAsBool("Visible", IsVisible); if (in->existsAttribute("AutomaticCulling")) { - s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling", + const s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames); if (tmpState != -1) AutomaticCullingState = (u32)tmpState; diff --git a/include/ITriangleSelector.h b/include/ITriangleSelector.h index dcc7333..8ae226b 100644 --- a/include/ITriangleSelector.h +++ b/include/ITriangleSelector.h @@ -49,7 +49,7 @@ struct SCollisionTriangleRange irr::u32 RangeSize; //! Real selector which contained those triangles (useful when working with MetaTriangleSelector) - ITriangleSelector* Selector; + const ITriangleSelector* Selector; //! SceneNode from which the triangles are from ISceneNode* SceneNode; diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index f67b998..b289568 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -460,7 +460,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const =0; //! Create render target. virtual IRenderTarget* addRenderTarget() = 0; diff --git a/include/SMaterial.h b/include/SMaterial.h index 788c898..66aa7f4 100644 --- a/include/SMaterial.h +++ b/include/SMaterial.h @@ -618,6 +618,7 @@ namespace video PolygonOffsetDirection = EPO_BACK; PolygonOffsetSlopeScale = value?1.f:0.f; PolygonOffsetDepthBias = value?1.f:0.f; + break; default: break; } diff --git a/include/coreutil.h b/include/coreutil.h index 74e27f1..bf2cb1a 100644 --- a/include/coreutil.h +++ b/include/coreutil.h @@ -47,7 +47,7 @@ inline bool hasFileExtension(const io::path& filename, const io::path& ext0, //! cut the filename extension from a source file path and store it in a dest file path inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source ) { - s32 endPos = source.findLast ( '.' ); + const s32 endPos = source.findLast ( '.' ); dest = source.subString ( 0, endPos < 0 ? source.size () : endPos ); return dest; } @@ -55,7 +55,7 @@ inline io::path& cutFilenameExtension ( io::path &dest, const io::path &source ) //! get the filename extension from a file path inline io::path& getFileNameExtension ( io::path &dest, const io::path &source ) { - s32 endPos = source.findLast ( '.' ); + const s32 endPos = source.findLast ( '.' ); if ( endPos < 0 ) dest = ""; else @@ -176,7 +176,7 @@ static inline io::path mergeFilename(const io::path& path, const io::path& filen if ( !result.empty() ) { - fschar_t last = result.lastChar(); + const fschar_t last = result.lastChar(); if ( last != IRR_TEXT('/') && last != IRR_TEXT('\\') ) result += IRR_TEXT('/'); } diff --git a/include/irrArray.h b/include/irrArray.h index 1e358fd..340e372 100644 --- a/include/irrArray.h +++ b/include/irrArray.h @@ -526,29 +526,31 @@ public: } - //! Finds an element in linear time, which is very slow. - /** Use binary_search for faster finding. Only works if ==operator is - implemented. - \param element Element to search for. + //! Finds an element by searching linearly from array start to end + /** Can be slow with large arrays, try binary_search for those. + Only works if corresponding operator== is implemented. + \param element Element to search for. \return Position of the searched element if it was found, otherwise -1 is returned. */ - s32 linear_search(const T& element) const + template + s32 linear_search(const E& element) const { for (u32 i=0; i + s32 linear_reverse_search(const E& element) const { for (s32 i=used-1; i>=0; --i) if (data[i] == element) diff --git a/source/Irrlicht/CAnimatedMeshMD3.cpp b/source/Irrlicht/CAnimatedMeshMD3.cpp index 0d3a091..329500c 100644 --- a/source/Irrlicht/CAnimatedMeshMD3.cpp +++ b/source/Irrlicht/CAnimatedMeshMD3.cpp @@ -211,7 +211,7 @@ IMesh* CAnimatedMeshMD3::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, //! create a Irrlicht MeshBuffer for a MD3 MeshBuffer IMeshBuffer * CAnimatedMeshMD3::createMeshBuffer(const SMD3MeshBuffer* source, - io::IFileSystem* fs, video::IVideoDriver * driver) + const io::IFileSystem* fs, video::IVideoDriver * driver) { SMeshBufferLightMap * dest = new SMeshBufferLightMap(); dest->Vertices.set_used(source->MeshHeader.numVertices); diff --git a/source/Irrlicht/CAnimatedMeshMD3.h b/source/Irrlicht/CAnimatedMeshMD3.h index c3f2f92..bea2ea9 100644 --- a/source/Irrlicht/CAnimatedMeshMD3.h +++ b/source/Irrlicht/CAnimatedMeshMD3.h @@ -117,7 +117,7 @@ namespace scene SMD3QuaternionTagList TagListIPol; IMeshBuffer* createMeshBuffer(const SMD3MeshBuffer* source, - io::IFileSystem* fs, video::IVideoDriver* driver); + const io::IFileSystem* fs, video::IVideoDriver* driver); void buildVertexArray(u32 frameA, u32 frameB, f32 interpolate, const SMD3MeshBuffer* source, diff --git a/source/Irrlicht/CB3DMeshWriter.cpp b/source/Irrlicht/CB3DMeshWriter.cpp index d640e78..92c297a 100644 --- a/source/Irrlicht/CB3DMeshWriter.cpp +++ b/source/Irrlicht/CB3DMeshWriter.cpp @@ -98,7 +98,7 @@ bool CB3DMeshWriter::writeMesh(io::IWriteFile* file, IMesh* const mesh, s32 flag u32 numTexture = texs.size(); for (u32 i = 0; i < numTexture; i++) { - file->write(texs[i].TextureName.c_str(), texs[i].TextureName.size() + 1); + file->write(texs[i].TextureName.c_str(), (size_t)texs[i].TextureName.size() + 1); file->write(&texs[i].Flags, 7*4); } @@ -498,7 +498,7 @@ core::array CB3DMeshWriter::getRootJoints(const ISkinnedM return roots; } -u32 CB3DMeshWriter::getUVlayerCount(IMesh* mesh) +u32 CB3DMeshWriter::getUVlayerCount(const IMesh* mesh) { const u32 numBeshBuffers = mesh->getMeshBufferCount(); for (u32 i = 0; i < numBeshBuffers; i++) diff --git a/source/Irrlicht/CB3DMeshWriter.h b/source/Irrlicht/CB3DMeshWriter.h index 12c7324..48fe539 100644 --- a/source/Irrlicht/CB3DMeshWriter.h +++ b/source/Irrlicht/CB3DMeshWriter.h @@ -37,7 +37,7 @@ private: u32 getJointChunkSize(const ISkinnedMesh* mesh, ISkinnedMesh::SJoint* joint); core::array getRootJoints(const ISkinnedMesh* mesh); - u32 getUVlayerCount(IMesh *mesh); + u32 getUVlayerCount(const IMesh *mesh); ISkinnedMesh* getSkinned (IMesh *mesh); inline void writeVector2(io::IWriteFile* file, const core::vector2df& vec); diff --git a/source/Irrlicht/CColorConverter.cpp b/source/Irrlicht/CColorConverter.cpp index f1e5411..243a8c6 100644 --- a/source/Irrlicht/CColorConverter.cpp +++ b/source/Irrlicht/CColorConverter.cpp @@ -13,21 +13,21 @@ namespace video { //! converts a monochrome bitmap to A1R5G5B5 data -void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad, bool flip) +void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad, bool flip) { if (!in || !out) return; if (flip) - out += width * height; + out += (size_t)width * height; - for (s32 y=0; y>shift & 0x01 ? (s16)0xffff : (s16)0x8000; @@ -50,21 +50,21 @@ void CColorConverter::convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 //! converts a 4 bit palettized image to A1R5G5B5 -void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) +void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, const s32* palette, u32 linepad, bool flip) { if (!in || !out || !palette) return; if (flip) - out += width*height; + out += (size_t)width*height; - for (s32 y=0; y> shift) & 0xf)]); @@ -89,19 +89,19 @@ void CColorConverter::convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 //! converts a 8 bit palettized image into A1R5G5B5 -void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad, bool flip) +void CColorConverter::convert8BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, const s32* palette, u32 linepad, bool flip) { if (!in || !out || !palette) return; if (flip) - out += width * height; + out += (size_t)width * height; - for (s32 y=0; y> 15)&0x1)<<31) | (((t >> 10)&0x1F)<<19) | @@ -299,20 +299,20 @@ void CColorConverter::convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s //! copies X8R8G8B8 32 bit data -void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip) +void CColorConverter::convert32BitTo32Bit(const s32* in, s32* out, u32 width, u32 height, u32 linepad, bool flip) { if (!in || !out) return; if (flip) - out += width * height; + out += (size_t)width * height; - for (s32 y=0; y> 7; dB[1] = (*sB & 0x03e0) >> 2; @@ -342,12 +342,12 @@ void CColorConverter::convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { dB[0] = (*sB & 0x7c00) >> 7; dB[1] = (*sB & 0x03e0) >> 2; @@ -358,47 +358,47 @@ void CColorConverter::convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A1R5G5B5toR5G5B5A1(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A1R5G5B5toR5G5B5A1(const void* sP, u32 sN, void* dP) { const u16* sB = (const u16*)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { *dB = (*sB<<1)|(*sB>>15); ++sB; ++dB; } } -void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A1R5G5B5toA8R8G8B8(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) *dB++ = A1R5G5B5toA8R8G8B8(*sB++); } -void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A1R5G5B5toA1R5G5B5(const void* sP, u32 sN, void* dP) { memcpy(dP, sP, sN * 2); } -void CColorConverter::convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A1R5G5B5toR5G6B5(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) *dB++ = A1R5G5B5toR5G6B5(*sB++); } -void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, u32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { // sB[3] is alpha dB[0] = sB[2]; @@ -410,12 +410,12 @@ void CColorConverter::convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, u32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { // sB[3] is alpha dB[0] = sB[0]; @@ -427,26 +427,26 @@ void CColorConverter::convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toA8R8G8B8(const void* sP, u32 sN, void* dP) { memcpy(dP, sP, sN * 4); } -void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toA1R5G5B5(const void* sP, u32 sN, void* dP) { u32* sB = (u32*)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) *dB++ = A8R8G8B8toA1R5G5B5(*sB++); } -void CColorConverter::convert_A8R8G8B8toA1B5G5R5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toA1B5G5R5(const void* sP, u32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { s32 r = sB[0] >> 3; s32 g = sB[1] >> 3; @@ -460,12 +460,12 @@ void CColorConverter::convert_A8R8G8B8toA1B5G5R5(const void* sP, s32 sN, void* d } } -void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, u32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { s32 r = sB[2] >> 3; s32 g = sB[1] >> 2; @@ -478,12 +478,12 @@ void CColorConverter::convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, u32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { u8 r = sB[2] & 0xe0; u8 g = (sB[1] & 0xe0) >> 3; @@ -496,17 +496,17 @@ void CColorConverter::convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R8G8B8toR8G8B8(const void* sP, u32 sN, void* dP) { memcpy(dP, sP, sN * 3); } -void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, u32 sN, void* dP) { u8* sB = (u8* )sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { *dB = 0xff000000 | (sB[0]<<16) | (sB[1]<<8) | sB[2]; @@ -515,12 +515,12 @@ void CColorConverter::convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, u32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { s32 r = sB[0] >> 3; s32 g = sB[1] >> 3; @@ -533,12 +533,12 @@ void CColorConverter::convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, u32 sN, void* dP) { u8* sB = (u8* )sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { *dB = 0xff000000 | (sB[2]<<16) | (sB[1]<<8) | sB[0]; @@ -547,36 +547,36 @@ void CColorConverter::convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_A8R8G8B8toR8G8B8A8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toR8G8B8A8(const void* sP, u32 sN, void* dP) { const u32* sB = (const u32*)sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { *dB++ = (*sB<<8) | (*sB>>24); ++sB; } } -void CColorConverter::convert_A8R8G8B8toA8B8G8R8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_A8R8G8B8toA8B8G8R8(const void* sP, u32 sN, void* dP) { const u32* sB = (const u32*)sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { *dB++ = (*sB&0xff00ff00)|((*sB&0x00ff0000)>>16)|((*sB&0x000000ff)<<16); ++sB; } } -void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, u32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { dB[0] = sB[3]; dB[1] = sB[2]; @@ -589,12 +589,12 @@ void CColorConverter::convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* d } -void CColorConverter::convert_R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R8G8B8toB8G8R8(const void* sP, u32 sN, void* dP) { u8* sB = (u8*)sP; u8* dB = (u8*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { dB[2] = sB[0]; dB[1] = sB[1]; @@ -605,12 +605,12 @@ void CColorConverter::convert_R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, u32 sN, void* dP) { u8 * sB = (u8 *)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { s32 r = sB[0] >> 3; s32 g = sB[1] >> 2; @@ -623,17 +623,17 @@ void CColorConverter::convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R5G6B5toR5G6B5(const void* sP, u32 sN, void* dP) { memcpy(dP, sP, sN * 2); } -void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { dB[0] = (*sB & 0xf800) >> 8; dB[1] = (*sB & 0x07e0) >> 3; @@ -644,12 +644,12 @@ void CColorConverter::convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u8 * dB = (u8 *)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) { dB[2] = (*sB & 0xf800) >> 8; dB[1] = (*sB & 0x07e0) >> 3; @@ -660,21 +660,21 @@ void CColorConverter::convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP) } } -void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R5G6B5toA8R8G8B8(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u32* dB = (u32*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) *dB++ = R5G6B5toA8R8G8B8(*sB++); } -void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP) +void CColorConverter::convert_R5G6B5toA1R5G5B5(const void* sP, u32 sN, void* dP) { u16* sB = (u16*)sP; u16* dB = (u16*)dP; - for (s32 x = 0; x < sN; ++x) + for (u32 x = 0; x < sN; ++x) *dB++ = R5G6B5toA1R5G5B5(*sB++); } @@ -736,7 +736,7 @@ bool CColorConverter::canConvertFormat(ECOLOR_FORMAT sourceFormat, ECOLOR_FORMAT return false; } -void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN, +void CColorConverter::convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, u32 sN, void* dP, ECOLOR_FORMAT dF) { // please also update can_convert_viaFormat when adding new conversions diff --git a/source/Irrlicht/CColorConverter.h b/source/Irrlicht/CColorConverter.h index 55662d3..d9293c8 100644 --- a/source/Irrlicht/CColorConverter.h +++ b/source/Irrlicht/CColorConverter.h @@ -18,34 +18,34 @@ class CColorConverter public: //! converts a monochrome bitmap to A1R5G5B5 - static void convert1BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); + static void convert1BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, u32 linepad=0, bool flip=false); //! converts a 4 bit palettized image to A1R5G5B5 - static void convert4BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); + static void convert4BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, const s32* palette, u32 linepad=0, bool flip=false); //! converts a 8 bit palettized image to A1R5G5B5 - static void convert8BitTo16Bit(const u8* in, s16* out, s32 width, s32 height, const s32* palette, s32 linepad=0, bool flip=false); + static void convert8BitTo16Bit(const u8* in, s16* out, u32 width, u32 height, const s32* palette, u32 linepad=0, bool flip=false); //! converts a 8 bit palettized or non palettized image (A8) into R8G8B8 - static void convert8BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad = 0, bool flip=false); + static void convert8BitTo24Bit(const u8* in, u8* out, u32 width, u32 height, const u8* palette, u32 linepad = 0, bool flip=false); //! converts a 8 bit palettized or non palettized image (A8) into A8R8G8B8 - static void convert8BitTo32Bit(const u8* in, u8* out, s32 width, s32 height, const u8* palette, s32 linepad = 0, bool flip=false); + static void convert8BitTo32Bit(const u8* in, u8* out, u32 width, u32 height, const u8* palette, u32 linepad = 0, bool flip=false); //! converts R8G8B8 16 bit data to A1R5G5B5 data - static void convert16BitTo16Bit(const s16* in, s16* out, s32 width, s32 height, s32 linepad=0, bool flip=false); + static void convert16BitTo16Bit(const s16* in, s16* out, u32 width, u32 height, u32 linepad=0, bool flip=false); //! copies R8G8B8 24 bit data to 24 data, and flips and //! mirrors the image during the process. - static void convert24BitTo24Bit(const u8* in, u8* out, s32 width, s32 height, s32 linepad=0, bool flip=false, bool bgr=false); + static void convert24BitTo24Bit(const u8* in, u8* out, u32 width, u32 height, u32 linepad=0, bool flip=false, bool bgr=false); //! Resizes the surface to a new size and converts it at the same time //! to an A8R8G8B8 format, returning the pointer to the new buffer. - static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, s32 newWidth, s32 newHeight, s32 currentWidth, s32 currentHeight); + static void convert16bitToA8R8G8B8andResize(const s16* in, s32* out, u32 newWidth, u32 newHeight, u32 currentWidth, u32 currentHeight); //! copies X8R8G8B8 32 bit data, and flips and //! mirrors the image during the process. - static void convert32BitTo32Bit(const s32* in, s32* out, s32 width, s32 height, s32 linepad, bool flip=false); + static void convert32BitTo32Bit(const s32* in, s32* out, u32 width, u32 height, u32 linepad, bool flip=false); //! Functions for converting one image format to another efficiently @@ -57,37 +57,37 @@ public: //! \param sN number of source pixels to copy //! \param dP pointer to destination data buffer. must be big enough //! to hold sN pixels in the output format. - static void convert_A1R5G5B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toR5G5B5A1(const void* sP, s32 sN, void* dP); - static void convert_A1R5G5B5toR5G6B5(const void* sP, s32 sN, void* dP); + static void convert_A1R5G5B5toR8G8B8(const void* sP, u32 sN, void* dP); + static void convert_A1R5G5B5toB8G8R8(const void* sP, u32 sN, void* dP); + static void convert_A1R5G5B5toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_A1R5G5B5toA1R5G5B5(const void* sP, u32 sN, void* dP); + static void convert_A1R5G5B5toR5G6B5(const void* sP, u32 sN, void* dP); + static void convert_A1R5G5B5toR5G5B5A1(const void* sP, u32 sN, void* dP); - static void convert_A8R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA1B5G5R5(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toR8G8B8(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toB8G8R8(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toA1R5G5B5(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toA1B5G5R5(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toR5G6B5(const void* sP, u32 sN, void* dP); - static void convert_A8R8G8B8toR3G3B2(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_R8G8B8toR5G6B5(const void* sP, s32 sN, void* dP); - static void convert_B8G8R8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_B8G8R8A8toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toR8G8B8A8(const void* sP, s32 sN, void* dP); - static void convert_A8R8G8B8toA8B8G8R8(const void* sP, s32 sN, void* dP); + static void convert_A8R8G8B8toR3G3B2(const void* sP, u32 sN, void* dP); + static void convert_R8G8B8toR8G8B8(const void* sP, u32 sN, void* dP); + static void convert_R8G8B8toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_R8G8B8toA1R5G5B5(const void* sP, u32 sN, void* dP); + static void convert_R8G8B8toB8G8R8(const void* sP, u32 sN, void* dP); + static void convert_R8G8B8toR5G6B5(const void* sP, u32 sN, void* dP); + static void convert_B8G8R8toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_B8G8R8A8toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toR8G8B8A8(const void* sP, u32 sN, void* dP); + static void convert_A8R8G8B8toA8B8G8R8(const void* sP, u32 sN, void* dP); - static void convert_R5G6B5toR5G6B5(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toR8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toB8G8R8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA8R8G8B8(const void* sP, s32 sN, void* dP); - static void convert_R5G6B5toA1R5G5B5(const void* sP, s32 sN, void* dP); - static void convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, s32 sN, + static void convert_R5G6B5toR5G6B5(const void* sP, u32 sN, void* dP); + static void convert_R5G6B5toR8G8B8(const void* sP, u32 sN, void* dP); + static void convert_R5G6B5toB8G8R8(const void* sP, u32 sN, void* dP); + static void convert_R5G6B5toA8R8G8B8(const void* sP, u32 sN, void* dP); + static void convert_R5G6B5toA1R5G5B5(const void* sP, u32 sN, void* dP); + static void convert_viaFormat(const void* sP, ECOLOR_FORMAT sF, u32 sN, void* dP, ECOLOR_FORMAT dF); // Check if convert_viaFormat is usable static bool canConvertFormat(ECOLOR_FORMAT sourceFormat, ECOLOR_FORMAT destFormat); diff --git a/source/Irrlicht/CD3D9Driver.cpp b/source/Irrlicht/CD3D9Driver.cpp index 838b39e..8a98dce 100644 --- a/source/Irrlicht/CD3D9Driver.cpp +++ b/source/Irrlicht/CD3D9Driver.cpp @@ -1253,13 +1253,10 @@ void CD3D9Driver::updateOcclusionQuery(scene::ISceneNode* node, bool block) /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 CD3D9Driver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 CD3D9Driver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); - if (index != -1) - return OcclusionQueries[index].Result; - else - return ~0; + const s32 index = OcclusionQueries.linear_search(node); + return index < 0 ? ~0 : OcclusionQueries[index].Result; } diff --git a/source/Irrlicht/CD3D9Driver.h b/source/Irrlicht/CD3D9Driver.h index 67dc2d8..c25ca01 100644 --- a/source/Irrlicht/CD3D9Driver.h +++ b/source/Irrlicht/CD3D9Driver.h @@ -115,7 +115,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! Create render target. virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE; diff --git a/source/Irrlicht/CD3D9Texture.cpp b/source/Irrlicht/CD3D9Texture.cpp index 7b31fcc..da398a0 100644 --- a/source/Irrlicht/CD3D9Texture.cpp +++ b/source/Irrlicht/CD3D9Texture.cpp @@ -335,7 +335,7 @@ void CD3D9Texture::regenerateMipMapLevels(void* data, u32 layer) u32 width = Size.Width; u32 height = Size.Height; u8* tmpData = static_cast(data); - u32 dataSize = 0; + size_t dataSize = 0; u32 level = 0; do @@ -714,7 +714,7 @@ void CD3D9Texture::uploadTexture(void* data, u32 mipmapLevel, u32 layer) u32 width = Size.Width >> mipmapLevel; u32 height = Size.Height >> mipmapLevel; - u32 dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height); + size_t dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height); HRESULT hr = 0; diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 65434fa..7ec1869 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -97,13 +97,6 @@ s32 CGUIListBox::getIcon(u32 id) const } -//! adds a list item, returns id of item -u32 CGUIListBox::addItem(const wchar_t* text) -{ - return addItem(text, -1); -} - - //! adds a list item, returns id of item void CGUIListBox::removeItem(u32 id) { diff --git a/source/Irrlicht/CGUIListBox.h b/source/Irrlicht/CGUIListBox.h index 0afe81d..10a9e5f 100644 --- a/source/Irrlicht/CGUIListBox.h +++ b/source/Irrlicht/CGUIListBox.h @@ -36,9 +36,6 @@ namespace gui //! returns string of a list item. the id may be a value from 0 to itemCount-1 virtual const wchar_t* getListItem(u32 id) const IRR_OVERRIDE; - //! adds an list item, returns id of item - virtual u32 addItem(const wchar_t* text) IRR_OVERRIDE; - //! clears the list virtual void clear() IRR_OVERRIDE; @@ -62,7 +59,14 @@ namespace gui //! \param icon Sprite index of the Icon within the current sprite bank. Set it to -1 if you want no icon //! \return //! returns the id of the new created item - virtual u32 addItem(const wchar_t* text, s32 icon) IRR_OVERRIDE; + virtual u32 addItem(const wchar_t* text, s32 icon=-1) IRR_OVERRIDE; + + //! Insert the item at the given index + //! Return the index on success or -1 on failure. + virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon=-1) IRR_OVERRIDE; + + //! set the item at the given index + virtual void setItem(u32 index, const wchar_t* text, s32 icon=-1) IRR_OVERRIDE; //! Returns the icon of an item virtual s32 getIcon(u32 id) const IRR_OVERRIDE; @@ -115,13 +119,6 @@ namespace gui //! return the default color which is used for the given colorType virtual video::SColor getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) const IRR_OVERRIDE; - //! set the item at the given index - virtual void setItem(u32 index, const wchar_t* text, s32 icon) IRR_OVERRIDE; - - //! Insert the item at the given index - //! Return the index on success or -1 on failure. - virtual s32 insertItem(u32 index, const wchar_t* text, s32 icon) IRR_OVERRIDE; - //! Swap the items at the given indices virtual void swapItems(u32 index1, u32 index2) IRR_OVERRIDE; diff --git a/source/Irrlicht/CGUIMenu.cpp b/source/Irrlicht/CGUIMenu.cpp index 37e9ec3..ce235c7 100644 --- a/source/Irrlicht/CGUIMenu.cpp +++ b/source/Irrlicht/CGUIMenu.cpp @@ -42,6 +42,9 @@ void CGUIMenu::draw() return; IGUISkin* skin = Environment->getSkin(); + if ( !skin ) + return; + IGUIFont* font = skin->getFont(EGDF_MENU); if (font != LastFont) @@ -199,6 +202,8 @@ void CGUIMenu::recalculateSize() IGUISkin* skin = Environment->getSkin(); + if ( !skin ) + return; IGUIFont* font = skin->getFont(EGDF_MENU); if (!font) diff --git a/source/Irrlicht/CImage.cpp b/source/Irrlicht/CImage.cpp index c97f35f..a076a58 100644 --- a/source/Irrlicht/CImage.cpp +++ b/source/Irrlicht/CImage.cpp @@ -24,8 +24,7 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size, void* d } else { - const u32 dataSize = getDataSizeFromFormat(Format, Size.Width, Size.Height); - + const size_t dataSize = getDataSizeFromFormat(Format, Size.Width, Size.Height); Data = new u8[align_next(dataSize,16)]; memcpy(Data, data, dataSize); DeleteMemory = true; @@ -36,7 +35,8 @@ CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size, void* d //! Constructor of empty image CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size) : IImage(format, size, true) { - Data = new u8[align_next(getDataSizeFromFormat(Format, Size.Width, Size.Height),16)]; + const size_t dataSize = getDataSizeFromFormat(Format, Size.Width, Size.Height); + Data = new u8[align_next(dataSize,16)]; DeleteMemory = true; } @@ -194,7 +194,7 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo { if (pitch==Pitch) { - memcpy(target, Data, height*pitch); + memcpy(target, Data, (size_t)height*pitch); return; } else @@ -332,8 +332,8 @@ void CImage::fill(const SColor &color) { u8 rgb[3]; CColorConverter::convert_A8R8G8B8toR8G8B8(&color, 1, rgb); - const u32 size = getImageDataSizeInBytes(); - for (u32 i=0; igetFileName(), ELL_WARNING); + goto cleanup; + } + switch(header.BPP) { case 1: @@ -348,7 +355,7 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const }; // clean up - +cleanup: delete [] paletteData; delete [] bmpData; diff --git a/source/Irrlicht/CImageLoaderDDS.cpp b/source/Irrlicht/CImageLoaderDDS.cpp index 0a4ab3d..68e1164 100644 --- a/source/Irrlicht/CImageLoaderDDS.cpp +++ b/source/Irrlicht/CImageLoaderDDS.cpp @@ -693,8 +693,8 @@ IImage* CImageLoaderDDS::loadImage(io::IReadFile* file) const s32 width, height; eDDSPixelFormat pixelFormat; ECOLOR_FORMAT format = ECF_UNKNOWN; - u32 dataSize = 0; - u32 mipMapsDataSize = 0; + size_t dataSize = 0; + size_t mipMapsDataSize = 0; bool is3D = false; bool useAlpha = false; u32 mipMapCount = 0; diff --git a/source/Irrlicht/CImageLoaderJPG.cpp b/source/Irrlicht/CImageLoaderJPG.cpp index 72ba484..0cd6a35 100644 --- a/source/Irrlicht/CImageLoaderJPG.cpp +++ b/source/Irrlicht/CImageLoaderJPG.cpp @@ -145,10 +145,13 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const return 0; core::stringc filename = file->getFileName(); + long fileSize = file->getSize(); + if ( fileSize < 3 ) + return 0; u8 **rowPtr=0; - u8* input = new u8[file->getSize()]; - file->read(input, file->getSize()); + u8* input = new u8[fileSize]; + file->read(input, fileSize); // allocate and initialize JPEG decompression object struct jpeg_decompress_struct cinfo; @@ -188,7 +191,7 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const jpeg_source_mgr jsrc; // Set up data pointer - jsrc.bytes_in_buffer = file->getSize(); + jsrc.bytes_in_buffer = fileSize; jsrc.next_input_byte = (JOCTET*)input; cinfo.src = &jsrc; @@ -225,10 +228,19 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const jpeg_start_decompress(&cinfo); // Get image data - u16 rowspan = cinfo.image_width * cinfo.out_color_components; + u32 rowspan = cinfo.image_width * cinfo.out_color_components; u32 width = cinfo.image_width; u32 height = cinfo.image_height; + if ( width > JPEG_MAX_DIMENSION || height > JPEG_MAX_DIMENSION + || !IImage::checkDataSizeLimit(IImage::getDataSizeFromFormat(ECF_R8G8B8, width, height)) + ) + { + os::Printer::log("Image dimensions too large in file", filename, ELL_ERROR); + longjmp(jerr.setjmp_buffer, 1); + } + + // Allocate memory for buffer u8* output = new u8[rowspan * height]; @@ -237,7 +249,7 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const // Create array of row pointers for lib rowPtr = new u8* [height]; - for( u32 i = 0; i < height; i++ ) + for( size_t i = 0; i < height; i++ ) rowPtr[i] = &output[ i * rowspan ]; u32 rowsRead = 0; @@ -246,6 +258,7 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const rowsRead += jpeg_read_scanlines( &cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead ); delete [] rowPtr; + rowPtr = 0; // Finish decompression jpeg_finish_decompress(&cinfo); diff --git a/source/Irrlicht/CImageLoaderPNG.cpp b/source/Irrlicht/CImageLoaderPNG.cpp index 1df1ead..08fc720 100644 --- a/source/Irrlicht/CImageLoaderPNG.cpp +++ b/source/Irrlicht/CImageLoaderPNG.cpp @@ -158,6 +158,9 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const Height=h; } + if (!IImage::checkDataSizeLimit((size_t)Width* Height * (BitDepth/8))) + png_cpexcept_error(png_ptr, "Image dimensions too large"); + // Convert palette color to true color if (ColorType==PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr); diff --git a/source/Irrlicht/CImageLoaderPVR.cpp b/source/Irrlicht/CImageLoaderPVR.cpp index 0da9300..ceae56f 100644 --- a/source/Irrlicht/CImageLoaderPVR.cpp +++ b/source/Irrlicht/CImageLoaderPVR.cpp @@ -69,7 +69,7 @@ core::array CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_ core::array mipMapsDataArray; ECOLOR_FORMAT format = ECF_UNKNOWN; - u32 dataSize = 0; + size_t dataSize = 0; file->seek(0); file->read(&header, sizeof(SPVRHeader)); @@ -216,7 +216,7 @@ core::array CImageLoaderPVR::loadImages(io::IReadFile* file, E_TEXTURE_ // read texture dataSize = 0; - long offset = 0; + size_t offset = 0; for (u32 i = 0; i < header.MipMapCount; ++i) { diff --git a/source/Irrlicht/CImageLoaderTGA.cpp b/source/Irrlicht/CImageLoaderTGA.cpp index c9b3a9d..667f40d 100644 --- a/source/Irrlicht/CImageLoaderTGA.cpp +++ b/source/Irrlicht/CImageLoaderTGA.cpp @@ -106,6 +106,12 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const header.ImageHeight = os::Byteswap::byteswap(header.ImageHeight); #endif + if (!IImage::checkDataSizeLimit((size_t)header.ImageWidth* header.ImageHeight * (header.PixelDepth/8))) + { + os::Printer::log("Image dimensions too large in file.", file->getFileName(), ELL_ERROR); + return 0; + } + // skip image identification field if (header.IdLength) file->seek(header.IdLength, true); diff --git a/source/Irrlicht/CImageWriterBMP.cpp b/source/Irrlicht/CImageWriterBMP.cpp index 84fdc7b..04d3973 100644 --- a/source/Irrlicht/CImageWriterBMP.cpp +++ b/source/Irrlicht/CImageWriterBMP.cpp @@ -62,7 +62,7 @@ bool CImageWriterBMP::writeImage(io::IWriteFile* file, IImage* image, u32 param) imageHeader.FileSize = imageHeader.BitmapDataOffset + imageHeader.BitmapDataSize; // bitmaps are stored upside down and padded so we always do this - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; + void (*CColorConverter_convertFORMATtoFORMAT)(const void*, u32, void*) = 0; switch(image->getColorFormat()) { case ECF_R8G8B8: diff --git a/source/Irrlicht/CImageWriterJPG.cpp b/source/Irrlicht/CImageWriterJPG.cpp index e1d88e4..793aed2 100644 --- a/source/Irrlicht/CImageWriterJPG.cpp +++ b/source/Irrlicht/CImageWriterJPG.cpp @@ -107,7 +107,7 @@ static void jpeg_file_dest(j_compress_ptr cinfo, io::IWriteFile* file) */ static bool writeJPEGFile(io::IWriteFile* file, IImage* image, u32 quality) { - void (*format)(const void*, s32, void*) = 0; + void (*format)(const void*, u32, void*) = 0; switch( image->getColorFormat () ) { case ECF_R8G8B8: diff --git a/source/Irrlicht/CImageWriterTGA.cpp b/source/Irrlicht/CImageWriterTGA.cpp index dd8c070..35f7afe 100644 --- a/source/Irrlicht/CImageWriterTGA.cpp +++ b/source/Irrlicht/CImageWriterTGA.cpp @@ -55,10 +55,10 @@ bool CImageWriterTGA::writeImage(io::IWriteFile *file, IImage *image,u32 param) // be fixed to only swap/flip imageHeader.ImageDescriptor = (1 << 5); - // chances are good we'll need to swizzle data, so i'm going + // chances are good we'll need to swizzle data, so I'm going // to convert and write one scan line at a time. it's also // a bit cleaner this way - void (*CColorConverter_convertFORMATtoFORMAT)(const void*, s32, void*) = 0; + void (*CColorConverter_convertFORMATtoFORMAT)(const void*, u32, void*) = 0; switch(image->getColorFormat()) { case ECF_A8R8G8B8: diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index eb37979..aea6226 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -1579,7 +1579,6 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) { OSVERSIONINFOEX osvi; - PGPI pGPI; BOOL bOsVersionInfoEx; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); @@ -1631,9 +1630,14 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) { if (osvi.dwMajorVersion == 6) { - DWORD dwType; - pGPI = (PGPI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); - pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); + DWORD dwType = 0; // (PRODUCT_UNDEFINED not available on MinGW) + HMODULE hmKernel32 = GetModuleHandle(TEXT("kernel32.dll")); + if ( hmKernel32 ) + { + PGPI pGPI = (PGPI)GetProcAddress(hmKernel32, "GetProductInfo"); + if ( pGPI ) + pGPI(osvi.dwMajorVersion, osvi.dwMinorVersion, 0, 0, &dwType); + } switch (dwType) { diff --git a/source/Irrlicht/CIrrMeshFileLoader.cpp b/source/Irrlicht/CIrrMeshFileLoader.cpp index f92b2dc..e24d7a5 100644 --- a/source/Irrlicht/CIrrMeshFileLoader.cpp +++ b/source/Irrlicht/CIrrMeshFileLoader.cpp @@ -276,13 +276,13 @@ void CIrrMeshFileLoader::readIndices(io::IXMLReader* reader, int indexCount, IIn void CIrrMeshFileLoader::readMeshBuffer(io::IXMLReader* reader, int vertexCount, CDynamicMeshBuffer* sbuffer) { - core::stringc data = reader->getNodeData(); - const c8* p = &data[0]; - scene::IVertexBuffer& Vertices = sbuffer->getVertexBuffer(); - video::E_VERTEX_TYPE vType = Vertices.getType(); - if (sbuffer) { + core::stringc data = reader->getNodeData(); + const c8* p = &data[0]; + scene::IVertexBuffer& Vertices = sbuffer->getVertexBuffer(); + video::E_VERTEX_TYPE vType = Vertices.getType(); + for (int i=0; i(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; triRange.MeshBuffer = MeshBuffer; triRange.MaterialIndex = MaterialIndex; @@ -272,7 +272,7 @@ void COctreeTriangleSelector::getTriangles(core::triangle3df* triangles, s32 arr { SCollisionTriangleRange triRange; triRange.RangeSize = trianglesWritten; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; triRange.MeshBuffer = MeshBuffer; triRange.MaterialIndex = MaterialIndex; diff --git a/source/Irrlicht/COpenGLCoreTexture.h b/source/Irrlicht/COpenGLCoreTexture.h index 17712f0..05c97ce 100644 --- a/source/Irrlicht/COpenGLCoreTexture.h +++ b/source/Irrlicht/COpenGLCoreTexture.h @@ -411,7 +411,7 @@ public: u32 width = Size.Width; u32 height = Size.Height; u8* tmpData = static_cast(data); - u32 dataSize = 0; + size_t dataSize = 0; u32 level = 0; do @@ -612,7 +612,7 @@ protected: } else { - u32 dataSize = IImage::getDataSizeFromFormat(ColorFormat, width, height); + GLsizei dataSize = (GLsizei)IImage::getDataSizeFromFormat(ColorFormat, width, height); switch (TextureType) { @@ -651,7 +651,7 @@ protected: GLint InternalFormat; GLenum PixelFormat; GLenum PixelType; - void (*Converter)(const void*, s32, void*); + void (*Converter)(const void*, u32, void*); bool LockReadOnly; IImage* LockImage; diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 815b58e..928c4f0 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -788,13 +788,10 @@ void COpenGLDriver::updateOcclusionQuery(scene::ISceneNode* node, bool block) /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 COpenGLDriver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 COpenGLDriver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); - if (index != -1) - return OcclusionQueries[index].Result; - else - return ~0; + const s32 index = OcclusionQueries.linear_search(node); + return index < 0 ? ~0 : OcclusionQueries[index].Result; } @@ -3618,7 +3615,7 @@ bool COpenGLDriver::queryTextureFormat(ECOLOR_FORMAT format) const GLint dummyInternalFormat; GLenum dummyPixelFormat; GLenum dummyPixelType; - void (*dummyConverter)(const void*, s32, void*); + void (*dummyConverter)(const void*, u32, void*); return getColorFormatParameters(format, dummyInternalFormat, dummyPixelFormat, dummyPixelType, &dummyConverter); } @@ -4208,7 +4205,7 @@ GLenum COpenGLDriver::getZBufferBits() const } bool COpenGLDriver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat, - GLenum& pixelType, void(**converter)(const void*, s32, void*)) const + GLenum& pixelType, void(**converter)(const void*, u32, void*)) const { // NOTE: Converter variable not used here, but don't remove, it's used in the OGL-ES drivers. diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index 6f2bd7a..b46008c 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -111,7 +111,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! Create render target. virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE; @@ -405,7 +405,7 @@ namespace video GLenum getZBufferBits() const; bool getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat, - GLenum& pixelType, void(**converter)(const void*, s32, void*)) const; + GLenum& pixelType, void(**converter)(const void*, u32, void*)) const; //! Return info about fixed pipeline state. E_OPENGL_FIXED_PIPELINE_STATE getFixedPipelineState() const; diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index d921cca..4302cfa 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -1247,7 +1247,7 @@ bool CSceneManager::isCulled(const ISceneNode* node) const // has occlusion query information if (node->getAutomaticCulling() & scene::EAC_OCC_QUERY) { - result = (Driver->getOcclusionQueryResult(const_cast(node))==0); + result = (Driver->getOcclusionQueryResult(node)==0); } // can be seen by a bounding box ? diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 90b0517..e2331b0 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -4810,9 +4810,9 @@ void CBurningVideoDriver::updateOcclusionQuery(scene::ISceneNode* node, bool blo /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger than the actual value of pixels. */ -u32 CBurningVideoDriver::getOcclusionQueryResult(scene::ISceneNode* node) const +u32 CBurningVideoDriver::getOcclusionQueryResult(const scene::ISceneNode* node) const { - const s32 index = OcclusionQueries.linear_search(SOccQuery(node)); + const s32 index = OcclusionQueries.linear_search(node); return index < 0 ? ~0 : OcclusionQueries[index].Result; } diff --git a/source/Irrlicht/CSoftwareDriver2.h b/source/Irrlicht/CSoftwareDriver2.h index 441ccd6..18ed97e 100644 --- a/source/Irrlicht/CSoftwareDriver2.h +++ b/source/Irrlicht/CSoftwareDriver2.h @@ -48,7 +48,7 @@ namespace video /** Return value is the number of visible pixels/fragments. The value is a safe approximation, i.e. can be larger then the actual value of pixels. */ - virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const IRR_OVERRIDE; + virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const IRR_OVERRIDE; //! sets transformation virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) IRR_OVERRIDE; diff --git a/source/Irrlicht/CTerrainTriangleSelector.cpp b/source/Irrlicht/CTerrainTriangleSelector.cpp index db544d4..2ee697f 100644 --- a/source/Irrlicht/CTerrainTriangleSelector.cpp +++ b/source/Irrlicht/CTerrainTriangleSelector.cpp @@ -115,7 +115,7 @@ void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, { SCollisionTriangleRange triRange; triRange.RangeSize = tIndex; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; outTriangleInfo->push_back(triRange); } @@ -163,7 +163,7 @@ void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, { SCollisionTriangleRange triRange; triRange.RangeSize = tIndex; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; outTriangleInfo->push_back(triRange); } @@ -209,7 +209,7 @@ void CTerrainTriangleSelector::getTriangles(core::triangle3df* triangles, { SCollisionTriangleRange triRange; triRange.RangeSize = tIndex; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; outTriangleInfo->push_back(triRange); } diff --git a/source/Irrlicht/CTextSceneNode.cpp b/source/Irrlicht/CTextSceneNode.cpp index 10f47c7..e97dc91 100644 --- a/source/Irrlicht/CTextSceneNode.cpp +++ b/source/Irrlicht/CTextSceneNode.cpp @@ -215,9 +215,18 @@ void CBillboardTextSceneNode::setText(const wchar_t* text) u32 rectno = sprites[spriteno].Frames[0].rectNumber; u32 texno = sprites[spriteno].Frames[0].textureNumber; - const core::dimension2d& texSize = Font->getSpriteBank()->getTexture(texno)->getOriginalSize(); - dim[0] = core::reciprocal((f32)texSize.Width); - dim[1] = core::reciprocal((f32)texSize.Height); + video::ITexture* texture = Font->getSpriteBank()->getTexture(texno); + if (texture) + { + const core::dimension2d& texSize = texture->getOriginalSize(); + dim[0] = core::reciprocal((f32)texSize.Width); + dim[1] = core::reciprocal((f32)texSize.Height); + } + else + { + dim[0] = 0; + dim[1] = 0; + } const core::rect& s = sourceRects[rectno]; diff --git a/source/Irrlicht/CTriangleSelector.cpp b/source/Irrlicht/CTriangleSelector.cpp index 531c62d..8186950 100644 --- a/source/Irrlicht/CTriangleSelector.cpp +++ b/source/Irrlicht/CTriangleSelector.cpp @@ -293,7 +293,7 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, triRange.RangeStart = 0; triRange.RangeSize = cnt; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; triRange.MeshBuffer = MeshBuffer; triRange.MaterialIndex = MaterialIndex; @@ -313,7 +313,7 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, triRange.MeshBuffer = BufferRanges[rangeIndex].MeshBuffer; triRange.RangeStart = BufferRanges[rangeIndex].RangeStart; triRange.RangeSize = core::min_( cnt-BufferRanges[rangeIndex].RangeStart, BufferRanges[rangeIndex].RangeSize); - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; outTriangleInfo->push_back(triRange); @@ -370,7 +370,7 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, { irr::u32 activeRange = 0; SCollisionTriangleRange triRange; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; triRange.RangeStart = triangleCount; triRange.MeshBuffer = BufferRanges[activeRange].MeshBuffer; @@ -433,7 +433,7 @@ void CTriangleSelector::getTriangles(core::triangle3df* triangles, { SCollisionTriangleRange triRange; triRange.RangeSize = triangleCount; - triRange.Selector = const_cast(this); + triRange.Selector = this; triRange.SceneNode = SceneNode; triRange.MeshBuffer = MeshBuffer; triRange.MaterialIndex = MaterialIndex; diff --git a/source/Irrlicht/CWebGL1Driver.cpp b/source/Irrlicht/CWebGL1Driver.cpp index fe765f8..e229966 100644 --- a/source/Irrlicht/CWebGL1Driver.cpp +++ b/source/Irrlicht/CWebGL1Driver.cpp @@ -750,7 +750,7 @@ GLenum CWebGL1Driver::getZBufferBits() const } bool CWebGL1Driver::getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat, - GLenum& pixelType, void(**converter)(const void*, s32, void*)) const + GLenum& pixelType, void(**converter)(const void*, u32, void*)) const { bool supported = false; pixelFormat = GL_RGBA; diff --git a/source/Irrlicht/CWebGL1Driver.h b/source/Irrlicht/CWebGL1Driver.h index 19e8a7e..fa3f0ec 100644 --- a/source/Irrlicht/CWebGL1Driver.h +++ b/source/Irrlicht/CWebGL1Driver.h @@ -118,7 +118,7 @@ namespace video virtual GLenum getZBufferBits() const IRR_OVERRIDE; virtual bool getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat, - GLenum& pixelType, void(**converter)(const void*, s32, void*)) const IRR_OVERRIDE; + GLenum& pixelType, void(**converter)(const void*, u32, void*)) const IRR_OVERRIDE; protected: // create a meshbuffer which has as many vertices as indices diff --git a/source/Irrlicht/Irrlicht.ruleset b/source/Irrlicht/Irrlicht.ruleset index 8766033..1061865 100644 --- a/source/Irrlicht/Irrlicht.ruleset +++ b/source/Irrlicht/Irrlicht.ruleset @@ -1,5 +1,5 @@  - + @@ -273,6 +273,7 @@ + diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index eac8f0b..3cde178 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. -Compiled as RELEASE -Test suite pass at GMT Wed May 4 10:25:42 2022 +Compiled as DEBUG +Test suite pass at GMT Sat May 14 18:16:57 2022