From 4e8e1629d1c47a162faf8d3c1e151c8b242a70cd Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Mon, 26 Aug 2013 09:17:53 +0200 Subject: [PATCH] Adapted the examples for iOS (WIP) --- cmake/Macros.cmake | 5 ++++- examples/CMakeLists.txt | 12 ++++++++---- examples/opengl/CMakeLists.txt | 11 ++++++++--- examples/opengl/OpenGL.cpp | 12 ++++++++++++ examples/window/CMakeLists.txt | 11 ++++++++--- examples/window/Window.cpp | 9 +++++++++ 6 files changed, 49 insertions(+), 11 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index c693afd8f..3bef23756 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -268,6 +268,8 @@ macro(sfml_add_example target) if(THIS_GUI_APP AND SFML_OS_WINDOWS) add_executable(${target} WIN32 ${THIS_SOURCES}) target_link_libraries(${target} sfml-main) + elseif(IOS) + add_executable(${target} MACOSX_BUNDLE ${THIS_SOURCES}) else() add_executable(${target} ${THIS_SOURCES}) endif() @@ -299,7 +301,8 @@ macro(sfml_add_example target) # add the install rule install(TARGETS ${target} - RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples) + RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples + BUNDLE DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples) # install the example's source code install(FILES ${THIS_SOURCES} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 16a8711a4..b52b54737 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,12 +2,16 @@ # add the examples subdirectories add_subdirectory(ftp) add_subdirectory(opengl) -add_subdirectory(pong) +if(NOT IOS) + add_subdirectory(pong) +endif() add_subdirectory(shader) add_subdirectory(sockets) -add_subdirectory(sound) -add_subdirectory(sound_capture) -add_subdirectory(voip) +if(NOT IOS) + add_subdirectory(sound) + add_subdirectory(sound_capture) + add_subdirectory(voip) +endif() add_subdirectory(window) if(SFML_OS_WINDOWS) add_subdirectory(win32) diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt index 5a699b6f9..58c8b91f9 100644 --- a/examples/opengl/CMakeLists.txt +++ b/examples/opengl/CMakeLists.txt @@ -5,10 +5,15 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/opengl) set(SRC ${SRCROOT}/OpenGL.cpp) # find OpenGL and GLU -find_package(OpenGL REQUIRED) -include_directories(${OPENGL_INCLUDE_DIR}) +if(NOT IOS) + find_package(OpenGL REQUIRED) + include_directories(${OPENGL_INCLUDE_DIR}) + set(ADDITIONAL_LIBRARIES ${OPENGL_LIBRARIES}) +else() + set(ADDITIONAL_LIBRARIES -framework OpenGLES) +endif() # define the opengl target sfml_add_example(opengl GUI_APP SOURCES ${SRC} - DEPENDS sfml-graphics sfml-window sfml-system ${OPENGL_LIBRARIES}) + DEPENDS sfml-graphics sfml-window sfml-system ${ADDITIONAL_LIBRARIES}) diff --git a/examples/opengl/OpenGL.cpp b/examples/opengl/OpenGL.cpp index 639254bc0..bdb3a58eb 100644 --- a/examples/opengl/OpenGL.cpp +++ b/examples/opengl/OpenGL.cpp @@ -6,6 +6,18 @@ #include +// Some platform-specific stuff +#ifdef SFML_OPENGL_ES + + #define glClearDepth glClearDepthf + #define glFrustum glFrustumf + #define gluBuild2DMipmaps(target, internalFormat, width, height, format, type, pixels) \ + glTexImage2D(target, 0, internalFormat, width, height, 0, format, type, pixels); \ + glGenerateMipmapOES(GL_TEXTURE_2D); + +#endif + + //////////////////////////////////////////////////////////// /// Entry point of application /// diff --git a/examples/window/CMakeLists.txt b/examples/window/CMakeLists.txt index a9edafa56..1a651869b 100644 --- a/examples/window/CMakeLists.txt +++ b/examples/window/CMakeLists.txt @@ -5,10 +5,15 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/window) set(SRC ${SRCROOT}/Window.cpp) # find OpenGL and GLU -find_package(OpenGL REQUIRED) -include_directories(${OPENGL_INCLUDE_DIR}) +if(NOT IOS) + find_package(OpenGL REQUIRED) + include_directories(${OPENGL_INCLUDE_DIR}) + set(ADDITIONAL_LIBRARIES ${OPENGL_LIBRARIES}) +else() + set(ADDITIONAL_LIBRARIES -framework OpenGLES) +endif() # define the window target sfml_add_example(window GUI_APP SOURCES ${SRC} - DEPENDS sfml-window sfml-system ${OPENGL_LIBRARIES}) + DEPENDS sfml-window sfml-system ${ADDITIONAL_LIBRARIES}) diff --git a/examples/window/Window.cpp b/examples/window/Window.cpp index 360703b42..bd8f4ffde 100644 --- a/examples/window/Window.cpp +++ b/examples/window/Window.cpp @@ -5,6 +5,15 @@ #include +// Some platform-specific stuff +#ifdef SFML_OPENGL_ES + + #define glClearDepth glClearDepthf + #define glFrustum glFrustumf + +#endif + + //////////////////////////////////////////////////////////// /// Entry point of application ///