[Android] Rewrote CMake scripts to compile SFML with our new toolchain

This commit is contained in:
Jonathan De Wachter 2013-09-22 17:16:48 +02:00
parent f9e80e1a3b
commit 60894d1c1a
28 changed files with 260 additions and 327 deletions

View File

@ -28,14 +28,18 @@ set(VERSION_PATCH 0)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# add an option for choosing the build type (shared or static) # add an option for choosing the build type (shared or static)
if(NOT IOS) if(NOT (IOS OR ANDROID))
sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries") sfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build SFML as shared libraries, FALSE to build it as static libraries")
else() else()
set(BUILD_SHARED_LIBS FALSE) if(IOS)
set(BUILD_SHARED_LIBS FALSE)
elseif(ANDROID)
set(BUILD_SHARED_LIBS TRUE)
endif()
endif() endif()
# add an option for building the examples # add an option for building the examples
if(NOT IOS) if(NOT (IOS OR ANDROID))
sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them") sfml_set_option(SFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the SFML examples, FALSE to ignore them")
else() else()
set(SFML_BUILD_EXAMPLES FALSE) set(SFML_BUILD_EXAMPLES FALSE)
@ -65,6 +69,27 @@ if(SFML_OS_MACOSX)
sfml_set_option(SFML_INSTALL_XCODE4_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it") sfml_set_option(SFML_INSTALL_XCODE4_TEMPLATES FALSE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it")
endif() endif()
# Android options
if(ANDROID)
# force usage of the STL port
set(ANDROID_USE_STLPORT TRUE)
# make sure there's an EGL implementation available
if (${ANDROID_ABI} MATCHES "armeabi" AND ${ANDROID_NATIVE_API_LEVEL} LESS 3)
message(FATAL_ERROR "API level must be equal or greater than 3 for ARM arches")
endif()
if ((${ANDROID_ABI} MATCHES "x86" OR ${ANDROID_ABI} MATCHES "mips") AND ${ANDROID_NATIVE_API_LEVEL} LESS 9)
message(FATAL_ERROR "API level must be equal or greater than 9 for x86 and MIPS arches")
endif()
# install everything in $NDK/sources/ because this path is appended by the NDK (convenient)
set(CMAKE_INSTALL_PREFIX ${ANDROID_NDK}/sources/sfml)
# we install libs in a subdirectory named after the ABI (lib/mips/*.so)
set(LIB_SUFFIX "/${ANDROID_ABI}")
endif()
# define SFML_STATIC if the build type is not set to 'shared' # define SFML_STATIC if the build type is not set to 'shared'
if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
add_definitions(-DSFML_STATIC) add_definitions(-DSFML_STATIC)
@ -222,7 +247,9 @@ endif()
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR})
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules) if(NOT SFML_OS_ANDROID)
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules)
endif()
# install 3rd-party libraries and tools # install 3rd-party libraries and tools
if(SFML_OS_WINDOWS) if(SFML_OS_WINDOWS)
@ -274,7 +301,8 @@ elseif(SFML_OS_IOS)
elseif(SFML_OS_ANDROID) elseif(SFML_OS_ANDROID)
install(DIRECTORY extlibs/android/extlibs DESTINATION .) install(DIRECTORY extlibs/android/extlibs/lib/${ANDROID_ABI} DESTINATION extlibs/lib)
install(FILES extlibs/android/extlibs/Android.mk DESTINATION extlibs)
install(FILES src/SFML/Android.mk DESTINATION .) install(FILES src/SFML/Android.mk DESTINATION .)
endif() endif()

View File

@ -14,7 +14,14 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
return() return()
endif() endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(SFML_OS_LINUX 1) set(SFML_OS_UNIX 1)
if(ANDROID)
# use the OpenGL ES implementation on Android
set(OPENGL_ES 1)
set(SFML_OS_ANDROID 1)
else()
set(SFML_OS_LINUX 1)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(SFML_OS_FREEBSD 1) set(SFML_OS_FREEBSD 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@ -91,8 +98,10 @@ else()
endif() endif()
# define the install directory for miscellaneous files # define the install directory for miscellaneous files
if(SFML_OS_WINDOWS OR SFML_OS_ANDROID) if(SFML_OS_WINDOWS)
set(INSTALL_MISC_DIR .) set(INSTALL_MISC_DIR .)
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
set(INSTALL_MISC_DIR share/SFML) set(INSTALL_MISC_DIR share/SFML)
elseif(SFML_OS_ANDROID)
set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml)
endif() endif()

View File

