Cleanup and refractoring

EGL / OpenGL ES also now working
This commit is contained in:
Curi0 2017-10-03 13:38:28 +05:30
parent e1c09aa2b5
commit e5d800c344
4 changed files with 43 additions and 46 deletions

View File

@ -5207,6 +5207,4 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window
}
#endif
#endif /* _glfw3_h_ */
extern int main();
#endif /* _glfw3_h_ */

View File

@ -25,9 +25,47 @@
//
//========================================================================
#include <android/log.h>
#include "internal.h"
extern int main();
void handle_cmd(struct android_app* _app, int32_t cmd) {
switch (cmd) {
case APP_CMD_INIT_WINDOW:
// The window is being shown so the initialization is finished.
app = _app;
break;
default:
__android_log_print(ANDROID_LOG_INFO, "GLFW",
"event not handled: %d", cmd);
}
}
// Android Entry Point
void android_main(struct android_app *app) {
app->onAppCmd = handle_cmd;
pthread_t t;pthread_create(&t, NULL, &main, NULL); // Call the main entry point
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;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
@ -35,6 +73,7 @@
int _glfwPlatformInit(void)
{
_glfwInitTimerPOSIX();
while (app == NULL); // Wait for the app to be initialized or the app will crash occasionally
return GLFW_TRUE;
}

View File

@ -48,8 +48,9 @@
#define _GLFW_PLATFORM_CONTEXT_STATE
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
// Null-specific per-window data
//
struct android_app* app;
// Android-specific per-window data
typedef struct _GLFWwindowAndroid
{
int width;

View File

@ -29,46 +29,6 @@
#include <android_native_app_glue.h>
#include <android/log.h>
struct android_app* app;
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");
default:
__android_log_print(ANDROID_LOG_INFO, "GLFW",
"event not handled: %d", cmd);
}
}
// Android Entry Point
void android_main(struct android_app *app) {
app->onAppCmd = handle_cmd;
pthread_t t;pthread_create(&t, NULL, &main, NULL); // Call the main entry point
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;
}
}
}
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
@ -78,7 +38,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
while (app == NULL); // Wait for the app to be initialized or the app will crash occasionally
window->android.app = app;
if (ctxconfig->client != GLFW_NO_API)