You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
преди 3 години
преди 1 месец
преди 3 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <link rel="stylesheet" href="../../style.css">
  6. </head>
  7. <body>
  8. <script data-goatcounter="https://services.opengamestudio.org:443/count" async src="//services.opengamestudio.org:443/count.js"></script>
  9. <div id="header">
  10. <div class="header2">
  11. <div class="menu">
  12. <a href="../../en/news/index.html">News</a>
  13. <a href="../../en/game/index.html">Games</a>
  14. <a href="../../en/tool/index.html">Tools</a>
  15. <a href="../../en/page/about.html">About</a>
  16. </div>
  17. <div id="lang">
  18. <a href="../../en/news/ios-tutorial.html">EN</a>
  19. <a href="../../ru/news/ios-tutorial.html">RU</a>
  20. </div>
  21. <div class="clear"></div>
  22. </div>
  23. </div>
  24. <h3 class="left_item_title">In the news...</h3>
  25. <center>
  26. <div class="news_item">
  27. <h2 class="news_item_title">
  28. <a href="ios-tutorial.html">iOS tutorial</a>
  29. </h2>
  30. <p class="news_item_date">
  31. 2017-06-08 10:00
  32. </p>
  33. <div class="news_item_contents">
  34. <p><img src="../../images/2017-06-08-ios-refactoring.png" alt="Earth and a rocket" /></p>
  35. <p>This article describes problems we faced during the creation of iOS tutorial in May 2017.</p>
  36. <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>
  37. <p><strong>Native library</strong></p>
  38. <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>
  39. <p>We had to consider the following facts:</p>
  40. <ol>
  41. <li>Xcode project can use C++ directly (thanks to Objective-C++) without stuff like JNI<ul>
  42. <li>There's no need for a separate library (+ application)</li>
  43. <li>Creating a separate library is an additional work (- library)</li></ul></li>
  44. <li>OpenSceneGraph builds libraries<ul>
  45. <li>It's easier to use standard build process (+ library)</li>
  46. <li>It's harder to create custom build process just for a single platform (- application)</li></ul></li>
  47. <li>OpenSceneGraph uses CMake build system, which is not supported by Xcode<ul>
  48. <li>Xcode project can't include CMake files (- application)</li>
  49. <li>It's easy to create custom CMake file that includes OpenSceneGraph CMake file to build a single library (+ library)</li></ul></li>
  50. <li>CMake can generate Xcode project<ul>
  51. <li>It's possible to create a CMake file that builds both OpenSceneGraph and the sample application (+ application)</li>
  52. <li>Xcode is the de-facto tool to create Xcode projects; it's easier to use standard build process (+ library)</li></ul></li>
  53. </ol>
  54. <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>
  55. <p><strong>Refactoring</strong></p>
  56. <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>
  57. <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>
  58. <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>
  59. <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>
  60. <ol>
  61. <li>functions.h - contains reusable classless functions</li>
  62. <li>main.h - contains the rest of the sample application code</li>
  63. </ol>
  64. <p>Their contents differ slightly for each platform, but it's easy to see the whole picture now.</p>
  65. <p>That's it for describing problems we faced during the creation of iOS tutorial in May 2017.</p>
  66. </div>
  67. </div>
  68. <div id="disqus_thread"></div>
  69. <script>
  70. var disqus_config = function () {
  71. this.page.url = "https://opengamestudio.org/en/news/ios-tutorial.html";
  72. this.page.identifier = "ios-tutorial.html";
  73. };
  74. (function() { // DON'T EDIT BELOW THIS LINE
  75. var d = document, s = d.createElement('script');
  76. s.src = 'https://opengamestudio.disqus.com/embed.js';
  77. s.setAttribute('data-timestamp', +new Date());
  78. (d.head || d.body).appendChild(s);
  79. })();
  80. </script>
  81. <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  82. <div id="footer">
  83. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  84. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  85. </div>
  86. </center>
  87. </body>
  88. </html>