Skip to content

Commit 431792e

Browse files
Merge pull request #400 from samuel-morales88/02_Validation_Layers_Correction
00_Base: Added code snippet for private class member to tutorial. 02…
2 parents 9dcdbeb + 1f4500c commit 431792e

2 files changed

Lines changed: 39 additions & 30 deletions

File tree

en/03_Drawing_a_triangle/00_Setup/00_Base_code.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,15 @@ glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
227227
----
228228

229229
All that's left now is creating the actual window. Add a `GLFWwindow* window;`
230-
private class member to store a reference to it and initialize the window with:
230+
private class member to store a reference to it:
231+
232+
[,c++]
233+
----
234+
private:
235+
GLFWwindow *window = nullptr;
236+
----
237+
238+
and initialize the window with:
231239

232240
[,c++]
233241
----

en/03_Drawing_a_triangle/00_Setup/02_Validation_layers.adoc

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ void createInstance()
120120
121121
// Check if the required layers are supported by the Vulkan implementation.
122122
auto layerProperties = context.enumerateInstanceLayerProperties();
123-
auto unsupportedLayerIt = std::ranges::find_if(requiredLayers,
123+
auto unsupportedLayerIt = std::ranges::find_if(requiredLayers,
124124
[&layerProperties](auto const &requiredLayer) {
125125
return std::ranges::none_of(layerProperties,
126-
[requiredLayer](auto const &layerProperty) { return strcmp(layerProperty.layerName, requiredLayer) == 0; });
126+
[requiredLayer](auto const &layerProperty) { return strcmp(layerProperty.layerName, requiredLayer) == 0; });
127127
});
128-
if (unsupportedLayerIt != requiredLayers.end())
129-
{
130-
throw std::runtime_error("Required layer not supported: " + std::string(*unsupportedLayerIt));
131-
}
128+
if (unsupportedLayerIt != requiredLayers.end())
129+
{
130+
throw std::runtime_error("Required layer not supported: " + std::string(*unsupportedLayerIt));
131+
}
132132
133133
...
134134
}
@@ -170,21 +170,20 @@ void createInstance()
170170
{
171171
...
172172
173-
// Get the required extensions.
174-
auto requiredExtensions = getRequiredInstanceExtensions();
173+
// Get the required extensions.
174+
auto requiredExtensions = getRequiredInstanceExtensions();
175175
176-
// Check if the required extensions are supported by the Vulkan implementation.
177-
auto extensionProperties = context.enumerateInstanceExtensionProperties();
178-
auto unsupportedPropertyIt =
179-
std::ranges::find_if(requiredExtensions,
180-
[&extensionProperties](auto const &requiredExtension) {
181-
return std::ranges::none_of(extensionProperties,
182-
[requiredExtension](auto const &extensionProperty) { return strcmp(extensionProperty.extensionName, requiredExtension) == 0; });
183-
});
184-
if (unsupportedPropertyIt != requiredExtensions.end())
185-
{
186-
throw std::runtime_error("Required extension not supported: " + std::string(*unsupportedPropertyIt));
187-
}
176+
// Check if the required extensions are supported by the Vulkan implementation.
177+
auto extensionProperties = context.enumerateInstanceExtensionProperties();
178+
auto unsupportedLayerIt = std::ranges::find_if(requiredLayers,
179+
[&layerProperties](auto const &requiredLayer) {
180+
return std::ranges::none_of(layerProperties,
181+
[requiredLayer](auto const &layerProperty) { return strcmp(layerProperty.layerName, requiredLayer) == 0; });
182+
});
183+
if (unsupportedPropertyIt != requiredExtensions.end())
184+
{
185+
throw std::runtime_error("Required extension not supported: " + std::string(*unsupportedPropertyIt));
186+
}
188187
189188
...
190189
}
@@ -388,19 +387,21 @@ void createInstance()
388387
389388
// Get the required layers
390389
std::vector<char const*> requiredLayers;
391-
if (enableValidationLayers) {
392-
requiredLayers.assign(validationLayers.begin(), validationLayers.end());
393-
}
390+
if (enableValidationLayers)
391+
{
392+
requiredLayers.assign(validationLayers.begin(), validationLayers.end());
393+
}
394394
395395
// Check if the required layers are supported by the Vulkan implementation.
396396
auto layerProperties = context.enumerateInstanceLayerProperties();
397-
if (std::ranges::any_of(requiredLayers, [&layerProperties](auto const& requiredLayer) {
398-
return std::ranges::none_of(layerProperties,
399-
[requiredLayer](auto const& layerProperty)
400-
{ return strcmp(layerProperty.layerName, requiredLayer) == 0; });
401-
}))
397+
auto unsupportedLayerIt = std::ranges::find_if(requiredLayers,
398+
[&layerProperties](auto const &requiredLayer) {
399+
return std::ranges::none_of(layerProperties,
400+
[requiredLayer](auto const &layerProperty) { return strcmp(layerProperty.layerName, requiredLayer) == 0; });
401+
});
402+
if (unsupportedLayerIt != requiredLayers.end())
402403
{
403-
throw std::runtime_error("One or more required layers are not supported!");
404+
throw std::runtime_error("Required layer not supported: " + std::string(*unsupportedLayerIt));
404405
}
405406
406407
// Get the required extensions.

0 commit comments

Comments
 (0)