Read android config values [skip ci]
This commit is contained in:
parent
219da74df4
commit
9edc993bf9
4 changed files with 18 additions and 9 deletions
|
|
@ -122,16 +122,15 @@ public:
|
|||
|
||||
#if defined(__ANDROID__)
|
||||
// Scale text on Android devices with high DPI
|
||||
int32_t screenDensity = vks::android::getScreenDensity();
|
||||
if (screenDensity >= ACONFIGURATION_DENSITY_XXHIGH) {
|
||||
if (vks::android::screenDensity >= ACONFIGURATION_DENSITY_XXHIGH) {
|
||||
LOGD("XXHIGH");
|
||||
scale = 2.0f;
|
||||
}
|
||||
else if (screenDensity >= ACONFIGURATION_DENSITY_XHIGH) {
|
||||
else if (vks::android::screenDensity >= ACONFIGURATION_DENSITY_XHIGH) {
|
||||
LOGD("XHIGH");
|
||||
scale = 1.5f;
|
||||
}
|
||||
else if (screenDensity >= ACONFIGURATION_DENSITY_HIGH) {
|
||||
else if (vks::android::screenDensity >= ACONFIGURATION_DENSITY_HIGH) {
|
||||
LOGD("HIGH");
|
||||
scale = 1.25f;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -119,6 +119,8 @@ PFN_vkCmdCopyQueryPoolResults vkCmdCopyQueryPoolResults;
|
|||
PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR;
|
||||
PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR;
|
||||
|
||||
int32_t vks::android::screenDensity;
|
||||
|
||||
void *libVulkan;
|
||||
|
||||
namespace vks
|
||||
|
|
@ -282,13 +284,13 @@ namespace vks
|
|||
dlclose(libVulkan);
|
||||
}
|
||||
|
||||
int32_t getScreenDensity()
|
||||
void getDeviceConfig()
|
||||
{
|
||||
// Screen density
|
||||
AConfiguration* config = AConfiguration_new();
|
||||
AConfiguration_fromAssetManager(config, androidApp->activity->assetManager);
|
||||
int32_t density = AConfiguration_getDensity(config);
|
||||
vks::android::screenDensity = AConfiguration_getDensity(config);
|
||||
AConfiguration_delete(config);
|
||||
return density;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,11 +156,17 @@ namespace vks
|
|||
{
|
||||
namespace android
|
||||
{
|
||||
/* @brief Touch control thresholds from Android NDK samples */
|
||||
const int32_t DOUBLE_TAP_TIMEOUT = 300 * 1000000;
|
||||
const int32_t DOUBLE_TAP_SLOP = 100;
|
||||
|
||||
/** @brief Density of the device screen (in DPI) */
|
||||
extern int32_t screenDensity;
|
||||
|
||||
bool loadVulkanLibrary();
|
||||
void loadVulkanFunctions(VkInstance instance);
|
||||
void freeVulkanLibrary();
|
||||
/** @brief Returns the density of the device screen (in DPI) */
|
||||
int32_t getScreenDensity();
|
||||
void getDeviceConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ public:
|
|||
} touchPos;
|
||||
bool touchDown = false;
|
||||
double touchTimer = 0.0;
|
||||
int64_t lastTapTime = 0;
|
||||
/** @brief Product model and manufacturer of the Android device (via android.Product*) */
|
||||
std::string androidProduct;
|
||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
|
|
@ -423,6 +424,7 @@ void android_main(android_app* state) \
|
|||
state->onAppCmd = VulkanExample::handleAppCommand; \
|
||||
state->onInputEvent = VulkanExample::handleAppInput; \
|
||||
androidApp = state; \
|
||||
vks::android::getDeviceConfig(); \
|
||||
vulkanExample->renderLoop(); \
|
||||
delete(vulkanExample); \
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue