diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index c693afd8..3bef2375 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 16a8711a..b52b5473 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 5a699b6f..58c8b91f 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 639254bc..bdb3a58e 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 a9edafa5..1a651869 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 360703b4..bd8f4ffd 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 ///