# Opensource Game Studio - News

https://kaisd.github.io/ogs-site/
2017-10-16T00:00:00+03:00

# Back to the Static

2017-10-16T00:00:00+03:00
2017-10-16T00:00:00+03:00
Opensource Game Studio
tag:kaisd.github.io,2017-10-16:/ogs-site/back-to-the-static.html
<p>We have been using Wordpress as our website engine for more than seven years. And now it's time to move forward. Or backward. For some time we've been tracking the development of the new breed of website engines - static site generators. It seems that this is the technology capable of …</p>
<p>We have been using Wordpress as our website engine for more than seven years. And now it's time to move forward. Or backward. For some time we've been tracking the development of the new breed of website engines - static site generators. It seems that this is the technology capable of changing past into future.</p> <p>A static website is more straightforward, quicker and more secure. And with the help of generators, it is also as easy to manage, as the dynamic website. So, we are starting our site anew with the help of the <a href="https://blog.getpelican.com/">Pelican</a>. Right now it doesn't have all the content from our old site, but we'll add most of it soon.</p>

# The birth of MJIN world

2017-09-10T00:00:00+03:00
2017-09-10T00:00:00+03:00
Opensource Game Studio
tag:kaisd.github.io,2017-09-10:/ogs-site/mjin-world-birth.html
<p><img alt="The birth of MJIN world" src="https://kaisd.github.io/ogs-site/2017-09-mjin-world-birth.png"></p> <p>This article describes the birth of MJIN world in August 2017.</p> <p><strong>mjin-player</strong></p> <p>As you know, <a href="https://kaisd.github.io/ogs-site/scripting-research.html">we spent July to research scripting</a>. We found a solution that satisfies the following criteria. Scripts should:</p> <ol> <li>run unchanged on all supported platforms</li> <li>allow extending C++ code</li> </ol> <p>We have verified the second criterion by writing …</p>
<p><img alt="The birth of MJIN world" src="https://kaisd.github.io/ogs-site/2017-09-mjin-world-birth.png"></p> <p>This article describes the birth of MJIN world in August 2017.</p> <p><strong>mjin-player</strong></p> <p>As you know, <a href="https://kaisd.github.io/ogs-site/scripting-research.html">we spent July to research scripting</a>. We found a solution that satisfies the following criteria. Scripts should:</p> <ol> <li>run unchanged on all supported platforms</li> <li>allow extending C++ code</li> </ol> <p>We have verified the second criterion by writing a sample application. The first criterion was taken for granted because it SHOULD be true.</p> <p>At the time, we saw two ways to verify the first criterion:</p> <ol> <li>create one sample application for each platform to verify scripting only</li> <li>create a single cross-platform application, which can run any code</li> </ol> <p>We chose the second approach because it is more beneficial in the long run. As you might have guessed, <a href="https://bitbucket.org/ogstudio/mjin-player">mjin-player</a> is that application.</p> <p>mjin-player serves as a base for the rest of MJIN projects to make them run on all supported platforms. However, there's no magic trick to hide the projects from the platform, and there was no such intention. Instead, mjin-player provides a consistent set of rules how other MJIN projects should be structured to be able to run on all supported platforms.</p> <p><strong>mjin-application</strong></p> <p>This set of rules for MJIN projects is packaged into <a href="https://bitbucket.org/ogstudio/mjin-application">mjin-application</a>. mjin-application is a library that provides basic functionality every MJIN project would need and nothing more. For instance, mjin-application does not and will not contain scripting or any other specific functionality.</p> <p><strong>MJIN world</strong></p> <p>So what is <a href="https://bitbucket.org/ogstudio/mjin">MJIN world</a>? It's a set of projects that constitute our game development tools. mjin-player and mjin-application are the first bricks of the newly born MJIN world. A lot more to come. Stay tuned for the brighter MJIN future.</p> <p>That's it for describing the birth of MJIN world in August 2017.</p>

# Scripting research

