Skip to content

Commit a1ae797

Browse files
committed
2 parents 039939d + ba0b537 commit a1ae797

File tree

31 files changed

+164
-165
lines changed

31 files changed

+164
-165
lines changed

CMakeLists.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,24 @@ endif()
6868
# install data
6969
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION share/vsgExamples)
7070

71-
# pure VSG examples
71+
# VSG examples
72+
add_subdirectory(examples/animation)
73+
add_subdirectory(examples/app)
74+
add_subdirectory(examples/commands)
7275
add_subdirectory(examples/core)
73-
add_subdirectory(examples/maths)
7476
add_subdirectory(examples/io)
75-
add_subdirectory(examples/ui)
76-
add_subdirectory(examples/state)
77-
add_subdirectory(examples/commands)
78-
add_subdirectory(examples/nodes)
79-
add_subdirectory(examples/threading)
80-
add_subdirectory(examples/app)
81-
add_subdirectory(examples/vk)
82-
add_subdirectory(examples/text)
77+
add_subdirectory(examples/lighting)
78+
add_subdirectory(examples/maths)
8379
add_subdirectory(examples/meshshaders)
84-
add_subdirectory(examples/raytracing)
80+
add_subdirectory(examples/nodes)
8581
add_subdirectory(examples/platform)
82+
add_subdirectory(examples/raytracing)
83+
add_subdirectory(examples/state)
84+
add_subdirectory(examples/text)
85+
add_subdirectory(examples/threading)
86+
add_subdirectory(examples/ui)
8687
add_subdirectory(examples/utils)
88+
add_subdirectory(examples/vk)
8789
add_subdirectory(examples/volume)
88-
add_subdirectory(examples/animation)
8990

9091
vsg_add_feature_summary()

examples/animation/vsganimation/vsganimation.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ int main(int argc, char** argv)
195195
{
196196
auto shaderHints = vsg::ShaderCompileSettings::create();
197197

198-
float penumbraRadius = 0.005;
198+
float penumbraRadius = 0.005f;
199199
if (arguments.read("--pcss"))
200200
{
201201
shadowSettings = vsg::PercentageCloserSoftShadows::create(numShadowMapsPerLight);
@@ -386,9 +386,9 @@ int main(int argc, char** argv)
386386
vsg::StateInfo stateInfo;
387387

388388
double margin = bounds.max.z - bounds.min.z;
389-
geomInfo.position.set((bounds.min.x + bounds.max.x) * 0.5, (bounds.min.y + bounds.max.y) * 0.5, 0.0);
390-
geomInfo.dx.set(bounds.max.x - bounds.min.x + margin, 0.0, 0.0);
391-
geomInfo.dy.set(0.0, bounds.max.y - bounds.min.y + margin, 0.0);
389+
geomInfo.position.set(static_cast<float>(bounds.min.x + bounds.max.x) * 0.5f, static_cast<float>(bounds.min.y + bounds.max.y) * 0.5f, 0.0f);
390+
geomInfo.dx.set(static_cast<float>(bounds.max.x - bounds.min.x + margin), 0.0f, 0.0f);
391+
geomInfo.dy.set(0.0, static_cast<float>(bounds.max.y - bounds.min.y + margin), 0.0f);
392392
geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f);
393393

394394
stateInfo.two_sided = true;
@@ -406,17 +406,17 @@ int main(int argc, char** argv)
406406
{
407407
auto directionalLight = vsg::DirectionalLight::create();
408408
directionalLight->name = "directional";
409-
directionalLight->color.set(1.0, 1.0, 1.0);
410-
directionalLight->intensity = 0.9;
409+
directionalLight->color.set(1.0f, 1.0f, 1.0f);
410+
directionalLight->intensity = 0.9f;
411411
directionalLight->direction = direction;
412412
directionalLight->shadowSettings = shadowSettings;
413413

414414
scene->addChild(directionalLight);
415415

416416
auto ambientLight = vsg::AmbientLight::create();
417417
ambientLight->name = "ambient";
418-
ambientLight->color.set(1.0, 1.0, 1.0);
419-
ambientLight->intensity = 0.1;
418+
ambientLight->color.set(1.0f, 1.0f, 1.0f);
419+
ambientLight->intensity = 0.1f;
420420
scene->addChild(ambientLight);
421421
}
422422

examples/app/vsganaglyphicstereo/vsganaglyphicstereo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ReplaceColorBlendState : public vsg::Visitor
6060
}
6161
};
6262

