appsettings.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>jME3 Application Display Settings :: jMonkeyEngine Docs</title>
  7. <link rel="canonical" href="https://wiki.jmonkeyengine.org/docs/jme3/intermediate/appsettings.html">
  8. <meta name="generator" content="Antora 2.3.3">
  9. <link rel="stylesheet" href="../../../_/css/site.css">
  10. <meta property="og:image" content="https://wiki.jmonkeyengine.org/_/img/iconx128.png">
  11. <meta property="og:description" content="jME3 Application Display Settings">
  12. <meta property="og:title" content="jMonkeyEngine Docs">
  13. <link rel="stylesheet" href="../../../_/css/site-extra.css">
  14. <link rel="stylesheet" href="../../../_/css/vendor/docsearch.min.css">
  15. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css -->
  16. <link rel="icon" href="../../../_/img/favicon.ico" type="image/x-icon">
  17. </head>
  18. <body class="article">
  19. <header class="header">
  20. <nav class="navbar">
  21. <div class="navbar-brand">
  22. <a class="navbar-item" href="https://wiki.jmonkeyengine.org">
  23. <img alt="" src="../../../_/img/jme-logo.png" height="32" type="image/x-icon">
  24. </a>
  25. <div class="navbar-item hide-for-print">
  26. <input id="search-input" type="text" placeholder="Search docs">
  27. </div>
  28. <button class="navbar-burger" data-target="topbar-nav">
  29. <span></span>
  30. <span></span>
  31. <span></span>
  32. </button>
  33. </div>
  34. <div id="topbar-nav" class="navbar-menu">
  35. <div class="navbar-end">
  36. <div class="navbar-item theme-switch-wrapper">
  37. <label class="theme-switch" for="checkbox">
  38. <input type="checkbox" id="checkbox" />
  39. <div class="slider round"></div>
  40. </label>
  41. </div>
  42. <a class="navbar-item" href="https://github.com/jmonkeyengine/wiki">Github</a>
  43. </div>
  44. </div>
  45. </nav>
  46. </header>
  47. <div class="body">
  48. <div class="nav-container" data-component="docs" data-version="master">
  49. <aside class="nav">
  50. <div class="panels">
  51. <div class="nav-panel-menu is-active" data-panel="menu">
  52. <nav class="nav-menu">
  53. <h3 class="title"><a href="../../documentation.html">Docs</a></h3>
  54. <ul class="nav-list">
  55. <li class="nav-item" data-depth="0">
  56. <ul class="nav-list">
  57. <li class="nav-item" data-depth="1">
  58. <a class="nav-link" href="../../documentation.html">Getting Started</a>
  59. </li>
  60. <li class="nav-item" data-depth="1">
  61. <a class="nav-link" href="https://javadoc.jmonkeyengine.org/v3.3.2-stable">JavaDoc</a>
  62. </li>
  63. <li class="nav-item" data-depth="1">
  64. <button class="nav-item-toggle"></button>
  65. <a class="nav-link" href="../../jme3.html">jMonkeyEngine 3</a>
  66. <ul class="nav-list">
  67. <li class="nav-item" data-depth="2">
  68. <button class="nav-item-toggle"></button>
  69. <span class="nav-text">Beginner Tutorials</span>
  70. <ul class="nav-list">
  71. <li class="nav-item" data-depth="3">
  72. <a class="nav-link" href="../beginner/hello_simpleapplication.html">Hello SimpleApplication</a>
  73. </li>
  74. <li class="nav-item" data-depth="3">
  75. <a class="nav-link" href="../beginner/hello_node.html">Hello Node</a>
  76. </li>
  77. <li class="nav-item" data-depth="3">
  78. <a class="nav-link" href="../beginner/hello_asset.html">Hello Asset</a>
  79. </li>
  80. <li class="nav-item" data-depth="3">
  81. <a class="nav-link" href="../beginner/hello_main_event_loop.html">Hello Main Event Loop</a>
  82. </li>
  83. <li class="nav-item" data-depth="3">
  84. <a class="nav-link" href="../beginner/hello_input_system.html">Hello Input System</a>
  85. </li>
  86. <li class="nav-item" data-depth="3">
  87. <a class="nav-link" href="../beginner/hello_material.html">Hello Material</a>
  88. </li>
  89. <li class="nav-item" data-depth="3">
  90. <a class="nav-link" href="../beginner/hello_animation.html">Hello Animation</a>
  91. </li>
  92. <li class="nav-item" data-depth="3">
  93. <a class="nav-link" href="../beginner/hello_picking.html">Hello Picking</a>
  94. </li>
  95. <li class="nav-item" data-depth="3">
  96. <a class="nav-link" href="../beginner/hello_collision.html">Hello Collision</a>
  97. </li>
  98. <li class="nav-item" data-depth="3">
  99. <a class="nav-link" href="../beginner/hello_terrain.html">Hello Terrain</a>
  100. </li>
  101. <li class="nav-item" data-depth="3">
  102. <a class="nav-link" href="../beginner/hello_audio.html">Hello Audio</a>
  103. </li>
  104. <li class="nav-item" data-depth="3">
  105. <a class="nav-link" href="../beginner/hello_effects.html">Hello Effects</a>
  106. </li>
  107. <li class="nav-item" data-depth="3">
  108. <a class="nav-link" href="../beginner/hello_physics.html">Hello Physics</a>
  109. </li>
  110. </ul>
  111. </li>
  112. <li class="nav-item" data-depth="2">
  113. <button class="nav-item-toggle"></button>
  114. <span class="nav-text">Intermediate Tutorials</span>
  115. <ul class="nav-list">
  116. <li class="nav-item" data-depth="3">
  117. <button class="nav-item-toggle"></button>
  118. <span class="nav-text">Concepts</span>
  119. <ul class="nav-list">
  120. <li class="nav-item" data-depth="4">
  121. <a class="nav-link" href="best_practices.html">Best Practices</a>
  122. </li>
  123. <li class="nav-item" data-depth="4">
  124. <a class="nav-link" href="simpleapplication.html">Simple Application</a>
  125. </li>
  126. <li class="nav-item" data-depth="4">
  127. <a class="nav-link" href="../features.html">Features</a>
  128. </li>
  129. <li class="nav-item" data-depth="4">
  130. <a class="nav-link" href="optimization.html">Optimization</a>
  131. </li>
  132. <li class="nav-item" data-depth="4">
  133. <a class="nav-link" href="../faq.html">FAQ</a>
  134. </li>
  135. </ul>
  136. </li>
  137. <li class="nav-item" data-depth="3">
  138. <button class="nav-item-toggle"></button>
  139. <span class="nav-text">Math Concepts</span>
  140. <ul class="nav-list">
  141. <li class="nav-item" data-depth="4">
  142. <a class="nav-link" href="../math_for_dummies.html">Math For Dummies</a>
  143. </li>
  144. <li class="nav-item" data-depth="4">
  145. <a class="nav-link" href="math.html">Math</a>
  146. </li>
  147. <li class="nav-item" data-depth="4">
  148. <a class="nav-link" href="../math.html">More Math</a>
  149. </li>
  150. <li class="nav-item" data-depth="4">
  151. <a class="nav-link" href="../rotate.html">Rotate</a>
  152. </li>
  153. <li class="nav-item" data-depth="4">
  154. <a class="nav-link" href="../math_video_tutorials.html">Math Video Tutorials</a>
  155. </li>
  156. </ul>
  157. </li>
  158. <li class="nav-item" data-depth="3">
  159. <button class="nav-item-toggle"></button>
  160. <span class="nav-text">3D Graphics Concepts</span>
  161. <ul class="nav-list">
  162. <li class="nav-item" data-depth="4">
  163. <a class="nav-link" href="multi-media_asset_pipeline.html">Multi-Media Asset Pipeline</a>
  164. </li>
  165. <li class="nav-item" data-depth="4">
  166. <a class="nav-link" href="../scenegraph_for_dummies.html">Scenegraph for Dummies</a>
  167. </li>
  168. <li class="nav-item" data-depth="4">
  169. <a class="nav-link" href="../beginner/hellovector.html">Hello Vector</a>
  170. </li>
  171. <li class="nav-item" data-depth="4">
  172. <a class="nav-link" href="../terminology.html">Terminology</a>
  173. </li>
  174. <li class="nav-item" data-depth="4">
  175. <a class="nav-link" href="how_to_use_materials.html">How to Use Materials</a>
  176. </li>
  177. <li class="nav-item" data-depth="4">
  178. <a class="nav-link" href="transparency_sorting.html">Transparency and Sorting</a>
  179. </li>
  180. <li class="nav-item" data-depth="4">
  181. <a class="nav-link" href="../external/blender.html">Importing from Blender</a>
  182. </li>
  183. <li class="nav-item" data-depth="4">
  184. <a class="nav-link" href="../external/3dsmax.html">Importing from 3DS Max</a>
  185. </li>
  186. </ul>
  187. </li>
  188. </ul>
  189. </li>
  190. </ul>
  191. </li>
  192. <li class="nav-item" data-depth="1">
  193. <a class="nav-link" href="../../logo.html">Logo Usage</a>
  194. </li>
  195. <li class="nav-item" data-depth="1">
  196. <a class="nav-link" href="../../bsd_license.html">License</a>
  197. </li>
  198. <li class="nav-item" data-depth="1">
  199. <a class="nav-link" href="../../github_tips.html">Github Tips</a>
  200. </li>
  201. </ul>
  202. </li>
  203. <li class="nav-item" data-depth="0">
  204. <button class="nav-item-toggle"></button>
  205. <span class="nav-text">SDK</span>
  206. <ul class="nav-list">
  207. <li class="nav-item" data-depth="1">
  208. <a class="nav-link" href="../../sdk.html">jMonkeyEngine SDK</a>
  209. </li>
  210. </ul>
  211. </li>
  212. </ul>
  213. </nav>
  214. </div>
  215. <div class="nav-panel-explore" data-panel="explore">
  216. <div class="context">
  217. <span class="title">Docs</span>
  218. <span class="version">master</span>
  219. </div>
  220. <ul class="components">
  221. <li class="component is-current">
  222. <span class="title">Docs</span>
  223. <ul class="versions">
  224. <li class="version is-current is-latest">
  225. <a href="../../documentation.html">master</a>
  226. </li>
  227. </ul>
  228. </li>
  229. <li class="component">
  230. <span class="title">Wiki UI</span>
  231. <ul class="versions">
  232. <li class="version is-latest">
  233. <a href="../../../wiki-ui/index.html">master</a>
  234. </li>
  235. </ul>
  236. </li>
  237. </ul>
  238. </div>
  239. </div>
  240. </aside>
  241. </div>
  242. <main class="article">
  243. <div class="toolbar" role="navigation">
  244. <button class="nav-toggle"></button>
  245. <nav class="breadcrumbs" aria-label="breadcrumbs">
  246. <ul>
  247. <li><a href="../../documentation.html">Docs</a></li>
  248. <li><a href="appsettings.html">jME3 Application Display Settings</a></li>
  249. </ul>
  250. </nav>
  251. <div class="edit-this-page"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/docs/modules/ROOT/pages/jme3/intermediate/appsettings.adoc">Edit this Page</a></div>
  252. </div>
  253. <div class="content">
  254. <article class="doc">
  255. <h1 class="page">jME3 Application Display Settings</h1>
  256. <div id="preamble">
  257. <div class="sectionbody">
  258. <div class="paragraph">
  259. <p>Every class that extends jme3.app.SimpleApplication has properties that can be configured by customizing a <code>com.jme3.system.AppSettings</code> object.</p>
  260. </div>
  261. <div class="admonitionblock important">
  262. <table>
  263. <tr>
  264. <td class="icon">
  265. <i class="fa icon-important" title="Important"></i>
  266. </td>
  267. <td class="content">
  268. <div class="paragraph">
  269. <p>Configure application settings in <code>main()</code>, before you call <code>app.start()</code> on the application object. If you change display settings during runtime, for example in <code>simpleInitApp()</code>, you must call <code>app.restart()</code> to make them take effect.</p>
  270. </div>
  271. </td>
  272. </tr>
  273. </table>
  274. </div>
  275. <div class="paragraph">
  276. <p><strong>Note:</strong> Other runtime settings are covered in <a href="simpleapplication.html" class="page">SimpleApplication</a>.</p>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="sect1">
  281. <h2 id="code-samples"><a class="anchor" href="#code-samples"></a>Code Samples</h2>
  282. <div class="sectionbody">
  283. <div class="paragraph">
  284. <p>Specify settings for a game (here called <code>MyGame</code>, or whatever you called your SimpleApplication instance) in the <code>main()</code> method before the game starts:</p>
  285. </div>
  286. <div class="listingblock">
  287. <div class="content">
  288. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public static void main(String[] args) {
  289. AppSettings settings = new AppSettings(true);
  290. settings.setResolution(640,480);
  291. // ... other properties, see below
  292. MyGame app = new MyGame();
  293. app.setSettings(settings);
  294. app.start();
  295. }</code></pre>
  296. </div>
  297. </div>
  298. <div class="paragraph">
  299. <p>Set the boolean in the AppSettings contructor to true if you want to keep the default settings for values that you do not specify. Set this parameter to false if you want the application to load user settings from previous launches. In either case you can still customize individual settings.</p>
  300. </div>
  301. <div class="admonitionblock warning">
  302. <table>
  303. <tr>
  304. <td class="icon">
  305. <i class="fa icon-warning" title="Warning"></i>
  306. </td>
  307. <td class="content">
  308. The settings are saved based on the title of your game (default = &#8220;jMonkey Engine 3.x-stable&#8221;). This means that if you have not changed the default title, then remove a setting method call, your settings changes will remain in effect for all projects using the default title. To prevent this, set the title for your game or remember to change the settings back to their <a href="https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/system/AppSettings.java#L213">default</a> and run the project again.
  309. </td>
  310. </tr>
  311. </table>
  312. </div>
  313. <div class="paragraph">
  314. <p>This example toggles the settings to fullscreen while the game is already running. Then it restarts the game context (not the whole game) which applies the changed settings.</p>
  315. </div>
  316. <div class="listingblock">
  317. <div class="content">
  318. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public void toggleToFullscreen() {
  319. GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
  320. DisplayMode[] modes = device.getDisplayModes();
  321. int i=0; // note: there are usually several, let's pick the first
  322. settings.setResolution(modes[i].getWidth(),modes[i].getHeight());
  323. settings.setFrequency(modes[i].getRefreshRate());
  324. settings.setBitsPerPixel(modes[i].getBitDepth());
  325. settings.setFullscreen(device.isFullScreenSupported());
  326. app.setSettings(settings);
  327. app.restart(); // restart the context to apply changes
  328. }</code></pre>
  329. </div>
  330. </div>
  331. <div class="paragraph">
  332. <p>To view your current settings, use the System class.</p>
  333. </div>
  334. <div class="listingblock">
  335. <div class="content">
  336. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">AppSettings settings = new AppSettings(true);
  337. System.out.println(settings);</code></pre>
  338. </div>
  339. </div>
  340. </div>
  341. </div>
  342. <div class="sect1">
  343. <h2 id="properties"><a class="anchor" href="#properties"></a>Properties</h2>
  344. <div class="sectionbody">
  345. <table class="tableblock frame-all grid-all stretch">
  346. <caption class="title">Table A: Video</caption>
  347. <colgroup>
  348. <col style="width: 30%;">
  349. <col style="width: 55%;">
  350. <col style="width: 15%;">
  351. </colgroup>
  352. <thead>
  353. <tr>
  354. <th class="tableblock halign-left valign-top">Settings Property</th>
  355. <th class="tableblock halign-left valign-top">Description</th>
  356. <th class="tableblock halign-left valign-top">Default</th>
  357. </tr>
  358. </thead>
  359. <tbody>
  360. <tr>
  361. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  362. <p>setRenderer(AppSettings.LWJGL_OPENGL1)<br>
  363. setRenderer(AppSettings.LWJGL_OPENGL2)<br>
  364. setRenderer(AppSettings.LWJGL_OPENGL3)</p>
  365. </div></div></td>
  366. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  367. <p>Switch Video Renderer to OpenGL 1.1, OpenGL 2, or OpenGL 3.3. If your graphic card does not support all OpenGL2 features (<code>UnsupportedOperationException: GLSL and OpenGL2 is required for the LWJGL renderer</code>), then you can force your SimpleApplication to use OpenGL1 compatibility. (Then you still can&#8217;t use special OpenGL2 features, but at least the error goes away and you can continue with the rest.)</p>
  368. </div></div></td>
  369. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  370. <p>OpenGL 2</p>
  371. </div></div></td>
  372. </tr>
  373. <tr>
  374. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  375. <p>setBitsPerPixel(32)</p>
  376. </div></div></td>
  377. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  378. <p>Set the color depth.<br>
  379. 1 bpp = black and white, 2 bpp = gray,<br>
  380. 4 bpp = 16 colors, 8 bpp = 256 colors, 24 or 32 bpp = &#8220;truecolor&#8221;.</p>
  381. </div></div></td>
  382. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  383. <p>24</p>
  384. </div></div></td>
  385. </tr>
  386. <tr>
  387. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  388. <p>setFramerate(60)</p>
  389. </div></div></td>
  390. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  391. <p>How often per second the engine should try to refresh the frame. For the release, usually 60 fps. Can be lower (30) if you need to free up the CPU for other applications. No use setting it to a higher value than the screen frequency! If the framerate goes below 30 fps, viewers start to notice choppiness or flickering.</p>
  392. </div></div></td>
  393. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  394. <p>-1 (unlimited)</p>
  395. </div></div></td>
  396. </tr>
  397. <tr>
  398. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  399. <p>setFullscreen(true)</p>
  400. </div></div></td>
  401. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  402. <p>Set this to true to make the game window fill the whole screen; you need to provide a key that calls app.stop() to exit the fullscreen view gracefully (default: escape).<br>
  403. Set this to false to play the game in a normal window of its own.</p>
  404. </div></div></td>
  405. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  406. <p>False (windowed)</p>
  407. </div></div></td>
  408. </tr>
  409. <tr>
  410. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  411. <p>setHeight(480), setWidth(640)<br>
  412. setResolution(640,480)</p>
  413. </div></div></td>
  414. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  415. <p>Two equivalent ways of setting the display resolution.</p>
  416. </div></div></td>
  417. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  418. <p>640x480 pixels</p>
  419. </div></div></td>
  420. </tr>
  421. <tr>
  422. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  423. <p>setSamples(4)</p>
  424. </div></div></td>
  425. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  426. <p>Set multisampling to 0 to switch antialiasing off (harder edges, faster.)<br>
  427. Set multisampling to 2 or 4 to activate antialising (softer edges, may be slower.)<br>
  428. Depending on your graphic card, you may be able to set multisampling to higher values such as 8, 16, or 32 samples.</p>
  429. </div></div></td>
  430. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  431. <p>0</p>
  432. </div></div></td>
  433. </tr>
  434. <tr>
  435. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  436. <p>setVSync(true)<br>
  437. setFrequency(60)</p>
  438. </div></div></td>
  439. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  440. <p>Set vertical syncing to true to time the frame buffer to coincide with the refresh frequency of the screen. VSync prevents ugly page tearing artefacts, but is a bit slower; recommened for release build.<br>
  441. Set VSync to false to deactivate vertical syncing (faster, but possible page tearing artifacts); can remain deactivated during development or for slower PCs.</p>
  442. </div></div></td>
  443. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  444. <p>false<br>
  445. 60 fps</p>
  446. </div></div></td>
  447. </tr>
  448. <tr>
  449. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  450. <p>setStencilBits(8)</p>
  451. </div></div></td>
  452. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  453. <p>Set the number of stencil bits.<br>
  454. This value is only relevant when the stencil buffer is being used. Specify 8 to indicate an 8-bit stencil buffer, specify 0 to disable the stencil buffer.</p>
  455. </div></div></td>
  456. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  457. <p>0 (disabled)</p>
  458. </div></div></td>
  459. </tr>
  460. <tr>
  461. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  462. <p>setDepthBits(16)</p>
  463. </div></div></td>
  464. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  465. <p>Sets the number of depth bits to use.<br>
  466. The number of depth bits specifies the precision of the depth buffer. To increase precision, specify 32 bits. To decrease precision, specify 16 bits. On some platforms 24 bits might not be supported, in that case, specify 16 bits.<br>
  467. See <a href="https://msdn.microsoft.com/en-us/library/bb976071.aspx">What Is a Depth Buffer?</a> and <a href="https://en.wikipedia.org/wiki/Z-buffering">Z-buffering</a> for a more in depth explanation.</p>
  468. </div></div></td>
  469. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  470. <p>24</p>
  471. </div></div></td>
  472. </tr>
  473. <tr>
  474. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  475. <p>setGammaCorrection(true)</p>
  476. </div></div></td>
  477. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  478. <p>Enables Gamma Correction.<br>
  479. If you’re starting a new project, use it, period. And don’t allow the player to turn it off.<br>
  480. See <a href="../advanced/jme3_srgbpipeline.html" class="page">Gamma Correction or sRGB pipeline</a></p>
  481. </div></div></td>
  482. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  483. <p>false</p>
  484. </div></div></td>
  485. </tr>
  486. </tbody>
  487. </table>
  488. <table class="tableblock frame-all grid-all stretch">
  489. <caption class="title">Table B: Input</caption>
  490. <colgroup>
  491. <col style="width: 30%;">
  492. <col style="width: 55%;">
  493. <col style="width: 15%;">
  494. </colgroup>
  495. <thead>
  496. <tr>
  497. <th class="tableblock halign-left valign-top">Settings Property</th>
  498. <th class="tableblock halign-left valign-top">Description</th>
  499. <th class="tableblock halign-left valign-top">Default</th>
  500. </tr>
  501. </thead>
  502. <tbody>
  503. <tr>
  504. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  505. <p>setUseInput(false)</p>
  506. </div></div></td>
  507. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  508. <p>Respond to user input by mouse and keyboard. Can be deactivated for use cases where you only display a 3D scene on the canvas without any interaction.</p>
  509. </div></div></td>
  510. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  511. <p>true</p>
  512. </div></div></td>
  513. </tr>
  514. <tr>
  515. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  516. <p>setUseJoysticks(true)</p>
  517. </div></div></td>
  518. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  519. <p>Activate optional joystick support</p>
  520. </div></div></td>
  521. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  522. <p>false</p>
  523. </div></div></td>
  524. </tr>
  525. <tr>
  526. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  527. <p>setEmulateMouse(true)</p>
  528. </div></div></td>
  529. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  530. <p>Enable or disable mouse emulation for touchscreen-based devices. Setting this to true converts taps on the touchscreen to clicks, and finger swiping gestures over the touchscreen into mouse axis events.</p>
  531. </div></div></td>
  532. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  533. <p>false</p>
  534. </div></div></td>
  535. </tr>
  536. <tr>
  537. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  538. <p>setEmulateMouseFlipAxis(true,true)</p>
  539. </div></div></td>
  540. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  541. <p>Flips the X or Y (or both) axes for the emulated mouse. Set the first parameter to true to flip the x axis, and the second to flip the y axis.</p>
  542. </div></div></td>
  543. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  544. <p>false,false</p>
  545. </div></div></td>
  546. </tr>
  547. </tbody>
  548. </table>
  549. <table class="tableblock frame-all grid-all stretch">
  550. <caption class="title">Table C: Audio</caption>
  551. <colgroup>
  552. <col style="width: 30%;">
  553. <col style="width: 55%;">
  554. <col style="width: 15%;">
  555. </colgroup>
  556. <thead>
  557. <tr>
  558. <th class="tableblock halign-left valign-top">Settings Property</th>
  559. <th class="tableblock halign-left valign-top">Description</th>
  560. <th class="tableblock halign-left valign-top">Default</th>
  561. </tr>
  562. </thead>
  563. <tbody>
  564. <tr>
  565. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  566. <p>setAudioRenderer(AppSettings.LWJGL_OPENAL)</p>
  567. </div></div></td>
  568. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  569. <p>Switch Audio Renderer. Currently there is only one option.</p>
  570. </div></div></td>
  571. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  572. <p>OpenAL</p>
  573. </div></div></td>
  574. </tr>
  575. <tr>
  576. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  577. <p>setStereo3D(true)</p>
  578. </div></div></td>
  579. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  580. <p>Enable 3D stereo. This feature requires hardware support from the GPU driver. See <a href="http://en.wikipedia.org/wiki/Quad_buffering">Quad Buffering</a>. Currently, your everday user&#8217;s hardware does not support this, so you can ignore it for now.</p>
  581. </div></div></td>
  582. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  583. <p>false</p>
  584. </div></div></td>
  585. </tr>
  586. </tbody>
  587. </table>
  588. <table class="tableblock frame-all grid-all stretch">
  589. <caption class="title">Table D: Branding</caption>
  590. <colgroup>
  591. <col style="width: 30%;">
  592. <col style="width: 55%;">
  593. <col style="width: 15%;">
  594. </colgroup>
  595. <thead>
  596. <tr>
  597. <th class="tableblock halign-left valign-top">Settings Property</th>
  598. <th class="tableblock halign-left valign-top">Description</th>
  599. <th class="tableblock halign-left valign-top">Default</th>
  600. </tr>
  601. </thead>
  602. <tbody>
  603. <tr>
  604. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  605. <p>setTitle("My Game")</p>
  606. </div></div></td>
  607. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  608. <p>This string will be visible in the titlebar, unless the window is fullscreen.</p>
  609. </div></div></td>
  610. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  611. <p>&#8220;jMonkey Engine 3.x-stable&#8221;</p>
  612. </div></div></td>
  613. </tr>
  614. <tr>
  615. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  616. <p>setIcons(new BufferedImage[]{<br>
  617. ImageIO.read(new File(" ")), …});</p>
  618. </div></div></td>
  619. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  620. <p>This specifies the little application icon in the titlebar of the application (unused in MacOS?). You should specify the icon in various sizes (256,128,32,16) to look good on various operating systems. Note: This is not the application icon on the desktop.</p>
  621. </div></div></td>
  622. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  623. <p>null</p>
  624. </div></div></td>
  625. </tr>
  626. <tr>
  627. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  628. <p>setSettingsDialogImage("Interface/mysplashscreen.png")</p>
  629. </div></div></td>
  630. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  631. <p>A custom splashscreen image in the <code>assets/Interface</code> directory which is displayed when the settings dialog is shown.</p>
  632. </div></div></td>
  633. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  634. <p>"/com/jme3/app/Monkey.png"</p>
  635. </div></div></td>
  636. </tr>
  637. </tbody>
  638. </table>
  639. <div class="admonitionblock tip">
  640. <table>
  641. <tr>
  642. <td class="icon">
  643. <i class="fa icon-tip" title="Tip"></i>
  644. </td>
  645. <td class="content">
  646. <div class="paragraph">
  647. <p>You can use <code>app.setShowSettings(true);</code> and <code>setSettingsDialogImage("Interface/mysplashscreen.png")</code> to present the user with jme3&#8217;s default display settings dialog when starting the game. Use <code>app.setShowSettings(false);</code> to hide the default settings screen. Set this boolean before calling <code>app.start()</code> on the SimpleApplication.</p>
  648. </div>
  649. </td>
  650. </tr>
  651. </table>
  652. </div>
  653. </div>
  654. </div>
  655. <div class="sect1">
  656. <h2 id="toggling-and-activating-settings"><a class="anchor" href="#toggling-and-activating-settings"></a>Toggling and Activating Settings</h2>
  657. <div class="sectionbody">
  658. <table class="tableblock frame-all grid-all stretch">
  659. <colgroup>
  660. <col style="width: 25%;">
  661. <col style="width: 75%;">
  662. </colgroup>
  663. <thead>
  664. <tr>
  665. <th class="tableblock halign-left valign-top">SimpleApplication method</th>
  666. <th class="tableblock halign-left valign-top">Description</th>
  667. </tr>
  668. </thead>
  669. <tbody>
  670. <tr>
  671. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  672. <p>app.setShowSettings(boolean)</p>
  673. </div></div></td>
  674. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  675. <p>Activate or deactivate the default settings screen before start()ing the game. If you let users use this screen, you do not need to modify the settings object. Note: Most developers implement their own custom settings screen, but the default one is useful during the alpha stages.</p>
  676. </div></div></td>
  677. </tr>
  678. <tr>
  679. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  680. <p>app.setSettings(settings)</p>
  681. </div></div></td>
  682. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  683. <p>After you have modified the properties on the settings object, you apply it to your application. Note that the settings are not automatically reloaded while the game is running.</p>
  684. </div></div></td>
  685. </tr>
  686. <tr>
  687. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  688. <p>app.start()</p>
  689. </div></div></td>
  690. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  691. <p>Every game calls start() in the beginning to initialize the game and apply the settings. Modify and set your settings before calling start().</p>
  692. </div></div></td>
  693. </tr>
  694. <tr>
  695. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  696. <p>app.restart()</p>
  697. </div></div></td>
  698. <td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
  699. <p>Restart()ing a running game restarts the game context and applies the updated settings object. (This does not restart or reinitialize the whole game.)</p>
  700. </div></div></td>
  701. </tr>
  702. </tbody>
  703. </table>
  704. </div>
  705. </div>
  706. <div class="sect1">
  707. <h2 id="saving-and-loading-settings"><a class="anchor" href="#saving-and-loading-settings"></a>Saving and Loading Settings</h2>
  708. <div class="sectionbody">
  709. <div class="admonitionblock caution">
  710. <table>
  711. <tr>
  712. <td class="icon">
  713. <i class="fa icon-caution" title="Caution"></i>
  714. </td>
  715. <td class="content">
  716. <div class="paragraph">
  717. <p>Due to a current bug and inconsistent behavior observed related to the preferences save location, to ensure correct behavior, save() and load() should only use forward slashes <kbd>/</kbd> and must be all lowercase.</p>
  718. </div>
  719. <div class="paragraph">
  720. <p>More information can be found <a href="https://github.com/jMonkeyEngine/jmonkeyengine/issues/1161">here</a>.</p>
  721. </div>
  722. </td>
  723. </tr>
  724. </table>
  725. </div>
  726. <div class="paragraph">
  727. <p>An AppSettings object also supports the following methods to save your settings under a unique key (in this example &#8220;com/foo/mycoolgame3&#8221;):</p>
  728. </div>
  729. <div class="ulist">
  730. <ul>
  731. <li>
  732. <p>Use <code>settings.save("com/foo/mycoolgame3")</code> to save your settings via standard java.io serialization.</p>
  733. </li>
  734. <li>
  735. <p>Use <code>settings.load("com/foo/mycoolgame3")</code> to load your settings.</p>
  736. </li>
  737. <li>
  738. <p>Use <code>settings2.copyFrom(settings)</code> to copy a settings object.</p>
  739. </li>
  740. </ul>
  741. </div>
  742. <div class="paragraph">
  743. <p>Usage:</p>
  744. </div>
  745. <div class="paragraph">
  746. <p>Provide the unique name of your jME3 application as the String argument. For example <code>com/foo/mycoolgame3</code>.</p>
  747. </div>
  748. <div class="listingblock">
  749. <div class="content">
  750. <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java"> try { settings.save("com/foo/mycoolgame3"); }
  751. catch (BackingStoreException ex) { /** could not save settings */ }</code></pre>
  752. </div>
  753. </div>
  754. <div class="ulist">
  755. <ul>
  756. <li>
  757. <p>On Windows, the preferences are saved under the following registry key:<br>
  758. <code>HKEY_CURRENT_USER\Software\JavaSoft\Prefs\com\foo\mycoolgame3</code></p>
  759. </li>
  760. <li>
  761. <p>On Linux, the preferences are saved in an XML file under:<br>
  762. <code>$HOME/.java/.userPrefs/com/foo/mycoolgame3</code></p>
  763. </li>
  764. <li>
  765. <p>On Mac <abbr title="Operating System">OS</abbr> X, the preferences are saved as XML file under:<br>
  766. <code>$HOME/Library/Preferences/com.foo.mycoolgame3.plist</code></p>
  767. </li>
  768. </ul>
  769. </div>
  770. </div>
  771. </div>
  772. </article>
  773. <aside class="toc sidebar" data-title="Contents" data-levels="2">
  774. <div class="toc-menu"></div>
  775. </aside>
  776. </div>
  777. </main>
  778. </div>
  779. <footer class="footer">
  780. <p>Copyright 2020 jMonkeyEngine Wiki Contributors. Licensed BSD-3.</p>
  781. </footer>
  782. <script src="../../../_/js/vendor/docsearch.min.js"></script>
  783. <!-- fetched from https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js -->
  784. <script>
  785. var search = docsearch({
  786. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  787. indexName: 'jmonkeyengine',
  788. inputSelector: '#search-input',
  789. autocompleteOptions: { hint: false, keyboardShortcuts: ['s'] },
  790. algoliaOptions: { hitsPerPage: 10 }
  791. }).autocomplete
  792. search.on('autocomplete:closed', function () { search.autocomplete.setVal() })
  793. function focusSearchInput () { document.querySelector('#search-input').focus() }
  794. if (document.querySelector('.home-link.is-current')) window.addEventListener('load', focusSearchInput)
  795. </script>
  796. <script src="../../../_/js/site.js"></script>
  797. <script async src="../../../_/js/vendor/highlight.js"></script>
  798. </body>
  799. </html>