From Ulrich Hertlein and Stephan Huber, improves to iOS build
This commit is contained in:
parent
60457486b0
commit
5723050580
36
README.txt
36
README.txt
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
||||
|
@ -39,31 +39,34 @@ 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;
|
||||
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;
|
||||
|
||||
init();
|
||||
|
||||
|
||||
if (valid())
|
||||
{
|
||||
setState( new osg::State );
|
||||
@ -116,11 +119,9 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
|
||||
/** Get focus on if the pointer is in this window.*/
|
||||
virtual void grabFocusIfPointerInWindow();
|
||||
|
||||
/** Raise the window to the top.*/
|
||||
virtual void raiseWindow();
|
||||
|
||||
bool requestClose() {return false; }
|
||||
/** Raise the window to the top.*/
|
||||
virtual void raiseWindow();
|
||||
|
||||
virtual void resizedImplementation(int x, int y, int width, int height);
|
||||
|
||||
@ -137,19 +138,19 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
WindowData(UIWindow* window = NULL, bool adaptToDeviceOrientation = true, float scaleFactor = -1.0f)
|
||||
: _window(window),
|
||||
_adaptToDeviceOrientation(adaptToDeviceOrientation),
|
||||
_viewContentScaleFactor(scaleFactor)
|
||||
_viewContentScaleFactor(scaleFactor)
|
||||
{
|
||||
}
|
||||
|
||||
void setAdaptToDeviceOrientation(bool flag) { _adaptToDeviceOrientation = flag; }
|
||||
|
||||
void setViewContentScaleFactor(float scaleFactor) { _viewContentScaleFactor = scaleFactor; }
|
||||
|
||||
void setViewContentScaleFactor(float scaleFactor) { _viewContentScaleFactor = scaleFactor; }
|
||||
|
||||
private:
|
||||
|
||||
UIWindow* _window;
|
||||
bool _adaptToDeviceOrientation;
|
||||
float _viewContentScaleFactor;
|
||||
float _viewContentScaleFactor;
|
||||
|
||||
friend class GraphicsWindowIOS;
|
||||
|
||||
@ -167,12 +168,12 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
bool adaptToDeviceOrientation() const { return _adaptToDeviceOrientation; }
|
||||
|
||||
void setAdaptToDeviceOrientation(bool flag) { _adaptToDeviceOrientation = flag; }
|
||||
|
||||
|
||||
//
|
||||
//helper funs for converting points to pixels
|
||||
osg::Vec2 pointToPixel(const osg::Vec2& point);
|
||||
osg::Vec2 pixelToPoint(const osg::Vec2& pixel);
|
||||
|
||||
|
||||
//
|
||||
//helper funs for converting points to pixels
|
||||
osg::Vec2 pointToPixel(const osg::Vec2& point);
|
||||
osg::Vec2 pixelToPoint(const osg::Vec2& pixel);
|
||||
|
||||
protected:
|
||||
|
||||
@ -194,13 +195,13 @@ class GraphicsWindowIOS : public osgViewer::GraphicsWindow
|
||||
GraphicsWindowIOSWindow* _window;
|
||||
GraphicsWindowIOSGLView* _view;
|
||||
GraphicsWindowIOSGLViewController* _viewController;
|
||||
EAGLContext* _context;
|
||||
EAGLContext* _context;
|
||||
bool _updateContext;
|
||||
|
||||
bool _ownsWindow, _adaptToDeviceOrientation;
|
||||
|
||||
float _viewContentScaleFactor;
|
||||
|
||||
|
||||
bool _ownsWindow, _adaptToDeviceOrientation;
|
||||
|
||||
float _viewContentScaleFactor;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user