<!DOCTYPE html> <head> <meta charset="utf-8" /> <!-- Set the viewport width to device width for mobile --> <meta name="viewport" content="width=device-width" /> <title>OpenSceneGraph sample</title> <link rel="stylesheet" href="http://opengamestudio.org/theme/css/normalize.css" /> <link rel="stylesheet" href="http://opengamestudio.org/theme/css/foundation.min.css" /> <link rel="stylesheet" href="http://opengamestudio.org/theme/css/style.css" /> <link rel="stylesheet" href="http://opengamestudio.org/theme/css/pygments.css" /> <script src="http://opengamestudio.org/theme/js/custom.modernizr.js"></script> <!-- So Firefox can bookmark->"abo this site" --> <link href="feeds/all.atom.xml" rel="alternate" title="Opensource Game Studio" type="application/atom+xml"> </head> <body> <!-- Nav Bar --> <nav> <!-- Show menu items and pages --> <div class="row"> <div class="large-12 columns top-bar"> <h1><a href="http://opengamestudio.org">Opensource Game Studio</a></h1> </div> </div> <div class="row top-menu"> <div class="large-12 columns"> <a href="/pages/games.html" class="menu-button secondary">Games</a> <a href="/pages/education.html" class="menu-button secondary">Education</a> <a href="/pages/about.html" class="menu-button secondary">About</a> </div> </div> </nav> <!-- End Nav --> <!-- Main Page Content and Sidebar --> <div class="row"> <!-- Main Blog Content --> <div class="large-9 columns"> <article> <header> <h3 class="article-title"><a href="http://opengamestudio.org/osg-sample.html" rel="bookmark" title="Permalink to OpenSceneGraph sample">OpenSceneGraph sample</a></h3> </header> <h6 class="subheader" title="2017-05-12T00:00:00+03:00">Пт 12 мая 2017 <a class="button secondary small translation-button" href="http://opengamestudio.org/osg-sample-ru.html">ru</a> </h6> <p><img alt="OSG sample" src="http://opengamestudio.org/2017-05_osg-sample.png"></p> <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> <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="http://opengamestudio.org/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> <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> <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> <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> <p class="subheader">Category: <a href="http://opengamestudio.org/category/news.html">News</a> </p> </article> </div> <!-- End Main Content --> <!-- Sidebar --> <aside class="large-3 columns"> <!--k <h5 class="sidebar-title">Site</h5> <ul class="side-nav"> <li><a href="http://opengamestudio.org/archives.html">Archives</a> <li><a href="http://opengamestudio.org/tags.html">Tags</a> <li><a href="http://opengamestudio.org/feeds/all.atom.xml" rel="alternate">Atom feed</a></li> </ul> <h5 class="sidebar-title">Categories</h5> <ul class="side-nav"> <li><a href="http://opengamestudio.org/category/news.html">News</a></li> </ul> --> <h5 class="sidebar-title">Ads</h5> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ogs2 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-4473792248813084" data-ad-slot="9024247127" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </aside> <!-- End Sidebar --> </div> <!-- End Main Content and Sidebar --> <!-- Footer --> <footer class="row"> <div class="large-12 columns"> <hr /> <div class="row"> <div class="large-7 columns"> <p>Proudly powered by <a href="http://getpelican.com">Pelican</a>, which takes great advantage of <a href="http://python.org">Python</a>.</p> </div> </div> </div> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-3773114-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </footer>