@ -10,8 +10,6 @@ macro(sfml_add_library target)
# parse the arguments # parse the arguments
cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN}) cmake_parse_arguments(THIS "" "" "SOURCES;DEPENDS;EXTERNAL_LIBS" ${ARGN})
if(NOT ANDROID)
# create the target # create the target
add_library(${target} ${THIS_SOURCES}) add_library(${target} ${THIS_SOURCES})
@ -42,8 +40,11 @@ if(NOT ANDROID)
endif() endif()
# set the version and soversion of the target (for compatible systems -- mostly Linuxes) # set the version and soversion of the target (for compatible systems -- mostly Linuxes)
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR}) # except for Android which strips soversion suffixes
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) if(NOT ANDROID)
set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR})
set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
endif()
# set the target's folder (for IDEs that support it, e.g. Visual Studio) # set the target's folder (for IDEs that support it, e.g. Visual Studio)
set_target_properties(${target} PROPERTIES FOLDER "SFML") set_target_properties(${target} PROPERTIES FOLDER "SFML")
@ -107,96 +108,54 @@ if(NOT ANDROID)
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin) FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
endmacro()
else() # add a new target which is a SFML example
# ex: sfml_add_example(ftp
# SOURCES ftp.cpp ...
# DEPENDS sfml-network sfml-system)
macro(sfml_add_example target)
# create an empty target added to the default build # parse the arguments
add_custom_target(${target} ALL) sfml_parse_arguments(THIS "SOURCES;DEPENDS" "GUI_APP" ${ARGN})
# get the module name (extract 'network' from 'sfml-network' for example) # set a source group for the source files
string(SUBSTRING ${target} 5 -1 MODULE_NAME) source_group("" FILES ${THIS_SOURCES})
# make the first letter a capital letter ('network' -> 'Network')s # create the target
string(SUBSTRING ${MODULE_NAME} 0 1 FIRST_LETTER) if(THIS_GUI_APP AND WINDOWS)
string(TOUPPER ${FIRST_LETTER} FIRST_LETTER) add_executable(${target} WIN32 ${THIS_SOURCES})
string(REGEX REPLACE "^.(.*)" "${FIRST_LETTER}\\1" PROTO_NAME_CAP "${MODULE_NAME}") target_link_libraries(${target} sfml-main)
set(MODULE_NAME ${PROTO_NAME_CAP}) else()
add_executable(${target} ${THIS_SOURCES})
# create an empty Application.mk ready to be filled
set(APPLICATION_MK ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/Application.mk)
file(WRITE ${APPLICATION_MK})
# define several path for later use
set(INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(EXTLIBS_DIR ${PROJECT_SOURCE_DIR}/extlibs/android/extlibs)
# add support for Windows under Cygwin (add C:/cygwin64 to path)
execute_process(COMMAND uname -o OUTPUT_VARIABLE UNAME_RESULT)
if (UNAME_RESULT MATCHES Cygwin)
execute_process(COMMAND cygpath --mixed / OUTPUT_VARIABLE CYGPATH)
string(STRIP ${CYGPATH} CYGPATH)
set(INCLUDE_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/include)
set(SRC_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/src)
set(EXTLIBS_DIR ${CYGPATH}${PROJECT_SOURCE_DIR}/extlibs/android/extlibs)
endif()
# write the Application.mk
file(APPEND ${APPLICATION_MK} "NDK_APP_OUT := ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj\n")
file(APPEND ${APPLICATION_MK} "APP_PLATFORM := android-${ANDROID_API_LEVEL}\n")
file(APPEND ${APPLICATION_MK} "APP_STL := stlport_static\n")
file(APPEND ${APPLICATION_MK} "APP_BUILD_SCRIPT := Android.mk\n")
file(APPEND ${APPLICATION_MK} "APP_MODULES := ${target}\n")
file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${INCLUDE_DIR}\n")
file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${SRC_DIR}\n")
file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -I${EXTLIBS_DIR}/include\n")
file(APPEND ${APPLICATION_MK} "APP_CPPFLAGS += -DSFML_OPENGL_ES\n")
if (ANDROID_ABI_ARM)
file(APPEND ${APPLICATION_MK} "APP_ABI += armeabi\n")
endif() endif()
if (ANDROID_ABI_ARMv7) # set the debug suffix
file(APPEND ${APPLICATION_MK} "APP_ABI += armeabi-v7a\n") set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
# set the target's folder (for IDEs that support it, e.g. Visual Studio)
set_target_properties(${target} PROPERTIES FOLDER "Examples")
# for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS)
if(NOT GCC_VERSION VERSION_LESS "4")
set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
endif()
endif() endif()
if (ANDROID_ABI_MIPS) # link the target to its SFML dependencies
file(APPEND ${APPLICATION_MK} "APP_ABI += mips\n") if(THIS_DEPENDS)
target_link_libraries(${target} ${THIS_DEPENDS})
endif() endif()
if (ANDROID_ABI_x86) # add the install rule
file(APPEND ${APPLICATION_MK} "APP_ABI += x86\n") install(TARGETS ${target}
endif() RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
# define the target build rules # install the example's source code
set(DIR ${PROJECT_SOURCE_DIR}/src/SFML/${MODULE_NAME}) install(FILES ${THIS_SOURCES}
set(NDK_MODULE_PATH ${PROJECT_SOURCE_DIR}/extlibs/android) DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
set(NDK_PROJECT_PATH ${PROJECT_SOURCE_DIR}/src/SFML/${MODULE_NAME}) COMPONENT examples)
set(NDK_BUILD ${ANDROID_NDK_PATH}/ndk-build)
set(NDK_APPLICATION_MK NDK_APPLICATION_MK=${APPLICATION_MK})
# create the environment for ndk-build
set(NDK_ENVIRONMENT NDK_MODULE_PATH=${NDK_MODULE_PATH} NDK_PROJECT_PATH=${NDK_PROJECT_PATH})
# invoke the ndk-build scripts from the ndk with the right parameters
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${NDK_BUILD} -C ${DIR} ${NDK_APPLICATION_MK} ${NDK_ENVIRONMENT})
# define the target install rules
if (ANDROID_ABI_ARM)
install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/armeabi DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib/ PATTERN "objs" EXCLUDE)
endif()
if (ANDROID_ABI_ARMv7)
install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/armeabi-v7a DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE)
endif()
if (ANDROID_ABI_MIPS)
install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/mips DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE)
endif()
if (ANDROID_ABI_x86)
install(DIRECTORY ${CMAKE_BINARY_DIR}/src/SFML/${MODULE_NAME}/obj/local/x86 DESTINATION ${ANDROID_NDK_PATH}/sources/sfml/lib PATTERN "objs" EXCLUDE)
endif()
endif()
endmacro() endmacro()

