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.

преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <style>
  6. #header
  7. {
  8. background: #2BA6E3;
  9. padding: 0.7em;
  10. text-align: left;
  11. }
  12. #header a
  13. {
  14. color: white;
  15. text-decoration: none;
  16. padding: 0.5em 1em 0.5em 1em;
  17. }
  18. #lang
  19. {
  20. float: right;
  21. }
  22. .news_item
  23. {
  24. background: #FFFFFF;
  25. width: 720px;
  26. padding: 1em;
  27. margin-top: 2em;
  28. margin-bottom: 2em;
  29. border: 1px solid #E0E0E0;
  30. text-align: left;
  31. }
  32. .news_item_contents
  33. {
  34. color: #444;
  35. line-height: 1.5em;
  36. }
  37. .news_item_date
  38. {
  39. margin-bottom: 2em;
  40. color: #aaa;
  41. }
  42. html
  43. {
  44. font-family: sans-serif;
  45. }
  46. body
  47. {
  48. background: #FAFAFA;
  49. }
  50. code, pre
  51. {
  52. font-family: monospace, serif;
  53. font-size: 1em;
  54. color: #7f0a0c;
  55. }
  56. img
  57. {
  58. width: 720px;
  59. }
  60. a
  61. {
  62. color: #3A91CB;
  63. text-decoration: none;
  64. }
  65. table
  66. {
  67. border-collapse: collapse;
  68. }
  69. table, th, td
  70. {
  71. border: 1px solid #aaa;
  72. padding: 0.5em;
  73. margin-top: 0.5em;
  74. margin-bottom: 0.5em;
  75. }
  76. </style>
  77. </head>
  78. <body>
  79. <div id="header">
  80. <strong id="title">Open Game Studio</strong>
  81. <a href="../../en/news/index.html">News</a>
  82. <a href="../../en/game/index.html">Games</a>
  83. <a href="../../en/tool/index.html">Tools</a>
  84. <a href="../../en/page/about.html">About</a>
  85. <div id="lang">
  86. <a href="../../en/news/ios-tutorial.html">EN</a>
  87. <a href="../../ru/news/ios-tutorial.html">RU</a>
  88. </div>
  89. </div>
  90. <center>
  91. <h1>In the news...</h1>
  92. <div class="news_item">
  93. <h2 class="news_item_title">
  94. <a href="ios-tutorial.html">iOS tutorial</a>
  95. </h2>
  96. <p class="news_item_date">
  97. 2017-06-08 10:00
  98. </p>
  99. <div class="news_item_contents">
  100. <p><img src="../../images/2017-06-08-ios-refactoring.png" alt="Earth and a rocket" /></p>
  101. <p>This article describes problems we faced during the creation of iOS tutorial in May 2017.</p>
  102. <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>
  103. <p><strong>Native library</strong></p>
  104. <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>
  105. <p>We had to consider the following facts:</p>
  106. <ol>
  107. <li>Xcode project can use C++ directly (thanks to Objective-C++) without stuff like JNI<ul>
  108. <li>There's no need for a separate library (+ application)</li>
  109. <li>Creating a separate library is an additional work (- library)</li></ul></li>
  110. <li>OpenSceneGraph builds libraries<ul>
  111. <li>It's easier to use standard build process (+ library)</li>
  112. <li>It's harder to create custom build process just for a single platform (- application)</li></ul></li>
  113. <li>OpenSceneGraph uses CMake build system, which is not supported by Xcode<ul>
  114. <li>Xcode project can't include CMake files (- application)</li>
  115. <li>It's easy to create custom CMake file that includes OpenSceneGraph CMake file to build a single library (+ library)</li></ul></li>
  116. <li>CMake can generate Xcode project<ul>
  117. <li>It's possible to create a CMake file that builds both OpenSceneGraph and the sample application (+ application)</li>
  118. <li>Xcode is the de-facto tool to create Xcode projects; it's easier to use standard build process (+ library)</li></ul></li>
  119. </ol>
  120. <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>
  121. <p><strong>Refactoring</strong></p>
  122. <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>
  123. <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>
  124. <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>
  125. <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>
  126. <ol>
  127. <li>functions.h - contains reusable classless functions</li>
  128. <li>main.h - contains the rest of the sample application code</li>
  129. </ol>
  130. <p>Their contents differ slightly for each platform, but it's easy to see the whole picture now.</p>
  131. <p>That's it for describing problems we faced during the creation of iOS tutorial in May 2017.</p>
  132. </div>
  133. </div>
  134. <div id="footer">
  135. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  136. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  137. The site is hosted by <a href="https://pages.github.com">GitHub Pages</a>.
  138. </div>
  139. </center>
  140. </body>
  141. </html>