2017-08-16T00:00:00+03:00
2017-08-16T00:00:00+03:00
Opensource Game Studio
tag:kaisd.github.io,2017-08-16:/ogs-site/scripting-research.html
<p><img alt="Scripting research" src="https://kaisd.github.io/ogs-site/2017-08-scripting-research.png"></p> <p>This article describes scripting research in July 2017.</p> <p><strong>Our first goal of using a scripting language was to have a platform-independent code that runs unchanged on every supported platform.</strong></p> <p>OGS Editor 0.10 supports Python for such a code thanks to <a href="http://swig.org/">SWIG</a>. SWIG provides a way to wrap almost any …</p>
<p><img alt="Scripting research" src="https://kaisd.github.io/ogs-site/2017-08-scripting-research.png"></p> <p>This article describes scripting research in July 2017.</p> <p><strong>Our first goal of using a scripting language was to have a platform-independent code that runs unchanged on every supported platform.</strong></p> <p>OGS Editor 0.10 supports Python for such a code thanks to <a href="http://swig.org/">SWIG</a>. SWIG provides a way to wrap almost any C/C++ code and use it in dozens of languages like Python, Ruby, Lua, Java, C#, etc.. SWIG really helped us taste the beauty of platform-independent code. However, SWIG only works one way: from C/C++ to a target language. This means the main application must be in the target language, and C/C++ code can only be used as a library.</p> <p>Having the main application in Python works fine for the desktop, but not so great for mobile and web, where C and C++ are the only natively supported cross-platform languages. There are projects like <a href="https://kivy.org">Kivy</a>, which allow you to develop cross-platform applications in Python, but they are not supported natively. This means it's a lot of headaches when Android and iOS APIs change.</p> <p>Having the main application in C/C++ and the need to support scripting means that a scripting language should be interpreted by the application. This is what SWIG, Kivy, and similar projects are not meant to fulfill.</p> <p><strong>Our secondary goal for using a scripting language was to allow to extend C++ code.</strong></p> <p>OGS Editor 0.10 has some modules written in C++, and some in Python. The modules are equal from the perspective of the main application; it doesn't care what language the module is written in.</p> <p>To achieve such flexibility, we introduced a so-called Environment. Each module would register the keys it responds to, and Environment would deliver corresponding messages. Technically such behaviour is achieved by inheriting a base class and overriding its methods in both C++ and a scripting language.</p> <p><strong>First, we evaluated Python for the role of cross-platform scripting language.</strong></p> <p>Since we already used Python, we started to research the possibility to run Python code on every supported platform. The result was disappointing because CPython (the default Python implementation used on the desktop) does not mention mobile and web platforms. We only found some years old forks of CPython that were claimed to work either on Android or iOS. Such a disarray was not suitable for us. We also had a look at <a href="http://pypy.org">PyPy</a>, another Python implementation. It also did not mention support for mobile and web platforms.</p> <p>This was a clear indication that Python community doesn't care for mobile and web platforms. Or that nobody had time to provide the information about building Python on such platforms. Either way, it was not acceptable for us.</p> <p><strong>Second, we evaluated <a href="http://wren.io">Wren</a> for the role of cross-platform scripting language.</strong></p> <p>Wren was the first scripting language we stumbled upon in the long list of non-mainstream scripting languages.</p> <p>Wren claimed to be small and easy to learn. Wren also claimed to be intended for embedding in applications. Ironically, the author <a href="http://wren.io/embedding-api.html">had no time to document how to do the embedding in the first place</a>. When <a href="https://github.com/munificent/wren/issues/465">we asked for the time estimates of publishing</a> the critical part of the documentation, <a href="https://github.com/munificent/wren/issues/402">we just got a reference to another issue</a> where the other guy was asking the same question half a year ago!</p> <p>That's when we ended our relationship with Wren.</p> <p><strong>Third, we evaluated <a href="http://chaiscript.com">Chai</a> for the role of cross-platform scripting language.</strong></p> <p>Chai was in the long list of non-mainstream scripting languages, too. Chai was promising because it claimed to be specifically tailored for embedding in a C++ application. We successfully managed to call a C++ function from inside Chai but failed to call a member function. <a href="http://discourse.chaiscript.com/t/cannot-call-a-function-that-accepts-a-string-and-a-vector/334">We asked for help</a>, but nobody replied.</p> <p>We had to end our relationship with Chai.</p> <p><strong>Fourth, we evaluated Lua for the role of cross-platform scripting language.</strong></p> <p>Lua is the mainstream language for embedding. So we decided to try the obvious choice. Documentation looked promising, too. However, by the end of reading the <a href="https://www.lua.org/pil/24.html">C API</a> chapter we had no clue how to inherit a class inside Lua.</p> <p>This led us to search for libraries that wrap Lua C API syntax into something more meaningful for C++. That's how we found <a href="http://sol2.rtfd.io">Sol2</a>. Just as before, the first attempt to call a C++ member function from Lua failed. But unlike before, we asked for help and <a href="https://github.com/ThePhD/sol2/issues/465">got the help</a>! This was a refreshing surprise for us. Next, we tried to inherit a class in Lua and override the class methods. We failed, but <a href="https://github.com/ThePhD/sol2/issues/468">the author helped us out again</a>. In the end, we succeeded in inheriting a class and overriding its behaviour.</p> <p>That's when we understood it's a start for a long and mutual relationship with Sol2/Lua.</p> <p><strong>This search for a scripting language taught us one important lesson: people matter, not technologies.</strong></p> <p>There are lots of scripting languages that look shiny on the outside but are dead. Why? Because some authors don't have time for users. In return, users don't have time for the authors' projects.</p> <p>That's it for describing scripting research in July 2017.</p>

# OpenSceneGraph cross-platform guide

2017-07-17T00:00:00+03:00
2017-07-17T00:00:00+03:00
Opensource Game Studio
tag:kaisd.github.io,2017-07-17:/ogs-site/openscenegraph-cross-platform-guide.html
<p><img alt="OpenSceneGraph guide" src="https://kaisd.github.io/ogs-site/2017-07-openscenegraph-guide.png"></p> <p>This article summarizes the work we did to produce OpenSceneGraph cross-platform guide.</p> <p>June marked the finish of <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide">OpenSceneGraph cross-platform guide</a> with the publishing of the last (initially planned) tutorial. The tutorial describes <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide/tree/master/1.10.SampleWeb">how to build and run sample OpenSceneGraph application in Web</a> using Emscripten. In case you missed it, here's …</p>
<p><img alt="OpenSceneGraph guide" src="https://kaisd.github.io/ogs-site/2017-07-openscenegraph-guide.png"></p> <p>This article summarizes the work we did to produce OpenSceneGraph cross-platform guide.</p> <p>June marked the finish of <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide">OpenSceneGraph cross-platform guide</a> with the publishing of the last (initially planned) tutorial. The tutorial describes <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide/tree/master/1.10.SampleWeb">how to build and run sample OpenSceneGraph application in Web</a> using Emscripten. In case you missed it, here's a <a href="https://ogstudio.github.io/openscenegraph-cross-platform-guide/">link to the final application</a>. Open it in your web browser.</p> <p>We started to compose the guide in February when we successfully managed to render a simple model on mobile and web. We spent 120 hours in five months to produce ten tutorials of the guide.</p> <p>We have been doing OpenSceneGraph cross-platform guide for two main reasons:</p> <ol> <li>Keep OpenSceneGraph cross-platform knowledge in easily accessible and reproducible form</li> <li>Share the knowledge with OpenSceneGraph community to make it stronger</li> </ol> <p>We believe we succeeded in both. Here's why:</p> <ol> <li>The guide repository has more <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide/stargazers">stars</a> (aka "likes") than any other repository of ours</li> <li>OpenSceneGraph project leader Robert Osfield said <a href="http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg74815.html">"Great work"</a>, which means a lot</li> <li>The guide already has <a href="https://github.com/OGStudio/openscenegraph-cross-platform-guide/issues">two issues</a></li> </ol> <p>Reaching our goal of researching OpenSceneGraph cross-platform development and providing the knowledge back to the community just made us happier.</p> <p>However, our journey does not stop here. Using the knowledge of the guide, we now continue to work on bringing our tools to support mobile and web, just as we <a href="http://opengamestudio.org/lang/en/news/2456">promised in January</a>.</p> <p>That's it for summarizing the work we did to produce OpenSceneGraph cross-platform guide.</p>