View File

@ -2,51 +2,56 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-system LOCAL_MODULE := sfml-system
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-system.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-system.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS := -llog -landroid
include $(PREBUILT_STATIC_LIBRARY) include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-window LOCAL_MODULE := sfml-window
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-window.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-window.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS := -lEGL LOCAL_EXPORT_LDLIBS := -lEGL
LOCAL_SHARED_LIBRARIES := sfml-system
include $(PREBUILT_STATIC_LIBRARY) include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-graphics LOCAL_MODULE := sfml-graphics
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-graphics.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-graphics.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM #LOCAL_EXPORT_LDLIBS := -lGLESv1_CM
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/extlibs/include LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/extlibs/include
LOCAL_STATIC_LIBRARIES := jpeg freetype LOCAL_SHARED_LIBRARIES := freetype jpeg
LOCAL_SHARED_LIBRARIES += sfml-system sfml-window
include $(PREBUILT_STATIC_LIBRARY) include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-audio LOCAL_MODULE := sfml-audio
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-audio.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-audio.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
#LOCAL_EXPORT_LDLIBS := -lOpenSLES
LOCAL_SHARED_LIBRARIES := openal sndfile
LOCAL_SHARED_LIBRARIES += sfml-system sfml-window
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/extlibs/include include $(PREBUILT_SHARED_LIBRARY)
LOCAL_WHOLE_STATIC_LIBRARIES := ogg vorbis vorbisenc flac sndfile openal
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-network LOCAL_MODULE := sfml-network
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-network.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-network.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := sfml-system
include $(PREBUILT_STATIC_LIBRARY) include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := sfml-main LOCAL_MODULE := sfml-main
LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-main.a LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libsfml-main.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SHARED_LIBRARIES := sfml-system sfml-window
include $(PREBUILT_STATIC_LIBRARY) include $(PREBUILT_STATIC_LIBRARY)

View File

@ -31,13 +31,8 @@
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#ifndef SFML_SYSTEM_ANDROID #include <al.h>
#include <al.h> #include <alc.h>
#include <alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
namespace sf namespace sf

View File

