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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 // Creates a transform to put our data on. | 310 // Creates a transform to put our data on. |
311 g_root = g_pack.createObject('Transform'); | 311 g_root = g_pack.createObject('Transform'); |
312 | 312 |
313 // Connects our root to the client's root. | 313 // Connects our root to the client's root. |
314 g_root.parent = g_client.root; | 314 g_root.parent = g_client.root; |
315 | 315 |
316 var paramObject = g_pack.createObject('ParamObject'); | 316 var paramObject = g_pack.createObject('ParamObject'); |
317 g_currentTimeParam = paramObject.createParam('timeParam','ParamFloat'); | 317 g_currentTimeParam = paramObject.createParam('timeParam','ParamFloat'); |
318 | 318 |
319 // Load effects and fill out options. | 319 // Load effects and fill out options. |
320 options = '' | 320 options = '<select id="shaderSelect" name="shaderSelect"' + |
| 321 ' onChange="changeShader()">' |
321 for(var s = 0; s < g_shaders.length; s++) { | 322 for(var s = 0; s < g_shaders.length; s++) { |
322 g_effects[s] = g_pack.createObject('Effect'); | 323 g_effects[s] = g_pack.createObject('Effect'); |
323 var shaderString = 'shaders/' + g_shaders[s].file + '.shader'; | 324 var shaderString = 'shaders/' + g_shaders[s].file + '.shader'; |
324 o3djs.effect.loadEffect(g_effects[s], shaderString); | 325 o3djs.effect.loadEffect(g_effects[s], shaderString); |
325 options += '<option value="' + s + '"' + (s == 0 ? ' selected' : '') + | 326 options += '<option value="' + s + '"' + (s == 0 ? ' selected' : '') + |
326 '>' + g_shaders[s].name + '</option>'; | 327 '>' + g_shaders[s].name + '</option>'; |
327 } | 328 } |
328 document.getElementById('shaderSelect').innerHTML = options; | 329 options += '</select>'; |
| 330 document.getElementById('shaderDiv').innerHTML = options; |
329 | 331 |
330 var rampWidth = 64; | 332 var rampWidth = 64; |
331 var texture = g_pack.createTexture2D( | 333 var texture = g_pack.createTexture2D( |
332 rampWidth, 1, g_o3d.Texture.XRGB8, 1, false); | 334 rampWidth, 1, g_o3d.Texture.XRGB8, 1, false); |
333 var pixels = []; | 335 var pixels = []; |
334 for (var ii = 0; ii < rampWidth; ++ii) { | 336 for (var ii = 0; ii < rampWidth; ++ii) { |
335 var level = ii > rampWidth * 0.5 ? 1 : 0.3; | 337 var level = ii > rampWidth * 0.5 ? 1 : 0.3; |
336 pixels.push(level, level, level); | 338 pixels.push(level, level, level); |
337 } | 339 } |
338 texture.set(0, pixels); | 340 texture.set(0, pixels); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 </script> | 401 </script> |
400 </head> | 402 </head> |
401 <body> | 403 <body> |
402 <h1>Shader Test</h1> | 404 <h1>Shader Test</h1> |
403 This example is useful for testing a shader or checking a scene. Clicking on the
scene will temporarily stop rotation. | 405 This example is useful for testing a shader or checking a scene. Clicking on the
scene will temporarily stop rotation. |
404 <br/> | 406 <br/> |
405 <!-- Start of O3D plugin --> | 407 <!-- Start of O3D plugin --> |
406 <div id="o3d" style="width: 100%; height: 80%;"></div> | 408 <div id="o3d" style="width: 100%; height: 80%;"></div> |
407 <!-- End of O3D plugin --> | 409 <!-- End of O3D plugin --> |
408 <p> | 410 <p> |
409 <select id='shaderSelect' name='shaderSelect' onChange='changeShader()'> | 411 <div id='shaderDiv'></div> |
410 </select> | |
411 </body> | 412 </body> |
412 </html> | 413 </html> |
OLD | NEW |