From Ulrich Hertlein and Stephan Huber, improves to iOS build

This commit is contained in:
Robert Osfield 2010-11-30 09:26:18 +00:00
parent 60457486b0
commit 5723050580
5 changed files with 65 additions and 54 deletions

View File

@ -147,32 +147,30 @@ still images, and a QTKit plugin will need to be developed to handle
animations.
-- Release notes on IOS build, by Thomas Hoghart
-- Release notes on iOS build, by Thomas Hoghart
* Manually set the relevant OSG_BUILD_PLATFORM_IPHONE... option in root
CMakeLists file. Can only have one or the other at the moment.
* Run CMake
* Disable all OpenGL types accodrding to OSG_GLES1_AVALIABLE or
OSG_GLES2_AVALIABLE. Also disable OSG_GLU_AVAILABLE
* Disable OSG_GL_DISPLAYLISTS_AVALIABLE
* Run CMake with either OSG_BUILD_PLATFORM_IPHONE or OSG_BUILD_PLATFORM_IPHONE_SIMULATOR set:
$ mkdir build-iOS ; cd build-iOS
$ ccmake -DOSG_BUILD_PLATFORM_IPHONE_SIMULATOR=YES -G Xcode ..
* Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device
* Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS
This will give us the static build we need for iPhone.
* Disable OSG_GL1_AVAILABLE, OSG_GL2_AVAILABLE, OSG_GL3_AVAILABLE, OSG_GLU_AVAILABLE
* Enable OSG_GLES1_AVAILABLE *OR* OSG_GLES2_AVAILABLE
* Ensure OSG_WINDOWING_SYSTEM is set to IOS
* Change FREETYPE include and library paths to an IPhone version
* Change FREETYPE include and library paths to an iPhone version
(OpenFrameworks has one bundled with its distribution)
* Under DYNAMIC ensure you untick DYNAMIC_OPENSCENEGRAPH and
DYNAMIC_OPENTHREADS. This will give us the static build we need
for IPhone
* Under CMake ensure the CMake_OSX_SYSROOT points to your
IOS SDK. Also check that the architecture is armv6/7 for
device or i386 for Simulator.
* Generate the XCode project
* Find osgDB FileUtis.cpp, open the 'Get Info' panel, change File Type
* Ensure that CMake_OSX_SYSROOT points to your iOS SDK.
* Generate the Xcode project
* Open the Xcode project
$ open OpenSceneGraph.xcodeproj
* Under Sources -> osgDB, select FileUtils.cpp and open the 'Get Info' panel, change File Type
to source.cpp.objcpp
Known issues:
* When Linking final app against ive plugin, you need to add -lz to
the 'Other linker flags' list.
known Issues:
* Apps and exes don't get created
* You can only select Simulator, or Device projects. In the XCode
project you will see both types but the sdk they link will
be the same.

View File

@ -243,8 +243,8 @@ ELSE(DYNAMIC_OPENSCENEGRAPH)
ADD_SUBDIRECTORY(osgstaticviewer)
# IPHONE_PORT@tom
IF(OSG_BUILD_PLATFORM_IPHONE || OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
ADD_SUBDIRECTORY(osgViewerIPhone)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
ADD_SUBDIRECTORY(osgviewerIPhone)
ENDIF()
# IPHONE_PORT@tom

View File

@ -6,8 +6,12 @@ SET(TARGET_SRC
osgIPhoneViewer-Info.plist
)
#INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR} )
SET(TARGET_LIBRARIES_VARS Foundation.framework QuartzCore.framework UIKit.framework)
#### end var setup ###
#backup setting
SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES})
SET(OSG_BUILD_APPLICATION_BUNDLES TRUE)
SETUP_EXAMPLE(osgViewerIPhone)
#restore setting
SET(OSG_BUILD_APPLICATION_BUNDLES {$TMP_OSG_BUILD_APPLICATION_BUNDLES})
SET(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -framework OpenGLES -framework UIKit")

View File

@ -39,26 +39,29 @@ class UIView;
#include <osgViewer/GraphicsWindow>
// we may not include any cocoa-header here, because this will pollute the name-sapce and tend to compile-errors
// Do not include any cocoa-header here, because this will pollute the name-space and causes compile errors
namespace osgViewer
{
/**
* Implementation of a GraphicsWindow for the iOS platform.
*/
class GraphicsWindowIOS : public osgViewer::GraphicsWindow
{
public:
class Implementation;
GraphicsWindowIOS(osg::GraphicsContext::Traits* traits)
: GraphicsWindow(),
GraphicsWindowIOS(osg::GraphicsContext::Traits* traits) : GraphicsWindow(),
_valid(false),
_initialized(false),
_realized(false),
_window(NULL),
_view(NULL),
_viewController(NULL),
_context(NULL),
_ownsWindow(true),
_adaptToDeviceOrientation(true),
_viewContentScaleFactor(-1.0f),
_window(NULL),
_context(NULL)
_viewContentScaleFactor(-1.0f)
{
_traits = traits;
@ -120,8 +123,6 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
/** Raise the window to the top.*/
virtual void raiseWindow();
bool requestClose() {return false; }
virtual void resizedImplementation(int x, int y, int width, int height);
virtual bool setWindowRectangleImplementation(int x, int y, int width, int height);

View File

@ -32,6 +32,14 @@ ELSE ()
ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF()
IF (APPLE)
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)
# compile FileUtils.cpp as objective-c++
SET_SOURCE_FILES_PROPERTIES(FileUtils.cpp
PROPERTIES COMPILE_FLAGS "-x objective-c++"
)
ENDIF()
ENDIF()
SET(LIB_NAME osgDB)