63-
vsg::ref_ptr<vsg::Node> createTextureQuad(const vsg::vec3& origin, const vsg::vec3& horizontal, const vsg::vec3& vertical, vsg::ref_ptr<vsg::Data> imageData, uint32_t mipmapLevelsHints = 0)
63+
vsg::ref_ptr<vsg::Node> createTextureQuad(const vsg::vec3& origin, const vsg::vec3& horizontal, const vsg::vec3& vertical, vsg::ref_ptr<vsg::Data> imageData, float mipmapLevelsHints = 0.0f)
6464
{
6565

6666
// set up search paths to SPIRV shaders and textures
@@ -239,8 +239,8 @@ int main(int argc, char** argv)
239239
if (leftImage && rightImage)
240240
{
241241
vsg::vec3 origin(0.0f, 0.0f, 0.0f);
242-
vsg::vec3 horizontal(leftImage->width(), 0.0f, 0.0f);
243-
vsg::vec3 vertical(0.0f, 0.0f, leftImage->height());
242+
vsg::vec3 horizontal(static_cast<float>(leftImage->width()), 0.0f, 0.0f);
243+
vsg::vec3 vertical(0.0f, 0.0f, static_cast<float>(leftImage->height()));
244244

245245
auto leftQuad = createTextureQuad(origin - offset * 0.5f, horizontal, vertical, leftImage);
246246
auto rightQuad = createTextureQuad(origin + offset * 0.5f, horizontal, vertical, rightImage);

examples/app/vsgcameras/vsgcameras.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ int main(int argc, char** argv)
232232

233233
// set up secondary views, one per camera found in the scene graph
234234
uint32_t margin = 10;
235-
uint32_t division = scene_cameras.size();
235+
uint32_t division = static_cast<uint32_t>(scene_cameras.size());
236236
if (division < 3) division = 3;
237237

238238
uint32_t secondary_width = width / division;

examples/io/vsgcluster/vsgcluster.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ int main(int argc, char** argv)
205205

206206
viewer->compile();
207207

208-
std::vector<uint64_t> buffer(1);
209-
uint32_t buffer_size = buffer.size() * sizeof(decltype(buffer)::value_type);
210-
211-
std::cout << "buffer_size = " << buffer_size << std::endl;
212-
213208
PacketBroadcaster broadcaster;
214209
broadcaster.broadcaster = bc;
215210

@@ -233,8 +228,6 @@ int main(int argc, char** argv)
233228

234229
if (rc)
235230
{
236-
//unsigned int size = rc->receive(buffer.data(), buffer_size);
237-
//std::cout << "received size = " << size << std::endl;
238231
auto object = receiver.receive();
239232
viewerData = object.cast<cluster::ViewerData>();
240233
if (viewerData)

examples/lighting/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_subdirectory(vsglights)
2+
add_subdirectory(vsgshadow)

examples/nodes/vsglights/vsglights.cpp renamed to examples/lighting/vsglights/vsglights.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ vsg::ref_ptr<vsg::Node> createTestScene(vsg::ref_ptr<vsg::Options> options)
3030

3131
auto bounds = vsg::visit<vsg::ComputeBounds>(scene).bounds;
3232
double diameter = vsg::length(bounds.max - bounds.min);
33-
geomInfo.position.set((bounds.min.x + bounds.max.x) * 0.5, (bounds.min.y + bounds.max.y) * 0.5, bounds.min.z);
34-
geomInfo.dx.set(diameter, 0.0, 0.0);
35-
geomInfo.dy.set(0.0, diameter, 0.0);
33+
geomInfo.position.set(static_cast<float>((bounds.min.x + bounds.max.x) * 0.5), static_cast<float>((bounds.min.y + bounds.max.y) * 0.5), static_cast<float>(bounds.min.z));
34+
geomInfo.dx.set(static_cast<float>(diameter), 0.0f, 0.0f);
35+
geomInfo.dy.set(0.0f, static_cast<float>(diameter), 0.0f);
3636

3737
scene->addChild(builder->createQuad(geomInfo, stateInfo));
3838

@@ -125,8 +125,8 @@ int main(int argc, char** argv)
125125
{
126126
auto ambientLight = vsg::AmbientLight::create();
127127
ambientLight->name = "ambient";
128-
ambientLight->color.set(1.0, 1.0, 1.0);
129-
ambientLight->intensity = 0.01;
128+
ambientLight->color.set(1.0f, 1.0f, 1.0f);
129+
ambientLight->intensity = 0.01f;
130130
group->addChild(ambientLight);
131131
}
132132

@@ -135,9 +135,9 @@ int main(int argc, char** argv)
135135
{
136136
auto directionalLight = vsg::DirectionalLight::create();
137137
directionalLight->name = "directional";
138-
directionalLight->color.set(1.0, 1.0, 1.0);
139-
directionalLight->intensity = 0.15;
140-
directionalLight->direction.set(0.0, -1.0, -1.0);
138+
directionalLight->color.set(1.0f, 1.0f, 1.0f);
139+
directionalLight->intensity = 0.15f;
140+
directionalLight->direction.set(0.0f, -1.0f, -1.0f);
141141
group->addChild(directionalLight);
142142
}
143143

@@ -146,9 +146,9 @@ int main(int argc, char** argv)
146146
{
147147
auto pointLight = vsg::PointLight::create();
148148
pointLight->name = "point";
149-
pointLight->color.set(1.0, 1.0, 0.0);
150-
pointLight->intensity = span * 0.5;
151-
pointLight->position.set(bounds.min.x, bounds.min.y, bounds.max.z + span * 0.3);
149+
pointLight->color.set(1.0f, 1.0f, 0.0);
150+
pointLight->intensity = static_cast<float>(span * 0.5);
151+
pointLight->position.set(static_cast<float>(bounds.min.x), static_cast<float>(bounds.min.y), static_cast<float>(bounds.max.z + span * 0.3));
152152

153153
// enable culling of the point light by decorating with a CullGroup
154154
auto cullGroup = vsg::CullGroup::create();
@@ -165,12 +165,12 @@ int main(int argc, char** argv)
165165
{
166166
auto spotLight = vsg::SpotLight::create();
167167
spotLight->name = "spot";
168-
spotLight->color.set(0.0, 1.0, 1.0);
169-
spotLight->intensity = span * 0.5;
170-
spotLight->position.set(bounds.max.x + span * 0.1, bounds.min.y - span * 0.1, bounds.max.z + span * 0.3);
168+
spotLight->color.set(0.0f, 1.0f, 1.0f);
169+
spotLight->intensity = static_cast<float>(span * 0.5);
170+
spotLight->position.set(static_cast<float>(bounds.max.x + span * 0.1), static_cast<float>(bounds.min.y - span * 0.1), static_cast<float>(bounds.max.z + span * 0.3));
171171
spotLight->direction = (bounds.min + bounds.max) * 0.5 - spotLight->position;
172-
spotLight->innerAngle = vsg::radians(8.0);
173-
spotLight->outerAngle = vsg::radians(9.0);
172+
spotLight->innerAngle = vsg::radians(8.0f);
173+
spotLight->outerAngle = vsg::radians(9.0f);
174174

175175
// enable culling of the spot light by decorating with a CullGroup
176176
auto cullGroup = vsg::CullGroup::create();
@@ -186,14 +186,14 @@ int main(int argc, char** argv)
186186
{
187187
auto ambientLight = vsg::AmbientLight::create();
188188
ambientLight->name = "ambient";
189-
ambientLight->color.set(1.0, 1.0, 1.0);
190-
ambientLight->intensity = 0.1;
189+
ambientLight->color.set(1.0f, 1.0f, 1.0f);
190+
ambientLight->intensity = 0.1f;
191191

192192
auto directionalLight = vsg::DirectionalLight::create();
193193
directionalLight->name = "head light";
194-
directionalLight->color.set(1.0, 1.0, 1.0);
195-
directionalLight->intensity = 0.9;
196-
directionalLight->direction.set(0.0, 0.0, -1.0);
194+
directionalLight->color.set(1.0f, 1.0f, 1.0f);
195+
directionalLight->intensity = 0.9f;
196+
directionalLight->direction.set(0.0f, 0.0f, -1.0f);
197197

198198
auto absoluteTransform = vsg::AbsoluteTransform::create();
199199
absoluteTransform->addChild(ambientLight);

examples/nodes/vsgshadow/vsgshadow.cpp renamed to examples/lighting/vsgshadow/vsgshadow.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ vsg::ref_ptr<vsg::Node> decorateIfRequired(vsg::ref_ptr<vsg::Node> node, const M
3737
{
3838
auto bb = vsg::visit<vsg::ComputeBounds>(node).bounds;
3939
auto lod = vsg::LOD::create();
40-
lod->bound = vsg::sphere((bb.min + bb.max) * 0.5, vsg::length(bb.max - bb.min));
40+
lod->bound = vsg::dsphere((bb.min + bb.max) * 0.5, vsg::length(bb.max - bb.min));
4141
lod->addChild(vsg::LOD::Child{settings.lodScreenRatio, node});
4242
return lod;
4343
}
@@ -77,10 +77,10 @@ vsg::ref_ptr<vsg::Node> createTestScene(const ModelSettings& settings)
7777
auto bounds = vsg::visit<vsg::ComputeBounds>(scene).bounds;
7878
if (settings.insertBaseGeometry)
7979
{
80-
double diameter = vsg::length(bounds.max - bounds.min);
81-
geomInfo.position.set((bounds.min.x + bounds.max.x) * 0.5, (bounds.min.y + bounds.max.y) * 0.5, bounds.min.z);
82-
geomInfo.dx.set(diameter, 0.0, 0.0);
83-
geomInfo.dy.set(0.0, diameter, 0.0);
80+
float diameter = static_cast<float>(vsg::length(bounds.max - bounds.min));
81+
geomInfo.position.set(static_cast<float>((bounds.min.x + bounds.max.x) * 0.5), static_cast<float>((bounds.min.y + bounds.max.y) * 0.5), static_cast<float>(bounds.min.z));
82+
geomInfo.dx.set(diameter, 0.0f, 0.0f);
83+
geomInfo.dy.set(0.0f, diameter, 0.0f);
8484
geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f);
8585

8686
stateInfo.two_sided = true;
@@ -155,11 +155,11 @@ vsg::ref_ptr<vsg::Node> createLargeTestScene(const ModelSettings& settings)
155155

156156
if (settings.insertBaseGeometry)
157157
{
158-
double diameter = vsg::length(bounds.max - bounds.min);
159-
geomInfo.position.set((bounds.min.x + bounds.max.x) * 0.5, (bounds.min.y + bounds.max.y) * 0.5, bounds.min.z);
160-
geomInfo.dx.set(diameter, 0.0, 0.0);
161-
geomInfo.dy.set(0.0, diameter, 0.0);
162-
geomInfo.dz.set(0.0, 0.0, 1.0);
158+
float diameter = static_cast<float>(vsg::length(bounds.max - bounds.min));
159+
geomInfo.position.set(static_cast<float>((bounds.min.x + bounds.max.x) * 0.5), static_cast<float>((bounds.min.y + bounds.max.y) * 0.5), static_cast<float>(bounds.min.z));
160+
geomInfo.dx.set(diameter, 0.0f, 0.0f);
161+
geomInfo.dy.set(0.0f, diameter, 0.0f);
162+
geomInfo.dz.set(0.0f, 0.0f, 1.0f);
163163
geomInfo.color.set(1.0f, 1.0f, 1.0f, 1.0f);
164164

165165
stateInfo.two_sided = true;
@@ -421,8 +421,8 @@ int main(int argc, char** argv)
421421

422422
auto inherit = arguments.read("--inherit");
423423
auto direction = arguments.value(vsg::dvec3(0.0, 0.0, -1.0), "--direction");
424-
auto angleSubtended = arguments.value<double>(0.0090f, "--angleSubtended");
425424
auto location = arguments.value<vsg::dvec3>({0.0, 0.0, 0.0}, "--location");
425+
auto angleSubtended = arguments.value<float>(0.0090f, "--angleSubtended");
426426
auto scale = arguments.value<double>(1.0, "--scale");
427427
double viewingDistance = scale;
428428

@@ -537,8 +537,8 @@ int main(int argc, char** argv)
537537
{
538538
directionalLight = vsg::DirectionalLight::create();
539539
directionalLight->name = "directional";
540-
directionalLight->color.set(1.0, 1.0, 1.0);
541-
directionalLight->intensity = 0.9;
540+
directionalLight->color.set(1.0f, 1.0f, 1.0f);
541+
directionalLight->intensity = 0.9f;
542542
directionalLight->direction = direction;
543543
directionalLight->angleSubtended = angleSubtended;
544544
directionalLight->shadowSettings = shadowSettings;
@@ -551,21 +551,21 @@ int main(int argc, char** argv)
551551
{
552552
ambientLight = vsg::AmbientLight::create();
553553
ambientLight->name = "ambient";
554-
ambientLight->color.set(1.0, 1.0, 1.0);
555-
ambientLight->intensity = 0.2;
554+
ambientLight->color.set(1.0f, 1.0f, 1.0f);
555+
ambientLight->intensity = 0.2f;
556556
group->addChild(ambientLight);
557557
}
558558

559559
if (numLights >= 3 && numLights < 4)
560560
{
561-
directionalLight->intensity = 0.7;
562-
ambientLight->intensity = 0.1;
561+
directionalLight->intensity = 0.7f;
562+
ambientLight->intensity = 0.1f;
563563

564564
auto directionalLight2 = vsg::DirectionalLight::create();
565565
directionalLight2->name = "2nd directional";
566-
directionalLight2->color.set(1.0, 1.0, 0.0);
567-
directionalLight2->intensity = 0.7;
568-
directionalLight2->direction = vsg::normalize(vsg::vec3(0.9, 1.0, -1.0));
566+
directionalLight2->color.set(1.0f, 1.0f, 0.0f);
567+
directionalLight2->intensity = 0.7f;
568+
directionalLight2->direction = vsg::normalize(vsg::dvec3(0.9, 1.0, -1.0));
569569
directionalLight2->angleSubtended = angleSubtended;
570570
directionalLight2->shadowSettings = shadowSettings;
571571

@@ -576,15 +576,15 @@ int main(int argc, char** argv)
576576
{
577577
auto spotLight = vsg::SpotLight::create();
578578
spotLight->name = "spot";
579-
spotLight->color.set(0.0, 1.0, 1.0);
580-
spotLight->intensity = 200.0;
579+
spotLight->color.set(0.0f, 1.0f, 1.0f);
580+
spotLight->intensity = 200.0f;
581581
spotLight->position = vsg::vec3(3.0, 0.5, 15.0);
582582
spotLight->direction = vsg::normalize(vsg::vec3(-0.5, -1, -10));
583583
if (largeScene)
584584
{
585585
spotLight->position = vsg::vec3(3000.0, 500.0, 15000.0);
586586
spotLight->direction = vsg::normalize(vsg::dvec3(500, 500, 0) - spotLight->position);
587-
spotLight->intensity = 15000.0 * 15000.0 / 4.0;
587+
spotLight->intensity = static_cast<float>(15000.0 * 15000.0 / 4.0);
588588
}
589589
spotLight->outerAngle = vsg::radians(10.0);
590590
spotLight->innerAngle = vsg::radians(5.0);

0 commit comments

Comments
 (0)