Vulkan now fully working

Tested on Xiaomi Redmi Note 4X runnning latest global update
This commit is contained in:
Curi0 2017-09-27 21:21:37 +05:30
parent 83c4c2d81a
commit 7848a3c72c

View File

@ -29,19 +29,45 @@
#include <android_native_app_glue.h> #include <android_native_app_glue.h>
#include <android/log.h> #include <android/log.h>
struct engine {
struct android_app* app; struct android_app* app;
};
struct engine engine; void handle_cmd(struct android_app* _app, int32_t cmd) {
switch (cmd) {
case APP_CMD_INIT_WINDOW:
// The window is being shown, get it ready.
app = _app;
__android_log_print(ANDROID_LOG_INFO, "GLFW",
"Window initialized", cmd);
default:
__android_log_print(ANDROID_LOG_INFO, "GLFW",
"event not handled: %d", cmd);
}
}
// Android Entry Point // Android Entry Point
void android_main(struct android_app *app) { void android_main(struct android_app *app) {
memset(&engine, 0, sizeof(engine)); app->onAppCmd = handle_cmd;
app->userData = &engine; pthread_t my_thread;
engine.app = &app; pthread_create(&my_thread, NULL, &glfwMain, NULL);
glfwMain(); while (1) {
int ident;
int events;
struct android_poll_source* source;
while ((ident=ALooper_pollAll(0, NULL, &events,(void**)&source)) >= 0) {
// Process this event.
if (source != NULL) {
source->process(app, source);
}
// Check if we are exiting.
if (app->destroyRequested != 0) {
return;
}
}
}
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -53,7 +79,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig, const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig) const _GLFWfbconfig* fbconfig)
{ {
window->android.app = &engine.app;
if (ctxconfig->client != GLFW_NO_API) if (ctxconfig->client != GLFW_NO_API)
{ {
if (ctxconfig->source == GLFW_EGL_CONTEXT_API) if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
@ -312,7 +337,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
memset(&sci, 0, sizeof(sci)); memset(&sci, 0, sizeof(sci));
sci.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; sci.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR;
sci.window = &window->android.app->window; sci.window = app->window;
err = vkCreateAndroidSurfaceKHR(instance, &sci, allocator, surface); err = vkCreateAndroidSurfaceKHR(instance, &sci, allocator, surface);
if (err) if (err)
@ -333,6 +358,5 @@ GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
return window->android.app; return app;
} }