Added ETC2 and ASTC texture variants (Refs #174), only enable wireframe if non solid fillmode is supported by the device
This commit is contained in:
parent
83806a43c2
commit
4cc7b204df
7 changed files with 86 additions and 37 deletions
|
|
@ -104,8 +104,6 @@ public:
|
|||
cameraPos = { 0.1f, 1.1f, 0.0f };
|
||||
enableTextOverlay = true;
|
||||
title = "Vulkan Example - Model rendering";
|
||||
// Enable physical device features required for this example
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
}
|
||||
|
||||
~VulkanExample()
|
||||
|
|
@ -124,6 +122,14 @@ public:
|
|||
uniformBuffers.scene.destroy();
|
||||
}
|
||||
|
||||
virtual void getEnabledFeatures()
|
||||
{
|
||||
// Fill mode non solid is required for wireframe display
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
enabledFeatures.fillModeNonSolid = VK_TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
void reBuildCommandBuffers()
|
||||
{
|
||||
if (!checkCommandBuffers())
|
||||
|
|
@ -356,7 +362,18 @@ public:
|
|||
void loadAssets()
|
||||
{
|
||||
loadModel(getAssetPath() + "models/voyager/voyager.dae");
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
|
||||
if (deviceFeatures.textureCompressionBC) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_bc3_unorm.ktx", VK_FORMAT_BC3_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else if (deviceFeatures.textureCompressionASTC_LDR) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_astc_8x8_unorm.ktx", VK_FORMAT_ASTC_8x8_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else if (deviceFeatures.textureCompressionETC2) {
|
||||
textures.colorMap.loadFromFile(getAssetPath() + "models/voyager/voyager_etc2_unorm.ktx", VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, vulkanDevice, queue);
|
||||
}
|
||||
else {
|
||||
vks::tools::exitFatal("Device does not support any compressed texture format!", "Error");
|
||||
}
|
||||
}
|
||||
|
||||
void setupVertexDescriptions()
|
||||
|
|
@ -568,10 +585,11 @@ public:
|
|||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.solid));
|
||||
|
||||
// Wire frame rendering pipeline
|
||||
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
|
||||
rasterizationState.lineWidth = 1.0f;
|
||||
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireframe));
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
|
||||
rasterizationState.lineWidth = 1.0f;
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireframe));
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare and initialize uniform buffer containing shader uniforms
|
||||
|
|
@ -649,19 +667,23 @@ public:
|
|||
{
|
||||
case KEY_W:
|
||||
case GAMEPAD_BUTTON_A:
|
||||
wireframe = !wireframe;
|
||||
reBuildCommandBuffers();
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
wireframe = !wireframe;
|
||||
reBuildCommandBuffers();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void getOverlayText(VulkanTextOverlay *textOverlay)
|
||||
{
|
||||
if (deviceFeatures.fillModeNonSolid) {
|
||||
#if defined(__ANDROID__)
|
||||
textOverlay->addText("Press \"Button A\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
textOverlay->addText("Press \"Button A\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#else
|
||||
textOverlay->addText("Press \"w\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
textOverlay->addText("Press \"w\" to toggle wireframe", 5.0f, 85.0f, VulkanTextOverlay::alignLeft);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue