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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 o3djs.require('o3djs.primitives'); | 48 o3djs.require('o3djs.primitives'); |
49 o3djs.require('o3djs.effect'); | 49 o3djs.require('o3djs.effect'); |
50 | 50 |
51 // global variables | 51 // global variables |
52 var g_o3d; | 52 var g_o3d; |
53 var g_math; | 53 var g_math; |
54 var g_client; | 54 var g_client; |
55 var g_pack; | 55 var g_pack; |
56 var g_viewInfo; | 56 var g_viewInfo; |
57 var g_finished = false; // for selenium testing | 57 var g_finished = false; // for selenium testing |
| 58 var g_samplers = []; |
58 | 59 |
59 /** | 60 /** |
60 * Creates the client area. | 61 * Creates the client area. |
61 */ | 62 */ |
62 function init() { | 63 function init() { |
63 // Comment out the line below to run the sample in the browser | 64 // Comment out the line below to run the sample in the browser |
64 // JavaScript engine. This may be helpful for debugging. | 65 // JavaScript engine. This may be helpful for debugging. |
65 o3djs.util.setMainEngine(o3djs.util.Engine.V8); | 66 o3djs.util.setMainEngine(o3djs.util.Engine.V8); |
66 | 67 |
67 o3djs.util.makeClients(initStep2, 'FloatingPointTextures'); | 68 o3djs.util.makeClients(initStep2, 'FloatingPointTextures'); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 transform.parent = g_client.root; | 154 transform.parent = g_client.root; |
154 | 155 |
155 // Create a ParamSampler on the transform with the same name as in | 156 // Create a ParamSampler on the transform with the same name as in |
156 // the effect so this param will be used instead of the one on the material. | 157 // the effect so this param will be used instead of the one on the material. |
157 var samplerParam = transform.createParam('texSampler0', 'ParamSampler'); | 158 var samplerParam = transform.createParam('texSampler0', 'ParamSampler'); |
158 | 159 |
159 var sampler = g_pack.createObject('Sampler'); | 160 var sampler = g_pack.createObject('Sampler'); |
160 samplerParam.value = sampler; | 161 samplerParam.value = sampler; |
161 sampler.addressModeU = g_o3d.Sampler.CLAMP; | 162 sampler.addressModeU = g_o3d.Sampler.CLAMP; |
162 sampler.addressModeV = g_o3d.Sampler.CLAMP; | 163 sampler.addressModeV = g_o3d.Sampler.CLAMP; |
| 164 g_samplers[s] = sampler; |
163 | 165 |
164 // Create a texture. | 166 // Create a texture. |
165 { | 167 { |
166 var pixels = []; | 168 var pixels = []; |
167 var format; | 169 var format; |
168 | 170 |
169 switch (s) { | 171 switch (s) { |
170 case 0: { // XRGB8 | 172 case 0: { // XRGB8 |
171 transform.addShape(effectInfos.texture_only.shape); | 173 transform.addShape(effectInfos.texture_only.shape); |
172 format = g_o3d.Texture.XRGB8; | 174 format = g_o3d.Texture.XRGB8; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 } | 264 } |
263 } | 265 } |
264 break; | 266 break; |
265 } | 267 } |
266 } | 268 } |
267 var texture = g_pack.createTexture2D(32, 32, format, 1, false); | 269 var texture = g_pack.createTexture2D(32, 32, format, 1, false); |
268 texture.set(0, pixels); | 270 texture.set(0, pixels); |
269 sampler.texture = texture; | 271 sampler.texture = texture; |
270 } | 272 } |
271 } | 273 } |
| 274 window.o3d_prepForSelenium = prepForSelenium; |
272 window.g_finished = true; // for selenium testing. | 275 window.g_finished = true; // for selenium testing. |
273 } | 276 } |
274 | 277 |
| 278 // Turn off all filtering in the samplers to get consistent testing |
| 279 // results. |
| 280 function prepForSelenium() { |
| 281 for (var i = 0; i < g_samplers.length; i++) { |
| 282 g_samplers[i].magFilter = g_o3d.Sampler.POINT; |
| 283 g_samplers[i].minFilter = g_o3d.Sampler.POINT; |
| 284 g_samplers[i].mipFilter = g_o3d.Sampler.NONE; |
| 285 } |
| 286 } |
| 287 |
| 288 |
275 </script> | 289 </script> |
276 </head> | 290 </head> |
277 <body onload="init()"> | 291 <body onload="init()"> |
278 <h1>Generate Texture</h1> | 292 <h1>Generate Texture</h1> |
279 Shows how to create textures in Javascript. | 293 Shows how to create textures in Javascript. |
280 <br/> | 294 <br/> |
281 | 295 |
282 <!-- Start of O3D plugin --> | 296 <!-- Start of O3D plugin --> |
283 <div id="o3d" style="width: 600px; height: 600px;"></div> | 297 <div id="o3d" style="width: 600px; height: 600px;"></div> |
284 <!-- End of O3D plugin --> | 298 <!-- End of O3D plugin --> |
285 </body> | 299 </body> |
286 </html> | 300 </html> |
OLD | NEW |