More changes

This commit is contained in:
Curi0 2017-10-18 10:18:33 +05:30
parent a0d99c8b59
commit 51000fdbb7
3 changed files with 19 additions and 12 deletions

View File

@ -568,7 +568,6 @@ GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
#endif #endif
#if defined(GLFW_EXPOSE_NATIVE_ANDROID) #if defined(GLFW_EXPOSE_NATIVE_ANDROID)
#include <android_native_app_glue.h>
GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* window); GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* window);
#endif #endif

View File

@ -63,7 +63,7 @@ elseif (_GLFW_ANDROID)
set(glfw_HEADERS ${common_HEADERS} android_platform.h android_joystick.h set(glfw_HEADERS ${common_HEADERS} android_platform.h android_joystick.h
posix_time.h posix_thread.h) posix_time.h posix_thread.h)
set(glfw_SOURCES ${common_SOURCES} android_init.c android_monitor.c android_window.c set(glfw_SOURCES ${common_SOURCES} android_init.c android_monitor.c android_window.c
android_joystick.c posix_time.c posix_thread.c egl_context.c osmesa_context.c ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) android_joystick.c posix_time.c posix_thread.c egl_context.c osmesa_context.c "${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c")
endif() endif()
if (APPLE) if (APPLE)

View File

@ -32,7 +32,8 @@ float x,y;
static int32_t handle_input(struct android_app* app, AInputEvent* event) static int32_t handle_input(struct android_app* app, AInputEvent* event)
{ {
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION)
for (size_t i = 0; i < AMotionEvent_getPointerCount(event); ++i) { for (size_t i = 0; i < AMotionEvent_getPointerCount(event); ++i)
{
x = AMotionEvent_getX(event, i); x = AMotionEvent_getX(event, i);
y = AMotionEvent_getY(event, i); y = AMotionEvent_getY(event, i);
} }
@ -55,14 +56,18 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
ANativeWindow_setBuffersGeometry(window->android->window, wndconfig->width, wndconfig->height, 0); ANativeWindow_setBuffersGeometry(window->android->window, wndconfig->width, wndconfig->height, 0);
if (ctxconfig->client != GLFW_NO_API) { if (ctxconfig->client != GLFW_NO_API)
{
if ((ctxconfig->source == GLFW_NATIVE_CONTEXT_API) | if ((ctxconfig->source == GLFW_NATIVE_CONTEXT_API) |
(ctxconfig->source == GLFW_EGL_CONTEXT_API)) { (ctxconfig->source == GLFW_EGL_CONTEXT_API))
{
if (!_glfwInitEGL()) if (!_glfwInitEGL())
return GLFW_FALSE; return GLFW_FALSE;
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
return GLFW_FALSE; return GLFW_FALSE;
} else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API) { }
else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
{
if (!_glfwInitOSMesa()) if (!_glfwInitOSMesa())
return GLFW_FALSE; return GLFW_FALSE;
if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
@ -70,7 +75,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
} }
} }
return GLFW_TRUE; return GLFW_TRUE;
} }
@ -110,8 +114,10 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
{ {
*height = ANativeWindow_getHeight(window->android->window); if (height)
*width = ANativeWindow_getWidth(window->android->window); *height = ANativeWindow_getHeight(window->android->window);
if (width)
*width = ANativeWindow_getWidth(window->android->window);
} }
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
@ -225,8 +231,10 @@ void _glfwPlatformPostEmptyEvent(void)
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
{ {
*xpos = x; if (xpos)
*ypos = y; *xpos = x;
if (ypos)
*ypos = y;
} }
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
@ -336,7 +344,7 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* handle) 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; return window->android;
} }