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
#if defined(GLFW_EXPOSE_NATIVE_ANDROID)
#include <android_native_app_glue.h>
GLFWAPI struct android_app * glfwGetAndroidApp(GLFWwindow* window);
#endif

View File

@ -63,7 +63,7 @@ elseif (_GLFW_ANDROID)
set(glfw_HEADERS ${common_HEADERS} android_platform.h android_joystick.h
posix_time.h posix_thread.h)
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()
if (APPLE)

View File

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