mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Vulkan now fully working
Tested on Xiaomi Redmi Note 4X runnning latest global update
This commit is contained in:
parent
83c4c2d81a
commit
7848a3c72c
@ -29,19 +29,45 @@
|
||||
#include <android_native_app_glue.h>
|
||||
#include <android/log.h>
|
||||
|
||||
struct android_app* app;
|
||||
|
||||
struct engine {
|
||||
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
|
||||
void android_main(struct android_app *app) {
|
||||
memset(&engine, 0, sizeof(engine));
|
||||
app->userData = &engine;
|
||||
engine.app = &app;
|
||||
app->onAppCmd = handle_cmd;
|
||||
pthread_t my_thread;
|
||||
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 _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
window->android.app = &engine.app;
|
||||
if (ctxconfig->client != GLFW_NO_API)
|
||||
{
|
||||
if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
|
||||
@ -312,7 +337,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
|
||||
|
||||
memset(&sci, 0, sizeof(sci));
|
||||
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);
|
||||
if (err)
|
||||
@ -333,6 +358,5 @@ GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||
return window->android.app;
|
||||
return app;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user