Browse Source

Fix various variable shadowing warnings on MSVC.

pull/499/head
Vladimír Vondruš 3 years ago
parent
commit
28c1f84e68
  1. 1
      doc/changelog.dox
  2. 3
      doc/snippets/Magnum.cpp
  3. 6
      src/Magnum/GL/Context.cpp
  4. 6
      src/Magnum/MeshTools/Compile.cpp
  5. 30
      src/Magnum/SceneTools/sceneconverter.cpp
  6. 4
      src/Magnum/Trade/AbstractSceneConverter.cpp
  7. 10
      src/Magnum/Trade/MaterialData.cpp
  8. 4
      src/Magnum/Vk/Device.cpp

1
doc/changelog.dox

@ -745,6 +745,7 @@ See also:
- Worked around a MSVC2022 bug with constexpr conversion operators if C++20
is used, causing most @ref Math tests to fail compilation (see
[mosra/magnum#602](https://github.com/mosra/magnum/pull/602))
- Fixed various variable shadowing warings on MSVC (see [mosra/magnum#611](https://github.com/mosra/magnum/issues/611))
@subsection changelog-latest-bugfixes Bug fixes

3
doc/snippets/Magnum.cpp

@ -44,6 +44,7 @@ using namespace Magnum;
using namespace Magnum::Math::Literals;
#ifdef MAGNUM_TARGET_GL
namespace Wew {
Containers::Pointer<GL::Mesh> mesh;
bool found = false;
@ -63,6 +64,7 @@ class MeshResourceLoader: public AbstractResourceLoader<GL::Mesh> {
}
};
/* [AbstractResourceLoader-implementation] */
}
#endif
int main() {
@ -304,6 +306,7 @@ Resource<GL::AbstractShaderProgram, MyShader> shader =
}
{
using namespace Wew;
typedef ResourceManager<GL::Mesh> MyResourceManager;
/* [AbstractResourceLoader-use] */
MyResourceManager manager;

6
src/Magnum/GL/Context.cpp

@ -1009,11 +1009,11 @@ bool Context::tryCreate(const Configuration& configuration) {
GL::defaultFramebuffer global itself without turning it into a pointer
or a function. */
if(!(_configurationFlags & Configuration::Flag::Windowless)) {
Implementation::FramebufferState& state = _state->framebuffer;
Implementation::FramebufferState& framebufferState = _state->framebuffer;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
state.defaultViewport = state.viewport = Range2Di::fromSize({viewport[0], viewport[1]}, {viewport[2], viewport[3]});
CORRADE_INTERNAL_ASSERT(state.defaultViewport != Implementation::FramebufferState::DisengagedViewport);
framebufferState.defaultViewport = framebufferState.viewport = Range2Di::fromSize({viewport[0], viewport[1]}, {viewport[2], viewport[3]});
CORRADE_INTERNAL_ASSERT(framebufferState.defaultViewport != Implementation::FramebufferState::DisengagedViewport);
}
/** @todo Get rid of this as well somehow */
Renderer::initializeContextBasedFunctionality();

6
src/Magnum/MeshTools/Compile.cpp

@ -565,11 +565,11 @@ Containers::Pair<UnsignedInt, UnsignedInt> compiledPerVertexJointCount(const Tra
continue;
const UnsignedInt componentCount = meshData.attributeArraySize(i);
for(UnsignedInt i = 0; i < componentCount; i += 4) {
for(UnsignedInt j = 0; j < componentCount; j += 4) {
if(!primaryCount)
primaryCount = Math::min(componentCount - i, 4u);
primaryCount = Math::min(componentCount - j, 4u);
else if(!secondaryCount)
secondaryCount = Math::min(componentCount - i, 4u);
secondaryCount = Math::min(componentCount - j, 4u);
else break;
}
}

30
src/Magnum/SceneTools/sceneconverter.cpp

@ -750,11 +750,11 @@ well, the IDs reference attributes of the first mesh.)")
struct SingleMeshImporter: Trade::AbstractImporter {
explicit SingleMeshImporter(Trade::MeshData&& mesh_, Containers::String&& name, Trade::AbstractImporter& original): mesh{std::move(mesh_)}, name{std::move(name)} {
for(UnsignedInt i = 0; i != mesh.attributeCount(); ++i) {
const Trade::MeshAttribute name = mesh.attributeName(i);
if(!isMeshAttributeCustom(name)) continue;
const Trade::MeshAttribute attributeName = mesh.attributeName(i);
if(!isMeshAttributeCustom(attributeName)) continue;
/* Appending even empty ones so we don't have to
special-case "not found" in doMeshAttributeName() */
arrayAppend(attributeNames, InPlaceInit, meshAttributeCustom(name), original.meshAttributeName(name));
arrayAppend(attributeNames, InPlaceInit, meshAttributeCustom(attributeName), original.meshAttributeName(attributeName));
}
}
@ -1016,10 +1016,10 @@ well, the IDs reference attributes of the first mesh.)")
if(images2D) {
if(!(Trade::sceneContentsFor(*converter) & Trade::SceneContent::Images2D)) {
Warning{} << "Ignoring" << images2D.size() << "2D images not supported by the converter";
} else for(UnsignedInt i = 0; i != images2D.size(); ++i) {
} else for(UnsignedInt j = 0; j != images2D.size(); ++j) {
Trade::Implementation::Duration d{conversionTime};
if(!converter->add(images2D[i], contents & Trade::SceneContent::Names ? importer->image2DName(i) : Containers::String{})) {
Error{} << "Cannot add 2D image" << i;
if(!converter->add(images2D[j], contents & Trade::SceneContent::Names ? importer->image2DName(j) : Containers::String{})) {
Error{} << "Cannot add 2D image" << j;
return 1;
}
}
@ -1039,10 +1039,10 @@ well, the IDs reference attributes of the first mesh.)")
if(images3D) {
if(!(Trade::sceneContentsFor(*converter) & Trade::SceneContent::Images3D)) {
Warning{} << "Ignoring" << images3D.size() << "3D images not supported by the converter";
} else for(UnsignedInt i = 0; i != images3D.size(); ++i) {
} else for(UnsignedInt j = 0; j != images3D.size(); ++j) {
Trade::Implementation::Duration d{conversionTime};
if(!converter->add(images3D[i], contents & Trade::SceneContent::Names ? importer->image3DName(i) : Containers::String{})) {
Error{} << "Cannot add 3D image" << i;
if(!converter->add(images3D[j], contents & Trade::SceneContent::Names ? importer->image3DName(j) : Containers::String{})) {
Error{} << "Cannot add 3D image" << j;
return 1;
}
}
@ -1066,18 +1066,18 @@ well, the IDs reference attributes of the first mesh.)")
if(meshes) {
if(!(Trade::sceneContentsFor(*converter) & Trade::SceneContent::Meshes)) {
Warning{} << "Ignoring" << meshes.size() << "meshes not supported by the converter";
} else for(UnsignedInt i = 0; i != meshes.size(); ++i) {
} else for(UnsignedInt j = 0; j != meshes.size(); ++j) {
Trade::Implementation::Duration d{conversionTime};
const Trade::MeshData& mesh = meshes[i];
const Trade::MeshData& mesh = meshes[j];
/* Propagate custom attribute names, skip ones that are empty.
Compared to data names this is done always to avoid
information loss. */
for(UnsignedInt j = 0; j != mesh.attributeCount(); ++j) {
for(UnsignedInt k = 0; k != mesh.attributeCount(); ++k) {
/** @todo have some kind of a map to not have to query the
same custom attribute again for each mesh */
const Trade::MeshAttribute name = mesh.attributeName(j);
const Trade::MeshAttribute name = mesh.attributeName(k);
if(!isMeshAttributeCustom(name)) continue;
/* The expectation here is that the meshes are coming from
the importer instance. If --mesh or --concatenate-meshes
@ -1089,8 +1089,8 @@ well, the IDs reference attributes of the first mesh.)")
}
}
if(!converter->add(mesh, contents & Trade::SceneContent::Names ? importer->meshName(i) : Containers::String{})) {
Error{} << "Cannot add mesh" << i;
if(!converter->add(mesh, contents & Trade::SceneContent::Names ? importer->meshName(j) : Containers::String{})) {
Error{} << "Cannot add mesh" << j;
return 1;
}
}

4
src/Magnum/Trade/AbstractSceneConverter.cpp

@ -1312,10 +1312,10 @@ bool AbstractSceneConverter::addImporterContentsInternal(AbstractImporter& impor
/* Propagate custom attribute names, skip ones that are empty.
Compared to data names this is done always to avoid
information loss. */
for(UnsignedInt j = 0; j != mesh->attributeCount(); ++j) {
for(UnsignedInt k = 0; k != mesh->attributeCount(); ++k) {
/** @todo have some kind of a map to not have to query the
same custom attribute again for each mesh */
const Trade::MeshAttribute name = mesh->attributeName(j);
const Trade::MeshAttribute name = mesh->attributeName(k);
if(!isMeshAttributeCustom(name)) continue;
if(const Containers::String nameString = importer.meshAttributeName(name)) {
setMeshAttributeName(name, nameString);

10
src/Magnum/Trade/MaterialData.cpp

@ -349,11 +349,11 @@ MaterialData::MaterialData(const MaterialTypes types, const DataFlags attributeD
CORRADE_ASSERT(begin <= end && end <= _data.size(),
"Trade::MaterialData: invalid range (" << Debug::nospace << begin << Debug::nospace << "," << end << Debug::nospace <<") for layer" << i << "with" << _data.size() << "attributes in total", );
if(end - begin > 1) for(std::size_t i = begin + 1; i != end; ++i) {
CORRADE_ASSERT(_data[i - 1].name() != _data[i].name(),
"Trade::MaterialData: duplicate attribute" << _data[i].name(), );
CORRADE_ASSERT(_data[i - 1].name() < _data[i].name(),
"Trade::MaterialData:" << _data[i].name() << "has to be sorted before" << _data[i - 1].name() << "if passing non-owned data", );
if(end - begin > 1) for(std::size_t j = begin + 1; j != end; ++j) {
CORRADE_ASSERT(_data[j - 1].name() != _data[j].name(),
"Trade::MaterialData: duplicate attribute" << _data[j].name(), );
CORRADE_ASSERT(_data[j - 1].name() < _data[j].name(),
"Trade::MaterialData:" << _data[j].name() << "has to be sorted before" << _data[j - 1].name() << "if passing non-owned data", );
}
begin = end;

4
src/Magnum/Vk/Device.cpp

@ -842,9 +842,9 @@ Result Device::tryCreateInternal(Instance& instance, const DeviceCreateInfo& inf
void Device::initialize(Instance& instance, const Version version, const Containers::StringIterable& enabledExtensions, Containers::Array<std::pair<Containers::StringView, bool>>& encounteredWorkarounds, const DeviceFeatures& enabledFeatures) {
/* Mark all known extensions as enabled */
for(const Containers::StringView extension: enabledExtensions) {
for(const Version version: KnownVersionsForExtensions) {
for(const Version extensionVersion: KnownVersionsForExtensions) {
const Containers::ArrayView<const Extension> knownExtensions =
Extension::extensions(version);
Extension::extensions(extensionVersion);
const auto found = std::lower_bound(knownExtensions.begin(), knownExtensions.end(), extension, [](const Extension& a, Containers::StringView b) {
return a.string() < b;
});

Loading…
Cancel
Save