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. 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 * Run CMake with either OSG_BUILD_PLATFORM_IPHONE or OSG_BUILD_PLATFORM_IPHONE_SIMULATOR set:
CMakeLists file. Can only have one or the other at the moment. $ mkdir build-iOS ; cd build-iOS
* Run CMake $ ccmake -DOSG_BUILD_PLATFORM_IPHONE_SIMULATOR=YES -G Xcode ..
* Disable all OpenGL types accodrding to OSG_GLES1_AVALIABLE or * Check that CMAKE_OSX_ARCHITECTURE is i386 for the simulator or armv6;armv7 for the device
OSG_GLES2_AVALIABLE. Also disable OSG_GLU_AVAILABLE * Disable DYNAMIC_OPENSCENEGRAPH, DYNAMIC_OPENTHREADS
* Disable OSG_GL_DISPLAYLISTS_AVALIABLE 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 * 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) (OpenFrameworks has one bundled with its distribution)
* Under DYNAMIC ensure you untick DYNAMIC_OPENSCENEGRAPH and * Ensure that CMake_OSX_SYSROOT points to your iOS SDK.
DYNAMIC_OPENTHREADS. This will give us the static build we need * Generate the Xcode project
for IPhone * Open the Xcode project
* Under CMake ensure the CMake_OSX_SYSROOT points to your $ open OpenSceneGraph.xcodeproj
IOS SDK. Also check that the architecture is armv6/7 for * Under Sources -> osgDB, select FileUtils.cpp and open the 'Get Info' panel, change File Type
device or i386 for Simulator.
* Generate the XCode project
* Find osgDB FileUtis.cpp, open the 'Get Info' panel, change File Type
to source.cpp.objcpp to source.cpp.objcpp
Known issues:
* When Linking final app against ive plugin, you need to add -lz to * When Linking final app against ive plugin, you need to add -lz to
the 'Other linker flags' list. the 'Other linker flags' list.
known Issues:
* Apps and exes don't get created * Apps and exes don't get created
* You can only select Simulator, or Device projects. In the XCode * You can only select Simulator, or Device projects. In the XCode
project you will see both types but the sdk they link will project you will see both types but the sdk they link will
be the same. be the same.

View File

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

View File

@ -6,8 +6,12 @@ SET(TARGET_SRC
osgIPhoneViewer-Info.plist osgIPhoneViewer-Info.plist
) )
#INCLUDE_DIRECTORIES( ${GLUT_INCLUDE_DIR} ) #backup setting
SET(TARGET_LIBRARIES_VARS Foundation.framework QuartzCore.framework UIKit.framework) SET(TMP_OSG_BUILD_APPLICATION_BUNDLES {$OSG_BUILD_APPLICATION_BUNDLES})
SET(OSG_BUILD_APPLICATION_BUNDLES TRUE)
#### end var setup ###
SETUP_EXAMPLE(osgViewerIPhone) 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> #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 namespace osgViewer
{ {
/**
* Implementation of a GraphicsWindow for the iOS platform.
*/
class GraphicsWindowIOS : public osgViewer::GraphicsWindow class GraphicsWindowIOS : public osgViewer::GraphicsWindow
{ {
public: public:
class Implementation; class Implementation;
GraphicsWindowIOS(osg::GraphicsContext::Traits* traits) GraphicsWindowIOS(osg::GraphicsContext::Traits* traits) : GraphicsWindow(),
: GraphicsWindow(),
_valid(false), _valid(false),
_initialized(false), _initialized(false),
_realized(false), _realized(false),
_window(NULL),
_view(NULL),
_viewController(NULL),
_context(NULL),
_ownsWindow(true), _ownsWindow(true),
_adaptToDeviceOrientation(true), _adaptToDeviceOrientation(true),
_viewContentScaleFactor(-1.0f), _viewContentScaleFactor(-1.0f)
_window(NULL),
_context(NULL)
{ {
_traits = traits; _traits = traits;
@ -120,8 +123,6 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
/** Raise the window to the top.*/ /** Raise the window to the top.*/
virtual void raiseWindow(); virtual void raiseWindow();
bool requestClose() {return false; }
virtual void resizedImplementation(int x, int y, int width, int height); virtual void resizedImplementation(int x, int y, int width, int height);
virtual bool setWindowRectangleImplementation(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) ADD_DEFINITIONS(-DOSG_LIBRARY_STATIC)
ENDIF() 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) SET(LIB_NAME osgDB)