# iOS tutorial

2017-06-08T10:00:00+03:00
2017-06-08T10:00:00+03:00
Opensource Game Studio
tag:kaisd.github.io,2017-06-08:/ogs-site/ios-tutorial.html
<p><img alt="iOS tutorial" src="https://kaisd.github.io/ogs-site/2017-06-08-ios-refactoring.png"></p> <p>This article describes problems we faced during the creation of iOS tutorial in May 2017.</p> <p><a href="https://twitter.com/OpenGameStudio/status/826816343433498627">This February</a> we managed to get simple model rendered under iOS in just a few days. We expected to finish iOS tutorial in no time. However, the reality reminded us: it's easy to come up …</p>
<p><img alt="iOS tutorial" src="https://kaisd.github.io/ogs-site/2017-06-08-ios-refactoring.png"></p> <p>This article describes problems we faced during the creation of iOS tutorial in May 2017.</p> <p><a href="https://twitter.com/OpenGameStudio/status/826816343433498627">This February</a> we managed to get simple model rendered under iOS in just a few days. We expected to finish iOS tutorial in no time. However, the reality reminded us: it's easy to come up with a hackish demo that works for one person, but it's hard to create a concise example that works for everyone.</p> <h3>Native library</h3> <p>The first question we had to answer was: should the sample application be part of Xcode project or be a separately built library?</p> <p>We had to consider the following facts:</p> <ol> <li>Xcode project can use C++ directly (thanks to Objective-C++) without stuff like JNI<ul> <li>There's no need for a separate library (+ application)</li> <li>Creating a separate library is an additional work (- library)</li> </ul> </li> <li>OpenSceneGraph builds libraries<ul> <li>It's easier to use standard build process (+ library)</li> <li>It's harder to create custom build process just for a single platform (- application)</li> </ul> </li> <li>OpenSceneGraph uses CMake build system, which is not supported by Xcode<ul> <li>Xcode project can't include CMake files (- application)</li> <li>It's easy to create custom CMake file that includes OpenSceneGraph CMake file to build a single library (+ library)</li> </ul> </li> <li>CMake can generate Xcode project<ul> <li>It's possible to create a CMake file that builds both OpenSceneGraph and the sample application (+ application)</li> <li>Xcode is the de-facto tool to create Xcode projects; it's easier to use standard build process (+ library)</li> </ul> </li> </ol> <p>After evaluating the pros and cons of each approach, we decided to turn the sample application into a library and include it in Xcode project. The downside of this approach is that simulator and real device builds need separate library builds.</p> <h3>Refactoring</h3> <p>The second question we had to answer was: should there be a single source code base for all platforms or several ones, one for each platform?</p> <p>While doing Android tutorial we used single source code base because it worked fine for desktop and Android. As we started to work through iOS tutorial, it became apparent that particular features may or may not work on some platforms. For example, one feature may work on desktop and iOS, but not Android. Another feature may work on iOS and Android, but not desktop. Since we didn't want to pollute the code with #ifdefs, we started to put each platform combination into a separate file. The number of files grew rapidly. The files were reusable, but it became extremely hard to see the whole picture.</p> <p>At this point, we realized there's the second question. We reminded ourselves that the main purpose of the sample source code is to teach how to do basic OpenSceneGraph things, not create a reusable library with API that is stable across several years.</p> <p>That's when our home grown feature tool came into play. With its help, we separated the code into several parts, which in the end produce just two files for each platform:</p> <ol> <li>functions.h - contains reusable classless functions</li> <li>main.h - contains the rest of the sample application code</li> </ol> <p>Their contents differ slightly for each platform, but it's easy to see the whole picture now.</p> <p>That's it for describing problems we faced during the creation of iOS tutorial in May 2017.</p>