| Index: samples/o3d-webgl/texture.js
|
| ===================================================================
|
| --- samples/o3d-webgl/texture.js (revision 45777)
|
| +++ samples/o3d-webgl/texture.js (working copy)
|
| @@ -281,6 +281,7 @@
|
| 0, // Level.
|
| bitmap.canvas_,
|
| bitmap.defer_flip_vertically_to_texture_);
|
| + this.setupRepeatModes_(bitmap.canvas_.width, bitmap.canvas_.height);
|
| if (bitmap.defer_mipmaps_to_texture_) {
|
| this.generateMips();
|
| }
|
| @@ -288,6 +289,39 @@
|
|
|
|
|
| /**
|
| + * Sets up the repeat modes for the given width and height.
|
| + * Assumes the texture is already bound to the TEXTURE_2D binding point.
|
| + * @private
|
| + */
|
| +o3d.Texture2D.prototype.setupRepeatModes_ = function(width, height) {
|
| + // OpenGL ES 2.0 and consequently WebGL don't support anything but
|
| + // CLAMP_TO_EDGE for NPOT textures.
|
| + if (o3d.Texture2D.isPowerOfTwo_(width) &&
|
| + o3d.Texture2D.isPowerOfTwo_(height)) {
|
| + this.gl.texParameteri(this.gl.TEXTURE_2D,
|
| + this.gl.TEXTURE_WRAP_S, this.gl.REPEAT);
|
| + this.gl.texParameteri(this.gl.TEXTURE_2D,
|
| + this.gl.TEXTURE_WRAP_T, this.gl.REPEAT);
|
| + } else {
|
| + this.gl.texParameteri(this.gl.TEXTURE_2D,
|
| + this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
|
| + this.gl.texParameteri(this.gl.TEXTURE_2D,
|
| + this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
|
| + }
|
| +};
|
| +
|
| +/**
|
| + * Indicates whether the given number is a power of two.
|
| + * @private
|
| + */
|
| +o3d.Texture2D.isPowerOfTwo_ = function(value) {
|
| + if (value == undefined)
|
| + return false;
|
| + return (value & (value - 1)) == 0;
|
| +};
|
| +
|
| +
|
| +/**
|
| * Copy pixels from source bitmap to certain mip level.
|
| * Scales if the width and height of source and dest do not match.
|
| * TODO(petersont): Takes optional arguments.
|
|
|