OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

How I build OpenSceneGraph manually for desktop, mobile, and web


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
kornerr
Appreciator


Joined: 01 Oct 2013
Posts: 275

PostPosted: Tue Aug 14, 2018 11:51 am    Post subject:
How I build OpenSceneGraph manually for desktop, mobile, and web
Reply with quote

Hi.

Recently I've started building OpenSceneGraph without using official
CMakeLists.txt file. I've decided to describe why and how of this
process.

1. WHY.

I use OpenSceneGraph to develop cross-platform applications. While
desktop builds work mostly fine, anything else (Android, iOS, Web) is
easy to break and hard to fix.

Here's my list of top annoying things I had to deal with frequently:

1.1. Inability to build Lua plugin out of the box on macOS

My project's CMakeLists.txt uses `ADD_DEFINITIONS("-std=c++11")` to
force C++11. This breaks Lua plugin building on macOS because Clang
says C language does not have `C++11`, which makes sense. However,
Linux's GCC simply warns about it.

1.2. Hacking PNG plugin safety checks for Android

To build OpenSceneGraph's PNG plugin for Android, I need to hack
CMake's PNG plugin detection because OpenSceneGraph's CMakeLists.txt
uses standard `FIND_PNG`. While this works fine on desktops, Android
sucks at supporting STL, exceptions, and other standard stuff in old
APIs. I personally target API 14.

1.3. Maintaining two different builds for iOS - simulator and device

You have to configure and work with two different versions of the same
application for both simulator and device. Which means you can't
switch between device and simulator in the single project. Not to
mention how many hacks went into OpenSceneGraph's CMakeLists.txt to
support iOS.

1.4. Building OpenSceneGraph takes A LOT of time

Even firing 10 parallel build processes with 'make -j10' is damn slow
because OpenSceneGraph has a ton of files.

2. HOW.

2.1. Build OpenSceneGraph as part of the project into static library

Here's CMakeLists.txt I currently use for all platforms except iOS:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/c42fcbaaf4064b0853246e68837bc91d2b1842c9/libs/OpenSceneGraph/CMakeLists.txt

2.2. Build OpenSceneGraph libraries from custom source files

Custom source files include OpenSceneGraph source files directly.
Here's how osgGA.cpp looks like:
https://github.com/OGStudio/openscenegraph-cross-platform-examples/blob/c42fcbaaf4064b0853246e68837bc91d2b1842c9/libs/OpenSceneGraph/src/osgGA.cpp

This allows to build OpenSceneGraph multitudes time faster at the
expense of using more RAM during building.
As for plugins, I no longer need to hack my way through plugin
dependencies' safety checks, I simply include necessary source files.

2.3. Prepare OpenSceneGraph header files for each platform in advance

OpenSceneGraph and OpenThreads require different headers (osg/GL,
osg/Version, osg/Config, etc.) for different platforms and (probably)
compilers. I simply generated those headers by configuring stub
projects.

2.4. Build OpenSceneGraph as part of iOS project without CMakeLists.txt

Wrap all C++ files (.cpp extension) into Objective-C++ files (.mm
extension) and include them into Xcode project. Now you can switch
between simulator and device just like in other iOS projects.

3. EXAMPLE

OpenSceneGraph cross-platform examples now use described approach.
Check out how easy it is to build them for desktop, mobile, and web
platforms: https://github.com/OGStudio/openscenegraph-cross-platform-examples


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Emscripten build and dlopen jnmaloney General 0 Tue Sep 25, 2018 6:30 am View latest post
No new posts OpenSceneGraph-3.6.3 stable release h... robertosfield General 0 Fri Sep 14, 2018 10:39 am View latest post
No new posts OpenSceneGraph-3.6.3 release candidate 3 robertosfield General 1 Thu Sep 13, 2018 8:03 am View latest post
No new posts OpenSceneGraph-3.6.3 release candidat... robertosfield General 15 Tue Sep 11, 2018 11:37 am View latest post
No new posts OpenSceneGraph-3.6.3 release candidat... robertosfield General 6 Thu Sep 06, 2018 11:39 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP