Android event handler (#97)
This commit is contained in:
parent
0ffc005c8f
commit
87fd1be105
2 changed files with 37 additions and 3 deletions
|
|
@ -864,7 +864,40 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(__ANDROID__)
|
#elif defined(__ANDROID__)
|
||||||
// todo : Android event handling
|
void VulkanExampleBase::handleAppCommand(android_app * app, int32_t cmd)
|
||||||
|
{
|
||||||
|
assert(app->userData != NULL);
|
||||||
|
VulkanExampleBase* vulkanExample = (VulkanExampleBase*)app->userData;
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case APP_CMD_SAVE_STATE:
|
||||||
|
/*
|
||||||
|
vulkanExample->app->savedState = malloc(sizeof(struct saved_state));
|
||||||
|
*((struct saved_state*)vulkanExample->app->savedState) = vulkanExample->state;
|
||||||
|
vulkanExample->app->savedStateSize = sizeof(struct saved_state);
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case APP_CMD_INIT_WINDOW:
|
||||||
|
LOGD("APP_CMD_INIT_WINDOW");
|
||||||
|
if (vulkanExample->androidApp->window != NULL)
|
||||||
|
{
|
||||||
|
LOGI("Initializing Vulkan...");
|
||||||
|
vulkanExample->initVulkan(false);
|
||||||
|
vulkanExample->initSwapchain();
|
||||||
|
vulkanExample->prepare();
|
||||||
|
assert(vulkanExample->prepared);
|
||||||
|
LOGI("Vulkan initialized");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGE("No window assigned!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case APP_CMD_LOST_FOCUS:
|
||||||
|
//vulkanExample->animating = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
// Set up a window using XCB and request event types
|
// Set up a window using XCB and request event types
|
||||||
xcb_window_t VulkanExampleBase::setupWindow()
|
xcb_window_t VulkanExampleBase::setupWindow()
|
||||||
|
|
@ -1190,3 +1223,4 @@ void VulkanExampleBase::setupSwapChain()
|
||||||
{
|
{
|
||||||
swapChain.create(setupCmdBuffer, &width, &height);
|
swapChain.create(setupCmdBuffer, &width, &height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,7 @@ public:
|
||||||
HWND setupWindow(HINSTANCE hinstance, WNDPROC wndproc);
|
HWND setupWindow(HINSTANCE hinstance, WNDPROC wndproc);
|
||||||
void handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
void handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
#elif defined(__ANDROID__)
|
#elif defined(__ANDROID__)
|
||||||
// todo : add event handler for Android
|
static void handleAppCommand(android_app* app, int32_t cmd);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
xcb_window_t setupWindow();
|
xcb_window_t setupWindow();
|
||||||
void initxcbConnection();
|
void initxcbConnection();
|
||||||
|
|
@ -231,7 +231,7 @@ public:
|
||||||
void createPipelineCache();
|
void createPipelineCache();
|
||||||
|
|
||||||
// Prepare commonly used Vulkan functions
|
// Prepare commonly used Vulkan functions
|
||||||
void prepare();
|
virtual void prepare();
|
||||||
|
|
||||||
// Load a SPIR-V shader
|
// Load a SPIR-V shader
|
||||||
VkPipelineShaderStageCreateInfo loadShader(const char* fileName, VkShaderStageFlagBits stage);
|
VkPipelineShaderStageCreateInfo loadShader(const char* fileName, VkShaderStageFlagBits stage);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue