Scale text overlay based on Android display DPI

This commit is contained in:
saschawillems 2017-03-10 17:52:53 +01:00
parent 82521aaafb
commit 8b6cdf4e95
3 changed files with 33 additions and 0 deletions

View file

@ -22,6 +22,10 @@
#include "VulkanBuffer.hpp"
#include "VulkanDevice.hpp"
#if defined(__ANDROID__)
#include "vulkanandroid.h"
#endif
#include "../external/stb/stb_font_consolas_24_latin1.inl"
// Defines for the STB font used
@ -116,6 +120,23 @@ public:
this->frameBufferWidth = framebufferwidth;
this->frameBufferHeight = framebufferheight;
#if defined(__ANDROID__)
// Scale text on Android devices with high DPI
int32_t screenDensity = vks::android::getScreenDensity();
if (screenDensity >= ACONFIGURATION_DENSITY_XXHIGH) {
LOGD("XXHIGH");
scale = 2.0f;
}
else if (screenDensity >= ACONFIGURATION_DENSITY_XHIGH) {
LOGD("XHIGH");
scale = 1.5f;
}
else if (screenDensity >= ACONFIGURATION_DENSITY_HIGH) {
LOGD("HIGH");
scale = 1.25f;
};
#endif
cmdBuffers.resize(framebuffers.size());
prepareResources();
prepareRenderPass();