@ -1,20 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-audio
LOCAL_SRC_FILES := ALCheck.cpp
LOCAL_SRC_FILES += AudioDevice.cpp
LOCAL_SRC_FILES += Listener.cpp
LOCAL_SRC_FILES += Music.cpp
LOCAL_SRC_FILES += Sound.cpp
LOCAL_SRC_FILES += SoundBuffer.cpp
LOCAL_SRC_FILES += SoundBufferRecorder.cpp
LOCAL_SRC_FILES += SoundFile.cpp
LOCAL_SRC_FILES += SoundRecorder.cpp
LOCAL_SRC_FILES += SoundSource.cpp
LOCAL_SRC_FILES += SoundStream.cpp
include $(BUILD_STATIC_LIBRARY)
$(call import-module,extlibs)

View File

@ -29,7 +29,7 @@ set(SRC
${INCROOT}/SoundStream.hpp ${INCROOT}/SoundStream.hpp
) )
source_group("" FILES ${SRC}) source_group("" FILES ${SRC})
if(NOT ANDROID)
# let CMake know about our additional audio libraries paths (on Windows and OSX) # let CMake know about our additional audio libraries paths (on Windows and OSX)
if(SFML_OS_WINDOWS) if(SFML_OS_WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/AL") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/AL")
@ -40,14 +40,37 @@ elseif(SFML_OS_MACOSX)
endif() endif()
# find external libraries # find external libraries
find_package(OpenAL REQUIRED) if(NOT ANDROID)
find_package(Sndfile REQUIRED) find_package(OpenAL REQUIRED)
find_package(Sndfile REQUIRED)
set(AUDIO_EXT_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
else()
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/include/AL")
find_host_package(OpenAL REQUIRED)
find_host_package(Sndfile REQUIRED)
set(AUDIO_EXT_INCLUDE_PATHS ${OPENAL_INCLUDE_DIRS} ${SNDFILE_INCLUDE_DIR})
set(AUDIO_EXT_LIBS -landroid
-lOpenSLES
${OPENAL_LIBRARY}
${SNDFILE_LIBRARY}
${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libvorbisenc.so
${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libvorbis.so
${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libFLAC.so
${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}/libogg.so)
endif()
# add include paths of external libraries # add include paths of external libraries
include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR})
endif()
# define the sfml-audio target # define the sfml-audio target
if(NOT ANDROID)
sfml_add_library(sfml-audio sfml_add_library(sfml-audio
SOURCES ${SRC} SOURCES ${SRC}
DEPENDS sfml-system DEPENDS sfml-system
EXTERNAL_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY}) EXTERNAL_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})
else()
sfml_add_library(sfml-audio
SOURCES ${SRC}
DEPENDS sfml-system sfml-window
EXTERNAL_LIBS ${AUDIO_EXT_LIBS})
endif()

View File

@ -26,12 +26,12 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Audio/SoundFile.hpp> #include <SFML/Audio/SoundFile.hpp>
#ifdef SFML_SYSTEM_ANDROID
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Lock.hpp>
#endif
#include <SFML/System/InputStream.hpp> #include <SFML/System/InputStream.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#ifdef SFML_SYSTEM_ANDROID
#include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#endif
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
@ -118,7 +118,7 @@ bool SoundFile::openRead(const std::string& filename)
#else #else
priv::ActivityStates* states = priv::getActivityStates(NULL); priv::ActivityStates* states = priv::getActivity(NULL);
Lock lock(states->mutex); Lock lock(states->mutex);
// Open the file // Open the file

View File

@ -26,6 +26,9 @@ elseif(SFML_OS_MACOSX)
elseif(IOS) elseif(IOS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-ios/") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-ios/")
elseif(ANDROID)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/include")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/android/extlibs/lib/${ANDROID_ABI}")
endif() endif()
# add the SFML sources path # add the SFML sources path
@ -40,9 +43,11 @@ set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib")
# add the modules subdirectories # add the modules subdirectories
add_subdirectory(System) add_subdirectory(System)
add_subdirectory(Window) add_subdirectory(Window)
if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS)
add_subdirectory(Main)
endif()
add_subdirectory(Network) add_subdirectory(Network)
add_subdirectory(Graphics) add_subdirectory(Graphics)
if(NOT SFML_OS_IOS) if(NOT SFML_OS_IOS OR NOT (SFML_OS_ANDROID AND ${ANDROID_ABI} MATCHES "mips"))
add_subdirectory(Audio) add_subdirectory(Audio)
endif() endif()
add_subdirectory(Main)

View File

