| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2009, Google Inc. | 2 Copyright 2009, Google Inc. |
| 3 All rights reserved. | 3 All rights reserved. |
| 4 | 4 |
| 5 Redistribution and use in source and binary forms, with or without | 5 Redistribution and use in source and binary forms, with or without |
| 6 modification, are permitted provided that the following conditions are | 6 modification, are permitted provided that the following conditions are |
| 7 met: | 7 met: |
| 8 | 8 |
| 9 * Redistributions of source code must retain the above copyright | 9 * Redistributions of source code must retain the above copyright |
| 10 notice, this list of conditions and the following disclaimer. | 10 notice, this list of conditions and the following disclaimer. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 o3djs.require('o3djs.math'); | 51 o3djs.require('o3djs.math'); |
| 52 o3djs.require('o3djs.rendergraph'); | 52 o3djs.require('o3djs.rendergraph'); |
| 53 o3djs.require('o3djs.camera'); | 53 o3djs.require('o3djs.camera'); |
| 54 o3djs.require('o3djs.pack'); | 54 o3djs.require('o3djs.pack'); |
| 55 o3djs.require('o3djs.scene'); | 55 o3djs.require('o3djs.scene'); |
| 56 o3djs.require('o3djs.primitives'); | 56 o3djs.require('o3djs.primitives'); |
| 57 | 57 |
| 58 // Events | 58 // Events |
| 59 // init() once the page has finished loading. | 59 // init() once the page has finished loading. |
| 60 window.onload = init; | 60 window.onload = init; |
| 61 window.onunload = uninit; |
| 61 | 62 |
| 62 // global variables | 63 // global variables |
| 63 var g_o3d; | 64 var g_o3d; |
| 64 var g_math; | 65 var g_math; |
| 65 var g_client; | 66 var g_client; |
| 66 var g_viewInfo; | 67 var g_viewInfo; |
| 67 var g_pack; | 68 var g_pack; |
| 68 var g_finished = false; // for selenium testing | 69 var g_finished = false; // for selenium testing |
| 69 var g_teapotRoot; | 70 var g_teapotRoot; |
| 70 var g_orthoRoot; | 71 var g_orthoRoot; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 bestMode = mode; | 301 bestMode = mode; |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 if (bestMode) { | 304 if (bestMode) { |
| 304 return bestMode.id; | 305 return bestMode.id; |
| 305 } else { // getDisplayModes isn't implemented on all platforms yet. | 306 } else { // getDisplayModes isn't implemented on all platforms yet. |
| 306 return g_o3d.Renderer.DISPLAY_MODE_DEFAULT; | 307 return g_o3d.Renderer.DISPLAY_MODE_DEFAULT; |
| 307 } | 308 } |
| 308 } | 309 } |
| 309 | 310 |
| 311 var timeoutId; |
| 310 function handleResizeEvent(event) { | 312 function handleResizeEvent(event) { |
| 311 // Only show the fullscreen banner if we're in plugin mode. | 313 // Only show the fullscreen banner if we're in plugin mode. |
| 312 g_orthoRoot.visible = !event.fullscreen && | 314 g_orthoRoot.visible = !event.fullscreen && |
| 313 document.getElementById("show_banner").checked; | 315 document.getElementById("show_banner").checked; |
| 314 | 316 |
| 315 setupCamera(g_teapotRoot); | 317 setupCamera(g_teapotRoot); |
| 318 |
| 319 // Set a timer to pop us back out of full-screen mode, just to show how easy |
| 320 // it is to cancel. You need a user action [a mouse click] to get into |
| 321 // full-screen mode, but you can revert back to a plugin without asking. |
| 322 if (event.fullscreen && |
| 323 document.getElementById("cancel_fullscreen").checked) { |
| 324 timeoutId = setTimeout( |
| 325 function () { |
| 326 g_client.cancelFullscreenDisplay() |
| 327 }, |
| 328 5000); |
| 329 } else { |
| 330 if (timeoutId) { |
| 331 clearTimeout(timeoutId); |
| 332 timeoutId = null; |
| 333 } |
| 334 } |
| 316 } | 335 } |
| 317 | 336 |
| 318 function updateBanner() { | 337 function updateBanner() { |
| 319 if (document.getElementById("show_banner").checked) { | 338 if (document.getElementById("show_banner").checked) { |
| 320 g_client.setFullscreenClickRegion(10, | 339 g_client.setFullscreenClickRegion(10, |
| 321 g_client.height - g_bannerTexture.height - 10, g_bannerTexture.width, | 340 g_client.height - g_bannerTexture.height - 10, g_bannerTexture.width, |
| 322 g_bannerTexture.height, getFullscreenModeId()); | 341 g_bannerTexture.height, getFullscreenModeId()); |
| 323 g_orthoRoot.visible = true; | 342 g_orthoRoot.visible = true; |
| 324 } else { | 343 } else { |
| 325 g_client.clearFullscreenClickRegion(); | 344 g_client.clearFullscreenClickRegion(); |
| 326 g_orthoRoot.visible = false; | 345 g_orthoRoot.visible = false; |
| 327 } | 346 } |
| 328 } | 347 } |
| 329 | 348 |
| 349 function uninit() { |
| 350 if (timeoutId) { |
| 351 clearTimeout(timeoutId); |
| 352 timeoutId = null; |
| 353 } |
| 354 } |
| 355 |
| 330 </script> | 356 </script> |
| 331 </head> | 357 </head> |
| 332 <body> | 358 <body> |
| 333 <h1>Full-screen mode.</h1> | 359 <h1>Full-screen mode.</h1> |
| 334 This tutorial shows how to toggle between plugin and full-screen display. | 360 This tutorial shows how to toggle between plugin and full-screen display. |
| 335 <p>It's built on top of helloworld.html; diff the two to see what changes were | 361 <p>It's built on top of helloworld.html; diff the two to see what changes were |
| 336 necessary. | 362 necessary. |
| 363 <p>Shortly after transitioning to full-screen mode, the teapot will |
| 364 automatically revert back to plugin mode, to demonstrate how programs can cancel |
| 365 full-screen mode on demand. |
| 337 <br/> | 366 <br/> |
| 338 <!-- Start of O3D plugin --> | 367 <!-- Start of O3D plugin --> |
| 339 <div id="o3d" style="width: 600px; height: 600px;"></div> | 368 <div id="o3d" style="width: 600px; height: 600px;"></div> |
| 340 <!-- End of O3D plugin --> | 369 <!-- End of O3D plugin --> |
| 341 <input type="checkbox" id="show_banner" checked onclick=updateBanner()> | 370 <input type="checkbox" id="show_banner" checked onclick=updateBanner()> |
| 342 Show full-screen banner when not full-screen.</input> | 371 Show full-screen banner when not full-screen.</input> |
| 372 <br> |
| 373 <input type="checkbox" id="cancel_fullscreen" checked> |
| 374 Revert back to plugin mode automatically after a few seconds of full-screen mode
.</input> |
| 343 </body> | 375 </body> |
| 344 </html> | 376 </html> |
| OLD | NEW |