添加 android create surface
This commit is contained in:
@@ -20,6 +20,8 @@ void handle_cmd(android_app *pApp, int32_t cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
android_app* g_android_app = nullptr;
|
||||
|
||||
void android_main(struct android_app *pApp) {
|
||||
aout << "Welcome to android_main" << std::endl;
|
||||
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
#include "Application.h"
|
||||
#ifndef _WIN32
|
||||
|
||||
#else
|
||||
#include <game-activity/native_app_glue/android_native_app_glue.h>
|
||||
#include <game-activity/GameActivity.h>
|
||||
#include "../app/src/main/cpp/AndroidOut.h"
|
||||
#endif
|
||||
|
||||
bool enableValidationLayers = true;
|
||||
|
||||
@@ -71,11 +78,29 @@ void Application::run()
|
||||
cleanup();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
#else
|
||||
extern android_app* g_android_app
|
||||
#endif
|
||||
|
||||
void Application::createSurface() {
|
||||
#ifdef _WIN32
|
||||
if (glfwCreateWindowSurface(instance, window, nullptr, &surface) != VK_SUCCESS) {
|
||||
throw std::runtime_error("failed to create window surface!");
|
||||
}
|
||||
#else
|
||||
if (instance == VK_NULL_HANDLE || !g_android_app)
|
||||
{
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkSurfaceKHR surface{};
|
||||
|
||||
VkAndroidSurfaceCreateInfoKHR info{VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR};
|
||||
|
||||
info.window = g_android_app->window;
|
||||
|
||||
VK_CHECK(vkCreateAndroidSurfaceKHR(instance, &info, nullptr, &surface));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user