| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 case o3d.Sampler.LINEAR: | 243 case o3d.Sampler.LINEAR: |
| 244 case o3d.Sampler.ANISOTROPIC: | 244 case o3d.Sampler.ANISOTROPIC: |
| 245 return this.gl.LINEAR; | 245 return this.gl.LINEAR; |
| 246 } | 246 } |
| 247 this.gl.client.error_callback("Unknown filter."); | 247 this.gl.client.error_callback("Unknown filter."); |
| 248 return this.gl.LINEAR; | 248 return this.gl.LINEAR; |
| 249 } | 249 } |
| 250 | 250 |
| 251 | 251 |
| 252 /** | 252 /** |
| 253 * A default Sampler that has no texture, thus uses the client's error texture. |
| 254 * |
| 255 * @type {!o3d.Sampler} |
| 256 * @private |
| 257 */ |
| 258 o3d.Sampler.defaultSampler_ = new o3d.Sampler(); |
| 259 o3d.Sampler.defaultSampler_.magFilter = o3d.Sampler.POINT; |
| 260 |
| 261 /** |
| 253 * Binds the texture for this sampler and sets texParameters according to the | 262 * Binds the texture for this sampler and sets texParameters according to the |
| 254 * states of the sampler. | 263 * states of the sampler. |
| 255 */ | 264 */ |
| 256 o3d.Sampler.prototype.bindAndSetParameters_ = function() { | 265 o3d.Sampler.prototype.bindAndSetParameters_ = function() { |
| 266 var currentTexture = null; |
| 257 if (this.texture) { | 267 if (this.texture) { |
| 258 var mip_filter = this.mipFilter; | 268 currentTexture = this.texture; |
| 259 if (this.texture.levels == 1) { | 269 } else if (!this.gl.client.reportErrors_()) { |
| 260 mip_filter = o3d.Sampler.NONE; | 270 currentTexture = this.gl.client.error_texture_; |
| 261 } | 271 } else { |
| 272 currentTexture = this.gl.client.fallback_error_texture_; |
| 273 this.gl.client.error_callback("Missing texture for sampler " + this.name); |
| 274 } |
| 262 | 275 |
| 263 this.texture.bindAndSetParameters_( | 276 var mip_filter = this.mipFilter; |
| 264 this.convertAddressMode_(this.addressModeU), | 277 if (currentTexture.levels == 1) { |
| 265 this.convertAddressMode_(this.addressModeV), | 278 mip_filter = o3d.Sampler.NONE; |
| 266 this.convertMinFilter_(this.minFilter, mip_filter), | |
| 267 this.convertMagFilter_(this.magFilter)); | |
| 268 } else { | |
| 269 this.gl.client.error_callback("Sampler used with no texture set."); | |
| 270 return; | |
| 271 } | 279 } |
| 280 currentTexture.bindAndSetParameters_( |
| 281 this.convertAddressMode_(this.addressModeU), |
| 282 this.convertAddressMode_(this.addressModeV), |
| 283 this.convertMinFilter_(this.minFilter, mip_filter), |
| 284 this.convertMagFilter_(this.magFilter)); |
| 272 } | 285 } |
| 273 | 286 |
| OLD | NEW |