diff --git a/CMakeLists.txt b/CMakeLists.txt index ebf3c2a3..df6139dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,23 +68,24 @@ endif() # install data install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION share/vsgExamples) -# pure VSG examples +# VSG examples +add_subdirectory(examples/animation) +add_subdirectory(examples/app) +add_subdirectory(examples/commands) add_subdirectory(examples/core) -add_subdirectory(examples/maths) add_subdirectory(examples/io) -add_subdirectory(examples/ui) -add_subdirectory(examples/state) -add_subdirectory(examples/commands) -add_subdirectory(examples/nodes) -add_subdirectory(examples/threading) -add_subdirectory(examples/app) -add_subdirectory(examples/vk) -add_subdirectory(examples/text) +add_subdirectory(examples/lighting) +add_subdirectory(examples/maths) add_subdirectory(examples/meshshaders) -add_subdirectory(examples/raytracing) +add_subdirectory(examples/nodes) add_subdirectory(examples/platform) +add_subdirectory(examples/raytracing) +add_subdirectory(examples/state) +add_subdirectory(examples/text) +add_subdirectory(examples/threading) +add_subdirectory(examples/ui) add_subdirectory(examples/utils) +add_subdirectory(examples/vk) add_subdirectory(examples/volume) -add_subdirectory(examples/animation) vsg_add_feature_summary() diff --git a/examples/animation/vsganimation/vsganimation.cpp b/examples/animation/vsganimation/vsganimation.cpp index 871ddf7b..fa587de9 100644 --- a/examples/animation/vsganimation/vsganimation.cpp +++ b/examples/animation/vsganimation/vsganimation.cpp @@ -195,7 +195,7 @@ int main(int argc, char** argv) { auto shaderHints = vsg::ShaderCompileSettings::create(); - float penumbraRadius = 0.005; + float penumbraRadius = 0.005f; if (arguments.read("--pcss")) { shadowSettings = vsg::PercentageCloserSoftShadows::create(numShadowMapsPerLight); @@ -386,9 +386,9 @@ int main(int argc, char** argv) vsg::StateInfo stateInfo; double margin = bounds.max.z - bounds.min.z; - geomInfo.position.set((bounds.min.x + bounds.max.x)*0.5, (bounds.min.y + bounds.max.y)*0.5, 0.0); - geomInfo.dx.set(bounds.max.x - bounds.min.x + margin, 0.0, 0.0); - geomInfo.dy.set(0.0, bounds.max.y - bounds.min.y + margin, 0.0); + geomInfo.position.set(static_cast(bounds.min.x + bounds.max.x)*0.5f, static_cast(bounds.min.y + bounds.max.y)*0.5f, 0.0f); + geomInfo.dx.set(static_cast(bounds.max.x - bounds.min.x + margin), 0.0f, 0.0f); + geomInfo.dy.set(0.0, static_cast(bounds.max.y - bounds.min.y + margin), 0.0f); geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f); stateInfo.two_sided = true; @@ -406,8 +406,8 @@ int main(int argc, char** argv) { auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; - directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.9; + directionalLight->color.set(1.0f, 1.0f, 1.0f); + directionalLight->intensity = 0.9f; directionalLight->direction = direction; directionalLight->shadowSettings = shadowSettings; @@ -415,8 +415,8 @@ int main(int argc, char** argv) auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; - ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.1; + ambientLight->color.set(1.0f, 1.0f, 1.0f); + ambientLight->intensity = 0.1f; scene->addChild(ambientLight); } diff --git a/examples/app/vsganaglyphicstereo/vsganaglyphicstereo.cpp b/examples/app/vsganaglyphicstereo/vsganaglyphicstereo.cpp index c95d239d..aaa3d9e1 100644 --- a/examples/app/vsganaglyphicstereo/vsganaglyphicstereo.cpp +++ b/examples/app/vsganaglyphicstereo/vsganaglyphicstereo.cpp @@ -61,7 +61,7 @@ class ReplaceColorBlendState : public vsg::Visitor } }; -vsg::ref_ptr createTextureQuad(const vsg::vec3& origin, const vsg::vec3& horizontal, const vsg::vec3& vertical, vsg::ref_ptr imageData, uint32_t mipmapLevelsHints = 0) +vsg::ref_ptr createTextureQuad(const vsg::vec3& origin, const vsg::vec3& horizontal, const vsg::vec3& vertical, vsg::ref_ptr imageData, float mipmapLevelsHints = 0.0f) { // set up search paths to SPIRV shaders and textures @@ -240,8 +240,8 @@ int main(int argc, char** argv) if (leftImage && rightImage) { vsg::vec3 origin(0.0f, 0.0f, 0.0f); - vsg::vec3 horizontal(leftImage->width(), 0.0f, 0.0f); - vsg::vec3 vertical(0.0f, 0.0f, leftImage->height()); + vsg::vec3 horizontal(static_cast(leftImage->width()), 0.0f, 0.0f); + vsg::vec3 vertical(0.0f, 0.0f, static_cast(leftImage->height())); auto leftQuad = createTextureQuad(origin - offset * 0.5f, horizontal, vertical, leftImage); auto rightQuad = createTextureQuad(origin + offset * 0.5f, horizontal, vertical, rightImage); diff --git a/examples/app/vsgcameras/vsgcameras.cpp b/examples/app/vsgcameras/vsgcameras.cpp index e6c6e7f0..b9f10357 100644 --- a/examples/app/vsgcameras/vsgcameras.cpp +++ b/examples/app/vsgcameras/vsgcameras.cpp @@ -233,7 +233,7 @@ int main(int argc, char** argv) // set up secondary views, one per camera found in the scene graph uint32_t margin = 10; - uint32_t division = scene_cameras.size(); + uint32_t division = static_cast(scene_cameras.size()); if (division<3) division = 3; uint32_t secondary_width = width / division; diff --git a/examples/io/vsgcluster/vsgcluster.cpp b/examples/io/vsgcluster/vsgcluster.cpp index 83a94cc2..9ef6f8ed 100644 --- a/examples/io/vsgcluster/vsgcluster.cpp +++ b/examples/io/vsgcluster/vsgcluster.cpp @@ -207,11 +207,6 @@ int main(int argc, char** argv) viewer->compile(); - std::vector buffer(1); - uint32_t buffer_size = buffer.size() * sizeof(decltype(buffer)::value_type); - - std::cout << "buffer_size = " << buffer_size << std::endl; - PacketBroadcaster broadcaster; broadcaster.broadcaster = bc; @@ -235,8 +230,6 @@ int main(int argc, char** argv) if (rc) { - //unsigned int size = rc->receive(buffer.data(), buffer_size); - //std::cout << "received size = " << size << std::endl; auto object = receiver.receive(); viewerData = object.cast(); if (viewerData) diff --git a/examples/lighting/CMakeLists.txt b/examples/lighting/CMakeLists.txt new file mode 100644 index 00000000..6f56331c --- /dev/null +++ b/examples/lighting/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(vsglights) +add_subdirectory(vsgshadow) diff --git a/examples/nodes/vsglights/CMakeLists.txt b/examples/lighting/vsglights/CMakeLists.txt similarity index 100% rename from examples/nodes/vsglights/CMakeLists.txt rename to examples/lighting/vsglights/CMakeLists.txt diff --git a/examples/nodes/vsglights/vsglights.cpp b/examples/lighting/vsglights/vsglights.cpp similarity index 84% rename from examples/nodes/vsglights/vsglights.cpp rename to examples/lighting/vsglights/vsglights.cpp index 57bb3509..dd9b27e0 100644 --- a/examples/nodes/vsglights/vsglights.cpp +++ b/examples/lighting/vsglights/vsglights.cpp @@ -31,9 +31,9 @@ vsg::ref_ptr createTestScene(vsg::ref_ptr options) auto bounds = vsg::visit(scene).bounds; double diameter = vsg::length(bounds.max - bounds.min); - geomInfo.position.set((bounds.min.x + bounds.max.x)*0.5, (bounds.min.y + bounds.max.y)*0.5, bounds.min.z); - geomInfo.dx.set(diameter, 0.0, 0.0); - geomInfo.dy.set(0.0, diameter, 0.0); + geomInfo.position.set(static_cast((bounds.min.x + bounds.max.x)*0.5), static_cast((bounds.min.y + bounds.max.y)*0.5), static_cast(bounds.min.z)); + geomInfo.dx.set(static_cast(diameter), 0.0f, 0.0f); + geomInfo.dy.set(0.0f, static_cast(diameter), 0.0f); scene->addChild(builder->createQuad(geomInfo, stateInfo)); @@ -127,8 +127,8 @@ int main(int argc, char** argv) { auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; - ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.01; + ambientLight->color.set(1.0f, 1.0f, 1.0f); + ambientLight->intensity = 0.01f; group->addChild(ambientLight); } @@ -137,9 +137,9 @@ int main(int argc, char** argv) { auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; - directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.15; - directionalLight->direction.set(0.0, -1.0, -1.0); + directionalLight->color.set(1.0f, 1.0f, 1.0f); + directionalLight->intensity = 0.15f; + directionalLight->direction.set(0.0f, -1.0f, -1.0f); group->addChild(directionalLight); } @@ -148,9 +148,9 @@ int main(int argc, char** argv) { auto pointLight = vsg::PointLight::create(); pointLight->name = "point"; - pointLight->color.set(1.0, 1.0, 0.0); - pointLight->intensity = span*0.5; - pointLight->position.set(bounds.min.x, bounds.min.y, bounds.max.z + span*0.3); + pointLight->color.set(1.0f, 1.0f, 0.0); + pointLight->intensity = static_cast(span*0.5); + pointLight->position.set(static_cast(bounds.min.x), static_cast(bounds.min.y), static_cast(bounds.max.z + span*0.3)); // enable culling of the point light by decorating with a CullGroup auto cullGroup = vsg::CullGroup::create(); @@ -167,12 +167,12 @@ int main(int argc, char** argv) { auto spotLight = vsg::SpotLight::create(); spotLight->name = "spot"; - spotLight->color.set(0.0, 1.0, 1.0); - spotLight->intensity = span*0.5; - spotLight->position.set(bounds.max.x + span*0.1, bounds.min.y - span*0.1, bounds.max.z + span*0.3); + spotLight->color.set(0.0f, 1.0f, 1.0f); + spotLight->intensity = static_cast(span*0.5); + spotLight->position.set(static_cast(bounds.max.x + span*0.1), static_cast(bounds.min.y - span*0.1), static_cast(bounds.max.z + span*0.3)); spotLight->direction = (bounds.min+bounds.max)*0.5 - spotLight->position; - spotLight->innerAngle = vsg::radians(8.0); - spotLight->outerAngle = vsg::radians(9.0); + spotLight->innerAngle = vsg::radians(8.0f); + spotLight->outerAngle = vsg::radians(9.0f); // enable culling of the spot light by decorating with a CullGroup auto cullGroup = vsg::CullGroup::create(); @@ -188,14 +188,14 @@ int main(int argc, char** argv) { auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; - ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.1; + ambientLight->color.set(1.0f, 1.0f, 1.0f); + ambientLight->intensity = 0.1f; auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "head light"; - directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.9; - directionalLight->direction.set(0.0, 0.0, -1.0); + directionalLight->color.set(1.0f, 1.0f, 1.0f); + directionalLight->intensity = 0.9f; + directionalLight->direction.set(0.0f, 0.0f, -1.0f); auto absoluteTransform = vsg::AbsoluteTransform::create(); absoluteTransform->addChild(ambientLight); diff --git a/examples/nodes/vsgshadow/CMakeLists.txt b/examples/lighting/vsgshadow/CMakeLists.txt similarity index 100% rename from examples/nodes/vsgshadow/CMakeLists.txt rename to examples/lighting/vsgshadow/CMakeLists.txt diff --git a/examples/nodes/vsgshadow/vsgshadow.cpp b/examples/lighting/vsgshadow/vsgshadow.cpp similarity index 94% rename from examples/nodes/vsgshadow/vsgshadow.cpp rename to examples/lighting/vsgshadow/vsgshadow.cpp index d78705d2..14c6bfd9 100644 --- a/examples/nodes/vsgshadow/vsgshadow.cpp +++ b/examples/lighting/vsgshadow/vsgshadow.cpp @@ -37,7 +37,7 @@ vsg::ref_ptr decorateIfRequired(vsg::ref_ptr node, const M { auto bb = vsg::visit(node).bounds; auto lod = vsg::LOD::create(); - lod->bound = vsg::sphere((bb.min + bb.max) * 0.5, vsg::length(bb.max - bb.min)); + lod->bound = vsg::dsphere((bb.min + bb.max) * 0.5, vsg::length(bb.max - bb.min)); lod->addChild(vsg::LOD::Child{settings.lodScreenRatio, node}); return lod; } @@ -79,10 +79,10 @@ vsg::ref_ptr createTestScene(const ModelSettings& settings) auto bounds = vsg::visit(scene).bounds; if (settings.insertBaseGeometry) { - double diameter = vsg::length(bounds.max - bounds.min); - geomInfo.position.set((bounds.min.x + bounds.max.x)*0.5, (bounds.min.y + bounds.max.y)*0.5, bounds.min.z); - geomInfo.dx.set(diameter, 0.0, 0.0); - geomInfo.dy.set(0.0, diameter, 0.0); + float diameter = static_cast(vsg::length(bounds.max - bounds.min)); + geomInfo.position.set(static_cast((bounds.min.x + bounds.max.x)*0.5), static_cast((bounds.min.y + bounds.max.y)*0.5), static_cast(bounds.min.z)); + geomInfo.dx.set(diameter, 0.0f, 0.0f); + geomInfo.dy.set(0.0f, diameter, 0.0f); geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f); stateInfo.two_sided = true; @@ -158,11 +158,11 @@ vsg::ref_ptr createLargeTestScene(const ModelSettings& settings) if (settings.insertBaseGeometry) { - double diameter = vsg::length(bounds.max - bounds.min); - geomInfo.position.set((bounds.min.x + bounds.max.x)*0.5, (bounds.min.y + bounds.max.y)*0.5, bounds.min.z); - geomInfo.dx.set(diameter, 0.0, 0.0); - geomInfo.dy.set(0.0, diameter, 0.0); - geomInfo.dz.set(0.0, 0.0, 1.0); + float diameter = static_cast(vsg::length(bounds.max - bounds.min)); + geomInfo.position.set(static_cast((bounds.min.x + bounds.max.x)*0.5), static_cast((bounds.min.y + bounds.max.y)*0.5), static_cast(bounds.min.z)); + geomInfo.dx.set(diameter, 0.0f, 0.0f); + geomInfo.dy.set(0.0f, diameter, 0.0f); + geomInfo.dz.set(0.0f, 0.0f, 1.0f); geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f); stateInfo.two_sided = true; @@ -426,8 +426,8 @@ int main(int argc, char** argv) auto inherit = arguments.read("--inherit"); auto direction = arguments.value(vsg::dvec3(0.0, 0.0, -1.0), "--direction"); - auto angleSubtended = arguments.value(0.0090f, "--angleSubtended"); auto location = arguments.value({0.0, 0.0, 0.0}, "--location"); + auto angleSubtended = arguments.value(0.0090f, "--angleSubtended"); auto scale = arguments.value(1.0, "--scale"); double viewingDistance = scale; @@ -543,8 +543,8 @@ int main(int argc, char** argv) { directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; - directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.9; + directionalLight->color.set(1.0f, 1.0f, 1.0f); + directionalLight->intensity = 0.9f; directionalLight->direction = direction; directionalLight->angleSubtended = angleSubtended; directionalLight->shadowSettings = shadowSettings; @@ -557,21 +557,21 @@ int main(int argc, char** argv) { ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; - ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.2; + ambientLight->color.set(1.0f, 1.0f, 1.0f); + ambientLight->intensity = 0.2f; group->addChild(ambientLight); } if (numLights >= 3 && numLights < 4) { - directionalLight->intensity = 0.7; - ambientLight->intensity = 0.1; + directionalLight->intensity = 0.7f; + ambientLight->intensity = 0.1f; auto directionalLight2 = vsg::DirectionalLight::create(); directionalLight2->name = "2nd directional"; - directionalLight2->color.set(1.0, 1.0, 0.0); - directionalLight2->intensity = 0.7; - directionalLight2->direction = vsg::normalize(vsg::vec3(0.9, 1.0, -1.0)); + directionalLight2->color.set(1.0f, 1.0f, 0.0f); + directionalLight2->intensity = 0.7f; + directionalLight2->direction = vsg::normalize(vsg::dvec3(0.9, 1.0, -1.0)); directionalLight2->angleSubtended = angleSubtended; directionalLight2->shadowSettings = shadowSettings; @@ -582,15 +582,15 @@ int main(int argc, char** argv) { auto spotLight = vsg::SpotLight::create(); spotLight->name = "spot"; - spotLight->color.set(0.0, 1.0, 1.0); - spotLight->intensity = 200.0; + spotLight->color.set(0.0f, 1.0f, 1.0f); + spotLight->intensity = 200.0f; spotLight->position = vsg::vec3(3.0, 0.5, 15.0); spotLight->direction = vsg::normalize(vsg::vec3(-0.5, -1, -10)); if (largeScene) { spotLight->position = vsg::vec3(3000.0, 500.0, 15000.0); spotLight->direction = vsg::normalize(vsg::dvec3(500, 500, 0) - spotLight->position); - spotLight->intensity = 15000.0 * 15000.0 / 4.0; + spotLight->intensity = static_cast(15000.0 * 15000.0 / 4.0); } spotLight->outerAngle = vsg::radians(10.0); spotLight->innerAngle = vsg::radians(5.0); diff --git a/examples/nodes/CMakeLists.txt b/examples/nodes/CMakeLists.txt index 4e671909..f993d3ab 100644 --- a/examples/nodes/CMakeLists.txt +++ b/examples/nodes/CMakeLists.txt @@ -1,8 +1,6 @@ add_subdirectory(vsgannotation) add_subdirectory(vsggroups) -add_subdirectory(vsglights) add_subdirectory(vsgtransform) -add_subdirectory(vsgshadow) add_subdirectory(vsgtextureprojection) add_subdirectory(vsglayers) diff --git a/examples/nodes/vsgannotation/vsgannotation.cpp b/examples/nodes/vsgannotation/vsgannotation.cpp index eb656eb4..0fb33945 100644 --- a/examples/nodes/vsgannotation/vsgannotation.cpp +++ b/examples/nodes/vsgannotation/vsgannotation.cpp @@ -26,7 +26,7 @@ class NamedGroup : public vsg::Inherit, Nam public: NamedGroup() { - debugColor = vsg::vec4(.8, .8, .8, 1.0); + debugColor = vsg::vec4(.8f, .8f, .8f, 1.0f); } using experimental::Annotation::accept; diff --git a/examples/nodes/vsglayers/vsglayers.cpp b/examples/nodes/vsglayers/vsglayers.cpp index 31843c2e..5ec87056 100644 --- a/examples/nodes/vsglayers/vsglayers.cpp +++ b/examples/nodes/vsglayers/vsglayers.cpp @@ -72,11 +72,11 @@ int main(int argc, char** argv) auto layout = vsg::StandardLayout::create(); layout->horizontalAlignment = vsg::StandardLayout::CENTER_ALIGNMENT; - layout->position = vsg::vec3(0.0, 0.0, 0.0); - layout->horizontal = vsg::vec3(1.0, 0.0, 0.0); - layout->vertical = vsg::vec3(0.0, 0.0, 1.0); - layout->color = vsg::vec4(1.0, 1.0, 1.0, 1.0); - layout->outlineWidth = 0.1; + layout->position = vsg::vec3(0.0f, 0.0f, 0.0f); + layout->horizontal = vsg::vec3(1.0f, 0.0f, 0.0f); + layout->vertical = vsg::vec3(0.0f, 0.0f, 1.0f); + layout->color = vsg::vec4(1.0f, 1.0f, 1.0f, 1.0f); + layout->outlineWidth = 0.1f; auto text = vsg::Text::create(); text->text = vsg::stringValue::create("Layer"); diff --git a/examples/nodes/vsgpagedlod/TileReader.cpp b/examples/nodes/vsgpagedlod/TileReader.cpp index 656ffdf3..ec08fad1 100644 --- a/examples/nodes/vsgpagedlod/TileReader.cpp +++ b/examples/nodes/vsgpagedlod/TileReader.cpp @@ -121,7 +121,7 @@ vsg::ref_ptr TileReader::read_root(vsg::ref_ptr uint32_t level = 0; for (uint32_t i = level; i < maxLevel; ++i) { - estimatedNumOfTilesBelow += std::pow(4, i - level); + estimatedNumOfTilesBelow += static_cast(std::pow(4, i - level)); } uint32_t tileMultiplier = std::min(estimatedNumOfTilesBelow, maxNumTilesBelow) + 1; @@ -252,7 +252,7 @@ void TileReader::init() pipelineLayout = vsg::PipelineLayout::create(vsg::DescriptorSetLayouts{descriptorSetLayout}, pushConstantRanges); sampler = vsg::Sampler::create(); - sampler->maxLod = mipmapLevelsHint; + sampler->maxLod = static_cast(mipmapLevelsHint); sampler->addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler->addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; sampler->addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; @@ -436,15 +436,10 @@ vsg::ref_ptr TileReader::createTextureQuad(const vsg::dbox& tile_exte scenegraph->addChild(transform); // set up vertex and index arrays - float min_x = tile_extents.min.x; - float min_y = tile_extents.min.y; -#if 1 - float max_x = tile_extents.max.x; - float max_y = tile_extents.max.y; -#else - float max_x = tile_extents.min.x * 0.05 + tile_extents.max.x * 0.95; - float max_y = tile_extents.min.y * 0.05 + tile_extents.max.y * 0.95; -#endif + float min_x = static_cast(tile_extents.min.x); + float min_y = static_cast(tile_extents.min.y); + float max_x = static_cast(tile_extents.max.x); + float max_y = static_cast(tile_extents.max.y); auto vertices = vsg::vec3Array::create( {{min_x, 0.0f, min_y}, diff --git a/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp b/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp index 3c07f6be..3b47c10d 100644 --- a/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp +++ b/examples/nodes/vsgtextureprojection/vsgtextureprojection.cpp @@ -67,11 +67,11 @@ vsg::ref_ptr createLargeTestScene(vsg::ref_ptr options, if (requiresBase) { - double diameter = vsg::length(bounds.max - bounds.min); - geomInfo.position.set((bounds.min.x + bounds.max.x)*0.5, (bounds.min.y + bounds.max.y)*0.5, bounds.min.z); - geomInfo.dx.set(diameter, 0.0, 0.0); - geomInfo.dy.set(0.0, diameter, 0.0); - geomInfo.dz.set(0.0, 0.0, 1.0); + float diameter = static_cast(vsg::length(bounds.max - bounds.min)); + geomInfo.position.set(static_cast((bounds.min.x + bounds.max.x)*0.5), static_cast((bounds.min.y + bounds.max.y)*0.5), static_cast(bounds.min.z)); + geomInfo.dx.set(diameter, 0.0f, 0.0f); + geomInfo.dy.set(0.0f, diameter, 0.0f); + geomInfo.dz.set(0.0f, 0.0f, 1.0f); geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f); stateInfo.two_sided = true; @@ -569,7 +569,7 @@ int main(int argc, char** argv) auto directionalLight = vsg::DirectionalLight::create(); directionalLight->name = "directional"; directionalLight->color.set(1.0, 1.0, 1.0); - directionalLight->intensity = 0.9; + directionalLight->intensity = 0.9f; directionalLight->direction = direction; if (numShadowMapsPerLight > 0) { @@ -580,7 +580,7 @@ int main(int argc, char** argv) auto ambientLight = vsg::AmbientLight::create(); ambientLight->name = "ambient"; ambientLight->color.set(1.0, 1.0, 1.0); - ambientLight->intensity = 0.2; + ambientLight->intensity = 0.2f; group->addChild(ambientLight); } diff --git a/examples/platform/vsgwin32/vsgwin32.cpp b/examples/platform/vsgwin32/vsgwin32.cpp index 02d41fea..16197598 100644 --- a/examples/platform/vsgwin32/vsgwin32.cpp +++ b/examples/platform/vsgwin32/vsgwin32.cpp @@ -105,7 +105,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR lpszCmdLine, i thread->join(); delete thread; - return (msg.wParam); + return static_cast(msg.wParam); } LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) diff --git a/examples/state/vsgclip/vsgclip.cpp b/examples/state/vsgclip/vsgclip.cpp index 9671b2dd..152ce298 100644 --- a/examples/state/vsgclip/vsgclip.cpp +++ b/examples/state/vsgclip/vsgclip.cpp @@ -62,7 +62,7 @@ class IntersectionHandler : public vsg::Inheritat(0).w = scale; + world_clipSettings->at(0).w = static_cast(scale); world_clipSettings->dirty(); } @@ -77,7 +77,10 @@ class IntersectionHandler : public vsg::Inheritintersections.begin(), intersector->intersections.end(), [](auto lhs, auto rhs) { return lhs->ratio < rhs->ratio; }); auto& intersection = *intersector->intersections.front(); - world_clipSettings->at(0) = vsg::vec4(intersection.worldIntersection.x, intersection.worldIntersection.y, intersection.worldIntersection.z, scale); + world_clipSettings->at(0) = vsg::vec4(static_cast(intersection.worldIntersection.x), + static_cast(intersection.worldIntersection.y), + static_cast(intersection.worldIntersection.z), + static_cast(scale)); world_clipSettings->dirty(); } @@ -302,7 +305,7 @@ int main(int argc, char** argv) viewer->compile(); - worldClipSettings->set(0, vsg::vec4(centre.x, centre.y, centre.z, radius * 0.3)); + worldClipSettings->set(0, vsg::vec4(static_cast(centre.x), static_cast(centre.y), static_cast(centre.z), static_cast(radius * 0.3))); auto startTime = std::chrono::steady_clock::now(); double frameCount = 0.0; @@ -327,7 +330,7 @@ int main(int argc, char** argv) vsg::dvec3 world_center(world_sphere.x, world_sphere.y, world_sphere.z); vsg::dvec3 eye_center = viewMatrix * world_center; - eye_sphere.set(eye_center.x, eye_center.y, eye_center.z, world_sphere.w); + eye_sphere.set(static_cast(eye_center.x), static_cast(eye_center.y), static_cast(eye_center.z), static_cast(world_sphere.w)); eyeClipSettings->dirty(); } diff --git a/examples/state/vsgcomputevertex/vsgcomputevertex.cpp b/examples/state/vsgcomputevertex/vsgcomputevertex.cpp index 757fff89..5cc6a37a 100644 --- a/examples/state/vsgcomputevertex/vsgcomputevertex.cpp +++ b/examples/state/vsgcomputevertex/vsgcomputevertex.cpp @@ -170,7 +170,7 @@ int main(int argc, char** argv) viewer->update(); double frameTime = std::chrono::duration(viewer->getFrameStamp()->time - viewer->start_point()).count(); - computeScale->at(0).z = sin(frameTime); + computeScale->at(0).z = static_cast(sin(frameTime)); computeScale->dirty(); viewer->recordAndSubmit(); diff --git a/examples/state/vsgdynamictexture/vsgdynamictexture.cpp b/examples/state/vsgdynamictexture/vsgdynamictexture.cpp index 67b5b18b..01cd49ef 100644 --- a/examples/state/vsgdynamictexture/vsgdynamictexture.cpp +++ b/examples/state/vsgdynamictexture/vsgdynamictexture.cpp @@ -11,16 +11,16 @@ class UpdateImage : public vsg::Visitor { using value_type = typename A::value_type; float r_mult = 1.0f / static_cast(image.height() - 1); - float r_offset = 0.5f + sin(value) * 0.25f; + float r_offset = 0.5f + static_cast(sin(value)) * 0.25f; float c_mult = 1.0f / static_cast(image.width() - 1); - float c_offset = 0.5f + cos(value) * 0.25f; + float c_offset = 0.5f + static_cast(cos(value)) * 0.25f; - for (size_t r = 0; r < image.height(); ++r) + for (uint32_t r = 0; r < image.height(); ++r) { float r_ratio = static_cast(r) * r_mult; value_type* ptr = &image.at(0, r); - for (size_t c = 0; c < image.width(); ++c) + for (uint32_t c = 0; c < image.width(); ++c) { float c_ratio = static_cast(c) * c_mult; diff --git a/examples/state/vsgdynamictexture_cs/vsgdynamictexture_cs.cpp b/examples/state/vsgdynamictexture_cs/vsgdynamictexture_cs.cpp index 7df27548..e226d3e0 100644 --- a/examples/state/vsgdynamictexture_cs/vsgdynamictexture_cs.cpp +++ b/examples/state/vsgdynamictexture_cs/vsgdynamictexture_cs.cpp @@ -11,26 +11,33 @@ class UpdateImage : public vsg::Visitor { using value_type = typename A::value_type; float r_mult = 1.0f / static_cast(image.height() - 1); - float r_offset = 0.5f + sin(value) * 0.25f; + float r_offset = 0.5f + static_cast(sin(value)) * 0.25f; float c_mult = 1.0f / static_cast(image.width() - 1); - float c_offset = 0.5f + cos(value) * 0.25f; + float c_offset = 0.5f + static_cast(cos(value)) * 0.25f; - for (size_t r = 0; r < image.height(); ++r) + for (uint32_t r = 0; r < image.height(); ++r) { float r_ratio = static_cast(r) * r_mult; value_type* ptr = &image.at(0, r); - for (size_t c = 0; c < image.width(); ++c) + for (uint32_t c = 0; c < image.width(); ++c) { float c_ratio = static_cast(c) * c_mult; float intensity = 0.5f - ((r_ratio - r_offset) * (r_ratio - r_offset)) + ((c_ratio - c_offset) * (c_ratio - c_offset)); - ptr->r = intensity * intensity; - ptr->g = intensity; - ptr->b = intensity; - - if constexpr (std::is_same_v) ptr->a = 1.0f; + if constexpr (std::is_same_v) + { + (*ptr) = intensity * intensity; + } + else + { + ptr->r = intensity * intensity; + ptr->g = intensity; + ptr->b = intensity; + + if constexpr (std::is_same_v) ptr->a = 1.0f; + } ++ptr; } diff --git a/examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp b/examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp index cf276831..acd938af 100644 --- a/examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp +++ b/examples/state/vsgdynamicvertex/vsgdynamicvertex.cpp @@ -214,7 +214,7 @@ int main(int argc, char** argv) { for(auto& v : *vertices) { - v.z += (sin(vsg::PI * frameCount / 180.0) * radius * 0.001); + v.z += static_cast(sin(vsg::PI * frameCount / 180.0) * radius * 0.001); } vertices->dirty(); } diff --git a/examples/state/vsgtexturearray/vsgtexturearray.cpp b/examples/state/vsgtexturearray/vsgtexturearray.cpp index a1491171..d6b6b78f 100644 --- a/examples/state/vsgtexturearray/vsgtexturearray.cpp +++ b/examples/state/vsgtexturearray/vsgtexturearray.cpp @@ -8,10 +8,10 @@ void updateBaseTexture(vsg::ubvec4Array2D& image, float value) { - for (size_t r = 0; r < image.height(); ++r) + for (uint32_t r = 0; r < image.height(); ++r) { float r_ratio = static_cast(r) / static_cast(image.height() - 1); - for (size_t c = 0; c < image.width(); ++c) + for (uint32_t c = 0; c < image.width(); ++c) { float c_ratio = static_cast(c) / static_cast(image.width() - 1); @@ -21,8 +21,8 @@ void updateBaseTexture(vsg::ubvec4Array2D& image, float value) float distance_from_center = vsg::length(delta); - float intensity = (sin(1.0 * angle + 30.0f * distance_from_center + 10.0 * value) + 1.0f) * 0.5f; - image.set(c, r, vsg::ubvec4(uint8_t(intensity * intensity * 255.0), uint8_t(intensity * 255.0), uint8_t(intensity * 255.0), 255)); + float intensity = (sin(1.0f * angle + 30.0f * distance_from_center + 10.0f * value) + 1.0f) * 0.5f; + image.set(c, r, vsg::ubvec4(uint8_t(intensity * intensity * 255.0f), uint8_t(intensity * 255.0f), uint8_t(intensity * 255.0f), 255)); } } image.dirty(); @@ -30,10 +30,10 @@ void updateBaseTexture(vsg::ubvec4Array2D& image, float value) void updateElevation(vsg::floatArray2D& heightField, float value) { - for (size_t r = 0; r < heightField.height(); ++r) + for (uint32_t r = 0; r < heightField.height(); ++r) { float r_ratio = static_cast(r) / static_cast(heightField.height() - 1); - for (size_t c = 0; c < heightField.width(); ++c) + for (uint32_t c = 0; c < heightField.width(); ++c) { float c_ratio = static_cast(c) / static_cast(heightField.width() - 1); @@ -43,7 +43,7 @@ void updateElevation(vsg::floatArray2D& heightField, float value) float distance_from_center = vsg::length(delta); - float intensity = (sin(1.0 * angle + 10.0f * distance_from_center + 2.0 * value) + 1.0f) * 0.5f; + float intensity = (sin(1.0f * angle + 10.0f * distance_from_center + 2.0f * value) + 1.0f) * 0.5f; heightField.set(c, r, intensity); } } diff --git a/examples/text/vsgtext/vsgtext.cpp b/examples/text/vsgtext/vsgtext.cpp index 1d287678..65f9db31 100644 --- a/examples/text/vsgtext/vsgtext.cpp +++ b/examples/text/vsgtext/vsgtext.cpp @@ -276,7 +276,7 @@ int main(int argc, char** argv) layout->horizontal = vsg::vec3(1.0, 0.0, 0.0); layout->vertical = vsg::vec3(0.0, 1.0, 0.0); layout->color = vsg::vec4(1.0, 1.0, 1.0, 1.0); - layout->outlineWidth = 0.1; + layout->outlineWidth = 0.1f; layout->billboard = true; auto text = vsg::Text::create(); @@ -510,7 +510,7 @@ int main(int argc, char** argv) { quad.vertices[i].z += 0.5f * sin(quad.vertices[i].x); quad.colors[i].r = 0.5f + 0.5f * sin(quad.vertices[i].x); - quad.outlineColors[i] = vsg::vec4(cos(0.5 * quad.vertices[i].x), 0.1f, 0.0f, 1.0f); + quad.outlineColors[i] = vsg::vec4(cos(0.5f * quad.vertices[i].x), 0.1f, 0.0f, 1.0f); quad.outlineWidths[i] = 0.1f + 0.15f * (1.0f + sin(quad.vertices[i].x)); } } @@ -542,8 +542,8 @@ int main(int argc, char** argv) dynamic_text_layout->position = vsg::vec3(0.0, 0.0, -6.0); dynamic_text_layout->horizontal = vsg::vec3(1.0, 0.0, 0.0); dynamic_text_layout->vertical = dynamic_text_layout->billboard ? vsg::vec3(0.0, 1.0, 0.0) : vsg::vec3(0.0, 0.0, 1.0) ; - dynamic_text_layout->color = vsg::vec4(1.0, 0.9, 1.0, 1.0); - dynamic_text_layout->outlineWidth = 0.1; + dynamic_text_layout->color = vsg::vec4(1.0f, 0.9f, 1.0f, 1.0f); + dynamic_text_layout->outlineWidth = 0.1f; dynamic_text->text = dynamic_text_label; dynamic_text->font = font; @@ -606,7 +606,7 @@ int main(int argc, char** argv) { // update the dynamic_text label string and position dynamic_text_label->value() = vsg::make_string("GpuLayoutTechnique: ", viewer->getFrameStamp()->frameCount); - dynamic_text_layout->position.x += 0.01; + dynamic_text_layout->position.x += 0.01f; dynamic_text->setup(0, options); } diff --git a/examples/text/vsgtextgroup/vsgtextgroup.cpp b/examples/text/vsgtextgroup/vsgtextgroup.cpp index 63b09e5d..7b8b015f 100644 --- a/examples/text/vsgtextgroup/vsgtextgroup.cpp +++ b/examples/text/vsgtextgroup/vsgtextgroup.cpp @@ -87,7 +87,7 @@ int main(int argc, char** argv) layout->horizontal = horizontal; layout->vertical = vertical; layout->color = vsg::vec4(1.0, 1.0, 1.0, 1.0); - layout->outlineWidth = 0.1; + layout->outlineWidth = 0.1f; layout->billboard = billboard; layout->billboardAutoScaleDistance = billboardAutoScaleDistance; @@ -282,7 +282,7 @@ int main(int argc, char** argv) { quad.vertices[i].z += 0.5f * sin(quad.vertices[i].x); quad.colors[i].r = 0.5f + 0.5f * sin(quad.vertices[i].x); - quad.outlineColors[i] = vsg::vec4(cos(0.5 * quad.vertices[i].x), 0.1f, 0.0f, 1.0f); + quad.outlineColors[i] = vsg::vec4(cos(0.5f * quad.vertices[i].x), 0.1f, 0.0f, 1.0f); quad.outlineWidths[i] = 0.1f + 0.15f * (1.0f + sin(quad.vertices[i].x)); } } diff --git a/examples/threading/vsgdynamicload/vsgdynamicload.cpp b/examples/threading/vsgdynamicload/vsgdynamicload.cpp index d61ece09..889fa38f 100644 --- a/examples/threading/vsgdynamicload/vsgdynamicload.cpp +++ b/examples/threading/vsgdynamicload/vsgdynamicload.cpp @@ -209,7 +209,7 @@ int main(int argc, char** argv) vsg::dvec3 primary(2.0, 0.0, 0.0); vsg::dvec3 secondary(0.0, 2.0, 0.0); - int numModels = static_cast(argc - 1); + int numModels = argc - 1; int numColumns = static_cast(std::ceil(std::sqrt(static_cast(numModels)))); int numRows = static_cast(std::ceil(static_cast(numModels) / static_cast(numColumns))); diff --git a/examples/ui/vsginput/vsginput.cpp b/examples/ui/vsginput/vsginput.cpp index d0cfd8c1..a2fbb1bf 100644 --- a/examples/ui/vsginput/vsginput.cpp +++ b/examples/ui/vsginput/vsginput.cpp @@ -165,7 +165,7 @@ int main(int argc, char** argv) double aspectRatio = double(windowTraits->width) / double(windowTraits->height); double projectionHeight = 25.0; - vsg::vec3 position(2.0f, projectionHeight - 2.0f, 0.0f); + vsg::vec3 position(2.0f, static_cast(projectionHeight) - 2.0f, 0.0f); vsg::vec3 delta(0.0f, -2.0f, 0.0f); // main label @@ -177,8 +177,8 @@ int main(int argc, char** argv) main_layout->position = position; main_layout->horizontal = vsg::vec3(1.0f, 0.0f, 0.0f); main_layout->vertical = vsg::vec3(0.0f, 1.0f, 0.0f); - main_layout->color = vsg::vec4(1.0f, 1.0f, 0.3, 1.0f); - main_layout->outlineWidth = 0.1; + main_layout->color = vsg::vec4(1.0f, 1.0f, 0.3f, 1.0f); + main_layout->outlineWidth = 0.1f; main->text = main_label; main->font = font; @@ -199,7 +199,7 @@ int main(int argc, char** argv) pointer_layout->horizontal = vsg::vec3(1.0f, 0.0f, 0.0f); pointer_layout->vertical = vsg::vec3(0.0f, 1.0f, 0.0f); pointer_layout->color = vsg::vec4(1.0f, 1.0f, 1.0f, 1.0f); - pointer_layout->outlineWidth = 0.1; + pointer_layout->outlineWidth = 0.1f; auto pointer_string = vsg::stringValue::create("Pointer event:"); pointer_text->text = pointer_string; @@ -221,7 +221,7 @@ int main(int argc, char** argv) keyboard_layout->horizontal = vsg::vec3(1.0f, 0.0f, 0.0f); keyboard_layout->vertical = vsg::vec3(0.0f, 1.0f, 0.0f); keyboard_layout->color = vsg::vec4(1.0f, 1.0f, 1.0f, 1.0f); - keyboard_layout->outlineWidth = 0.1; + keyboard_layout->outlineWidth = 0.1f; auto keyboard_string = vsg::stringValue::create("Keyboard event:"); keyboard_text->text = keyboard_string; @@ -243,7 +243,7 @@ int main(int argc, char** argv) scroll_layout->horizontal = vsg::vec3(1.0f, 0.0f, 0.0f); scroll_layout->vertical = vsg::vec3(0.0f, 1.0f, 0.0f); scroll_layout->color = vsg::vec4(1.0f, 1.0f, 1.0f, 1.0f); - scroll_layout->outlineWidth = 0.1; + scroll_layout->outlineWidth = 0.1f; auto scroll_string = vsg::stringValue::create("Scroll event:"); scroll_text->text = scroll_string; @@ -265,7 +265,7 @@ int main(int argc, char** argv) application_layout->horizontal = vsg::vec3(1.0, 0.0, 0.0f); application_layout->vertical = vsg::vec3(0.0, 1.0, 0.0f); application_layout->color = vsg::vec4(1.0, 1.0, 1.0, 1.0f); - application_layout->outlineWidth = 0.1; + application_layout->outlineWidth = 0.1f; auto application_string = vsg::stringValue::create("Window event:"); window_text->text = application_string; @@ -287,7 +287,7 @@ int main(int argc, char** argv) application_layout->horizontal = vsg::vec3(1.0, 0.0, 0.0f); application_layout->vertical = vsg::vec3(0.0, 1.0, 0.0f); application_layout->color = vsg::vec4(1.0, 1.0, 1.0, 1.0f); - application_layout->outlineWidth = 0.1; + application_layout->outlineWidth = 0.1f; auto application_string = vsg::stringValue::create("Frame event:"); frame_text->text = application_string; diff --git a/examples/utils/vsgbuilder/vsgbuilder.cpp b/examples/utils/vsgbuilder/vsgbuilder.cpp index 0ecb188d..86457a2d 100644 --- a/examples/utils/vsgbuilder/vsgbuilder.cpp +++ b/examples/utils/vsgbuilder/vsgbuilder.cpp @@ -145,7 +145,7 @@ int main(int argc, char** argv) stateInfo.billboard = true; float w = std::pow(float(numVertices), 0.33f) * 2.0f * vsg::length(geomInfo.dx); - float scaleDistance = w*3.0; + float scaleDistance = w*3.0f; auto positions = vsg::vec4Array::create(numVertices); geomInfo.positions = positions; for (auto& v : *(positions)) diff --git a/examples/utils/vsgcustomshaderset/custom_pbr.h b/examples/utils/vsgcustomshaderset/custom_pbr.h index 1b065a7c..d53292fd 100644 --- a/examples/utils/vsgcustomshaderset/custom_pbr.h +++ b/examples/utils/vsgcustomshaderset/custom_pbr.h @@ -7,11 +7,11 @@ namespace custom // OpenGL style fog struct to pass to the GPU struct Fog { - vsg::vec3 color = {1.0, 1.0, 1.0}; - float density = 0.05; // OpenGL default is 1.0! - float start = 0.0; - float end = 1.0; - float exponent = 1.0; + vsg::vec3 color = {1.0f, 1.0f, 1.0f}; + float density = 0.05f; // OpenGL default is 1.0! + float start = 0.0f; + float end = 1.0f; + float exponent = 1.0f; void read(vsg::Input& input) { diff --git a/examples/utils/vsgintersection/vsgintersection.cpp b/examples/utils/vsgintersection/vsgintersection.cpp index fc7957d4..8053c035 100644 --- a/examples/utils/vsgintersection/vsgintersection.cpp +++ b/examples/utils/vsgintersection/vsgintersection.cpp @@ -41,9 +41,9 @@ class IntersectionHandler : public vsg::Inherit