@ -1,38 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-graphics
LOCAL_SRC_FILES := Color.cpp
LOCAL_SRC_FILES += GLCheck.cpp
LOCAL_SRC_FILES += GLExtensions.cpp
LOCAL_SRC_FILES += Image.cpp
LOCAL_SRC_FILES += ImageLoader.cpp
LOCAL_SRC_FILES += RenderStates.cpp
LOCAL_SRC_FILES += RenderTexture.cpp
LOCAL_SRC_FILES += RenderTarget.cpp
LOCAL_SRC_FILES += RenderWindow.cpp
LOCAL_SRC_FILES += Shader.cpp
LOCAL_SRC_FILES += Texture.cpp
LOCAL_SRC_FILES += TextureSaver.cpp
LOCAL_SRC_FILES += Transform.cpp
LOCAL_SRC_FILES += Transformable.cpp
LOCAL_SRC_FILES += View.cpp
LOCAL_SRC_FILES += Vertex.cpp
LOCAL_SRC_FILES += Shape.cpp
LOCAL_SRC_FILES += CircleShape.cpp
LOCAL_SRC_FILES += RectangleShape.cpp
LOCAL_SRC_FILES += ConvexShape.cpp
LOCAL_SRC_FILES += Sprite.cpp
LOCAL_SRC_FILES += Font.cpp
LOCAL_SRC_FILES += Text.cpp
LOCAL_SRC_FILES += VertexArray.cpp
LOCAL_SRC_FILES += RenderTextureImpl.cpp
LOCAL_SRC_FILES += RenderTextureImplFBO.cpp
LOCAL_SRC_FILES += RenderTextureImplDefault.cpp
LOCAL_CPPFLAGS := -DGL_GLEXT_PROTOTYPES -DSFML_OPENGL_ES
include $(BUILD_STATIC_LIBRARY)
$(call import-module,extlibs)

View File

@ -128,6 +128,12 @@ if(IOS)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
set(GRAPHICS_EXT_INCLUDE_PATHS ${FREETYPE_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR}) set(GRAPHICS_EXT_INCLUDE_PATHS ${FREETYPE_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR})
set(GRAPHICS_EXT_LIBS "-framework OpenGLES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}") set(GRAPHICS_EXT_LIBS "-framework OpenGLES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}")
elseif(ANDROID)
find_host_package(JPEG REQUIRED)
find_host_package(Freetype REQUIRED)
set(GRAPHICS_EXT_INCLUDE_PATHS ${FREETYPE_INCLUDE_DIRS} ${JPEG_INCLUDE_DIR})
set(GRAPHICS_EXT_LIBS -lz ${FREETYPE_LIBRARY} ${JPEG_LIBRARY})
add_definitions(-DGL_GLEXT_PROTOTYPES)
endif() endif()
# add include paths of external libraries # add include paths of external libraries

View File

@ -27,12 +27,12 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/GLCheck.hpp> #include <SFML/Graphics/GLCheck.hpp>
#ifdef SFML_SYSTEM_ANDROID
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Lock.hpp>
#endif
#include <SFML/System/InputStream.hpp> #include <SFML/System/InputStream.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#ifdef SFML_SYSTEM_ANDROID
#include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#endif
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include FT_GLYPH_H #include FT_GLYPH_H
@ -149,7 +149,7 @@ bool Font::loadFromFile(const std::string& filename)
#else #else
priv::ActivityStates* states = priv::getActivityStates(NULL); priv::ActivityStates* states = priv::getActivity(NULL);
Lock lock(states->mutex); Lock lock(states->mutex);
// Open the file // Open the file

View File

@ -27,11 +27,11 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Graphics/Image.hpp> #include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/ImageLoader.hpp> #include <SFML/Graphics/ImageLoader.hpp>
#include <SFML/System/Err.hpp>
#ifdef SFML_SYSTEM_ANDROID #ifdef SFML_SYSTEM_ANDROID
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#endif #endif
#include <SFML/System/Err.hpp>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
@ -112,7 +112,7 @@ bool Image::loadFromFile(const std::string& filename)
#else #else
priv::ActivityStates* states = priv::getActivityStates(NULL); priv::ActivityStates* states = priv::getActivity(NULL);
Lock lock(states->mutex); Lock lock(states->mutex);
// Open the file // Open the file

View File

