<!DOCTYPE html> <html> <meta charset="utf-8"> <head> <style> body { background: #FAFAFA; } code, pre { font-family: monospace, serif; font-size: 1em; color: #7f0a0c; } figure { margin: 0px; padding: 0px; } img { width: 720px; } html { font-family: sans-serif; } #header { background: #2BA6E3; padding: 0.7em; text-align: left; } #header a { color: white; text-decoration: none; padding: 0.5em 1em 0.5em 1em; } a { color: #3A91CB; text-decoration: none; } .news_item { background: #FFFFFF; width: 720px; padding: 1em; margin-top: 2em; margin-bottom: 2em; border: 1px solid #E0E0E0; text-align: left; } .news_item_contents { color: #444; line-height: 1.5em; } .news_item_date { margin-bottom: 50px; color: #aaa; } #lang { float: right; } </style> </head> <body> <center> <div id="header"> <a href="index.html">News</a> <a href="games.html">Games</a> <a href="tools.html">Tools</a> <a href="about.html">About</a> <div id="lang"> <a href="osg-sample.html">EN</a> <a href="osg-sample-ru.html">RU</a> </div> </div> <h1>In the news</h1> <div class="news_item"> <h2 class="news_item_title"> <a href=" 2017-05-12_osg-sample.html "> OpenSceneGraph sample </a> </h2> <p class="news_item_date"> 2017-05-12 00:00 </p> <div class="news_item_contents"> <figure> <img src="images/2017-05_osg-sample.png" alt="OSG sample" /><figcaption>OSG sample</figcaption> </figure> <p>This article describes creation of the tutorials for building sample OpenSceneGraph application under Linux, macOS, Windows, and Android in April 2017.</p> <p>Previous tutorials described how to install OpenSceneGraph under Linux, macOS, Windows and render a model using the standard <strong>osgviewer</strong> tool. This time we worked on a <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide-application">sample OpenSceneGraph application</a> that would run under Linux, macOS, Windows, and Android.</p> <p>The application is very basic and has the following features:</p> <ol start="0" type="1"> <li>Render window creation</li> <li>Model loading</li> <li>Model rendering with simple GLSL shaders</li> <li>Model motion with a mouse under Linux, macOS, Windows and a finger under Android</li> </ol> <p>Creating the tutorials for Linux, macOS, Windows was so easy and straightforward, that it only took us half a month. We spent the second half of the month creating Android tutorial.</p> <p>Our <a href="2016-11-19_2016-october-recap.html">first successful Android build</a> last year included hacks and non-obvious steps to make OpenSceneGraph run under Android. This time we wanted a cleaner, faster, and cheaper approach.</p> <p>The approach we ended up with requires just a few files and a few changes to the original Android Studio project (with C++ support) to make sample OpenSceneGraph application run under Android.</p> <p>Here’s a quick rundown of the files:</p> <ol start="0" type="1"> <li>GLES2 surface</li> <li>Render activity to render to the surface</li> <li>Native library Java interface</li> <li>Native library C++ implementation</li> <li>CMake file to build native library</li> <li>Render activity layout</li> <li>Model to display</li> </ol> <p>Here’s a quick rundown of the project changes:</p> <ol start="0" type="1"> <li>Update Android manifest to use GLES2 and render activity</li> <li>Reference native library’s CMake file in the project’s CMake file</li> </ol> <p>OpenSceneGraph documentation suggests building OpenSceneGraph outside Android Studio with CMake. However, this approach has the following limitations:</p> <ol start="0" type="1"> <li>You have to build OpenSceneGraph for each target architecture</li> <li>You have to manually copy/reference built OpenSceneGraph libraries into Android Studio project</li> </ol> <p>Our approach includes building OpenSceneGraph for those target architectures that Android Studio project is built for. Also, OpenSceneGraph is already referenced, so no extra work is required: you just need to rebuild the project, and you’re done.</p> <p>That’s it for describing the creation of the tutorials for building sample OpenSceneGraph application under Linux, macOS, Windows, and Android in April 2017.</p> </div> </div> </center> <script type="text/javascript"> </script> </body> </html>