@ -1,7 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-main
LOCAL_SRC_FILES := SFML_Main.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@ -14,22 +14,17 @@ else()
endif() endif()
source_group("" FILES ${SRC}) source_group("" FILES ${SRC})
if(NOT ANDROID) # define the sfml-main target
# define the sfml-main target add_library(sfml-main STATIC ${SRC})
add_library(sfml-main STATIC ${SRC})
# set the debug suffix # set the debug suffix
set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d) set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d)
# insert the major version number in the output filename # insert the major version number in the output filename
set_target_properties(sfml-main PROPERTIES OUTPUT_NAME "sfml-main") set_target_properties(sfml-main PROPERTIES OUTPUT_NAME "sfml-main")
# set the target's folder (for IDEs that support it, e.g. Visual Studio) # set the target's folder (for IDEs that support it, e.g. Visual Studio)
set_target_properties(sfml-main PROPERTIES FOLDER "SFML") set_target_properties(sfml-main PROPERTIES FOLDER "SFML")
# setup the install rule # setup the install rule
install(TARGETS sfml-main ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel) install(TARGETS sfml-main ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel)
else()
# define the sfml-main target
sfml_add_library(sfml-main SOURCES ${SRC} DEPENDS sfml-window sfml-system)
endif()

View File

@ -27,15 +27,15 @@
#ifdef SFML_SYSTEM_ANDROID #ifdef SFML_SYSTEM_ANDROID
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/Window/EGLCheck.hpp>
#include <SFML/Window/Keyboard.hpp> #include <SFML/Window/Keyboard.hpp>
#include <SFML/System/Sleep.hpp> #include <SFML/System/Sleep.hpp>
#include <SFML/System/Thread.hpp> #include <SFML/System/Thread.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
extern int main(int argc, char *argv[]); extern int main(int argc, char *argv[]);
JavaVM* javaVM;
namespace sf namespace sf
{ {
@ -292,16 +292,6 @@ void processSensorEvents(ActivityStates* states)
} }
} }
ActivityStates* getActivityStates(ActivityStates* initializedStates)
{
static ActivityStates* states = NULL;
if (!states)
states = initializedStates;
return states;
}
ActivityStates* retrieveStates(ANativeActivity* activity) ActivityStates* retrieveStates(ANativeActivity* activity)
{ {
// Hide the ugly cast we find in each callback function // Hide the ugly cast we find in each callback function
@ -578,9 +568,6 @@ static void onLowMemory(ANativeActivity* activity)
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize) void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
{ {
// Feed OpenAL-Soft's javaVM to make so he can function
javaVM = activity->vm;
// Create an activity states (will keep us in the know, about events we care) // Create an activity states (will keep us in the know, about events we care)
sf::priv::ActivityStates* states = NULL; sf::priv::ActivityStates* states = NULL;
states = new sf::priv::ActivityStates; states = new sf::priv::ActivityStates;
@ -610,7 +597,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_
states->terminated = false; states->terminated = false;
// Share it across the SFML modules // Share it across the SFML modules
sf::priv::getActivityStates(states); sf::priv::getActivity(states);
// These functions will update the activity states and therefore, will allow // These functions will update the activity states and therefore, will allow
// SFML to be kept in the know // SFML to be kept in the know

View File

@ -1,17 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-network
LOCAL_SRC_FILES := Ftp.cpp
LOCAL_SRC_FILES += Http.cpp
LOCAL_SRC_FILES += IpAddress.cpp
LOCAL_SRC_FILES += Packet.cpp
LOCAL_SRC_FILES += Socket.cpp
LOCAL_SRC_FILES += SocketSelector.cpp
LOCAL_SRC_FILES += TcpListener.cpp
LOCAL_SRC_FILES += TcpSocket.cpp
LOCAL_SRC_FILES += UdpSocket.cpp
LOCAL_SRC_FILES += Unix/SocketImpl.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@ -1,21 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-system
LOCAL_SRC_FILES := Clock.cpp
LOCAL_SRC_FILES += Err.cpp
LOCAL_SRC_FILES += Lock.cpp
LOCAL_SRC_FILES += Mutex.cpp
LOCAL_SRC_FILES += Sleep.cpp
LOCAL_SRC_FILES += String.cpp
LOCAL_SRC_FILES += Thread.cpp
LOCAL_SRC_FILES += ThreadLocal.cpp
LOCAL_SRC_FILES += Time.cpp
LOCAL_SRC_FILES += Unix/ClockImpl.cpp
LOCAL_SRC_FILES += Unix/MutexImpl.cpp
LOCAL_SRC_FILES += Unix/SleepImpl.cpp
LOCAL_SRC_FILES += Unix/ThreadImpl.cpp
LOCAL_SRC_FILES += Unix/ThreadLocalImpl.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@ -81,6 +81,11 @@ if(SFML_OS_WINDOWS)
set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} winmm) set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} winmm)
endif() endif()
# pthread is implicitly linked by the NDK
if(ANDROID)
set(SYSTEM_EXT_LIBS "")
endif()
# define the sfml-system target # define the sfml-system target
sfml_add_library(sfml-system sfml_add_library(sfml-system
SOURCES ${SRC} ${PLATFORM_SRC} SOURCES ${SRC} ${PLATFORM_SRC}

View File

@ -1,23 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := sfml-window
LOCAL_SRC_FILES := Context.cpp
LOCAL_SRC_FILES += GlContext.cpp
LOCAL_SRC_FILES += GlResource.cpp
LOCAL_SRC_FILES += Joystick.cpp
LOCAL_SRC_FILES += JoystickManager.cpp
LOCAL_SRC_FILES += Keyboard.cpp
LOCAL_SRC_FILES += Mouse.cpp
LOCAL_SRC_FILES += VideoMode.cpp
LOCAL_SRC_FILES += Window.cpp
LOCAL_SRC_FILES += WindowImpl.cpp
LOCAL_SRC_FILES += EGLCheck.cpp
LOCAL_SRC_FILES += Android/WindowImplAndroid.cpp
LOCAL_SRC_FILES += Android/EglContext.cpp
LOCAL_SRC_FILES += Android/VideoModeImpl.cpp
LOCAL_SRC_FILES += Android/InputImpl.cpp
LOCAL_SRC_FILES += Android/JoystickImpl.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@ -0,0 +1,41 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#include <SFML/Window/Android/Activity.hpp>
namespace sf
{
namespace priv
{
ActivityStates* getActivity(ActivityStates* initializedStates)
{
static ActivityStates* states = NULL;
if (!states)
states = initializedStates;
return states;
}
}
}

View File

@ -28,14 +28,13 @@
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window/Event.hpp>
#include <SFML/System/Mutex.hpp>
#include <android/native_activity.h> #include <android/native_activity.h>
#include <android/configuration.h> #include <android/configuration.h>
#include <android/sensor.h> #include <android/sensor.h>
#include <SFML/Window/EGLCheck.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/System/Mutex.hpp>
#include <vector> #include <vector>
#include <EGL/egl.h>
namespace sf namespace sf
{ {
@ -71,7 +70,7 @@ struct ActivityStates
bool updated; bool updated;
}; };
ActivityStates* getActivityStates(ActivityStates* initializedStates=NULL); SFML_WINDOW_API ActivityStates* getActivity(ActivityStates* initializedStates=NULL);
} // namespace priv } // namespace priv
} // namespace sf } // namespace sf

View File

@ -27,12 +27,12 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window/Android/EglContext.hpp> #include <SFML/Window/Android/EglContext.hpp>
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/OpenGL.hpp> #include <SFML/OpenGL.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <SFML/System/Sleep.hpp> #include <SFML/System/Sleep.hpp>
#include <SFML/System/Mutex.hpp> #include <SFML/System/Mutex.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#include <android/native_window.h> #include <android/native_window.h>
@ -47,7 +47,7 @@ m_context (EGL_NO_CONTEXT),
m_surface (EGL_NO_SURFACE) m_surface (EGL_NO_SURFACE)
{ {
// Get the activity states and protect it from concurent access // Get the activity states and protect it from concurent access
ActivityStates* states = getActivityStates(NULL); ActivityStates* states = getActivity(NULL);
sf::Lock lock(states->mutex); sf::Lock lock(states->mutex);
// Get the intialized EGL display // Get the intialized EGL display
@ -84,7 +84,7 @@ m_context (EGL_NO_CONTEXT),
m_surface (EGL_NO_SURFACE) m_surface (EGL_NO_SURFACE)
{ {
// Get the activity states and protect it from concurent access // Get the activity states and protect it from concurent access
ActivityStates* states = getActivityStates(NULL); ActivityStates* states = getActivity(NULL);
sf::Lock lock(states->mutex); sf::Lock lock(states->mutex);
// Get the intialized EGL display // Get the intialized EGL display

View File

@ -26,8 +26,8 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window/Android/InputImpl.hpp> #include <SFML/Window/Android/InputImpl.hpp>
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#include <jni.h> #include <jni.h>
@ -47,7 +47,7 @@ void InputImpl::setVirtualKeyboardVisible(bool visible)
{ {
// TODO: Check if the window is active // TODO: Check if the window is active
ActivityStates* states = getActivityStates(NULL); ActivityStates* states = getActivity(NULL);
sf::Lock lock(states->mutex); sf::Lock lock(states->mutex);
jint lResult; jint lResult;

View File

@ -26,11 +26,10 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window/VideoModeImpl.hpp> #include <SFML/Window/VideoModeImpl.hpp>
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Vector2.hpp> #include <SFML/System/Vector2.hpp>
#include <SFML/System/Sleep.hpp> #include <SFML/System/Sleep.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
namespace sf namespace sf
{ {
@ -53,7 +52,7 @@ std::vector<VideoMode> VideoModeImpl::getFullscreenModes()
VideoMode VideoModeImpl::getDesktopMode() VideoMode VideoModeImpl::getDesktopMode()
{ {
// Get the activity states // Get the activity states
priv::ActivityStates* states = priv::getActivityStates(NULL); priv::ActivityStates* states = priv::getActivity(NULL);
Lock lock(states->mutex); Lock lock(states->mutex);
// Wait for a window if there's none // Wait for a window if there's none

View File

@ -29,12 +29,10 @@
#include <SFML/Window/WindowStyle.hpp> // important to be included first (conflict with None) #include <SFML/Window/WindowStyle.hpp> // important to be included first (conflict with None)
#include <SFML/Window/Android/WindowImplAndroid.hpp> #include <SFML/Window/Android/WindowImplAndroid.hpp>
#include <SFML/Window/Event.hpp> #include <SFML/Window/Event.hpp>
#include <SFML/Window/Android/Activity.hpp>
#include <SFML/System/Lock.hpp> #include <SFML/System/Lock.hpp>
#include <SFML/Main/activity.hpp>
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "sfml_app", __VA_ARGS__))
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Private data // Private data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -72,7 +70,7 @@ WindowHandle WindowImplAndroid::getSystemHandle() const
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void WindowImplAndroid::processEvents() void WindowImplAndroid::processEvents()
{ {
ActivityStates* states = getActivityStates(NULL); ActivityStates* states = getActivity(NULL);
sf::Lock lock(states->mutex); sf::Lock lock(states->mutex);
int ident, events; int ident, events;

View File

@ -141,14 +141,16 @@ elseif(ANDROID)
set(PLATFORM_SRC set(PLATFORM_SRC
${SRCROOT}/Android/WindowImplAndroid.hpp ${SRCROOT}/Android/WindowImplAndroid.hpp
${SRCROOT}/Android/WindowImplAndroid.cpp ${SRCROOT}/Android/WindowImplAndroid.cpp
${SRCROOT}/Android/EGLContext.hpp ${SRCROOT}/Android/EglContext.hpp
${SRCROOT}/Android/EGLContext.cpp ${SRCROOT}/Android/EglContext.cpp
${SRCROOT}/Android/VideoModeImpl.hpp #${SRCROOT}/Android/VideoModeImpl.hpp
${SRCROOT}/Android/VideoModeImpl.cpp ${SRCROOT}/Android/VideoModeImpl.cpp
${SRCROOT}/Android/InputImpl.hpp ${SRCROOT}/Android/InputImpl.hpp
${SRCROOT}/Android/InputImpl.cpp ${SRCROOT}/Android/InputImpl.cpp
${SRCROOT}/Android/JoystickImpl.hpp ${SRCROOT}/Android/JoystickImpl.hpp
${SRCROOT}/Android/JoystickImpl.cpp) ${SRCROOT}/Android/JoystickImpl.cpp
${SRCROOT}/Android/Activity.hpp
${SRCROOT}/Android/Activity.cpp)
source_group("android" FILES ${PLATFORM_SRC}) source_group("android" FILES ${PLATFORM_SRC})
endif() endif()
@ -156,7 +158,7 @@ endif()
if(NOT OPENGL_ES) if(NOT OPENGL_ES)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
if(SFML_OS_LINUX) if(SFML_OS_LINUX AND NOT SFML_OS_ANDROID)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
if(NOT X11_Xrandr_FOUND) if(NOT X11_Xrandr_FOUND)
message(FATAL_ERROR "Xrandr library not found") message(FATAL_ERROR "Xrandr library not found")
@ -184,6 +186,8 @@ elseif(SFML_OS_MACOSX)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${OPENGL_gl_LIBRARY} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon") set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${OPENGL_gl_LIBRARY} "-framework Foundation -framework AppKit -framework IOKit -framework Carbon")
elseif(SFML_OS_IOS) elseif(SFML_OS_IOS)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework OpenGLES -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework CoreMotion") set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-framework OpenGLES -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework CoreMotion")
elseif(SFML_OS_ANDROID)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} "-landroid -llog -lEGL -lGLESv1_CM")
endif() endif()
# define the sfml-window target # define the sfml-window target

View File

@ -35,6 +35,7 @@
#include <SFML/Window/Android/EglContext.hpp> #include <SFML/Window/Android/EglContext.hpp>
#endif #endif
namespace namespace
{ {
const sf::Window* fullscreenWindow = NULL; const sf::Window* fullscreenWindow = NULL;