diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 02:35:20 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-28 02:35:20 +0000 |
commit | 86aa005b33fb99dbeb02bc38c84de1012d685418 (patch) | |
tree | 855cd2288af7ef5923ab66055f9d57daf0654f13 /o3d/samples | |
parent | 4c2dbaa9f8fe2de83ae4ddc259e9eae35714603a (diff) | |
download | chromium_src-86aa005b33fb99dbeb02bc38c84de1012d685418.zip chromium_src-86aa005b33fb99dbeb02bc38c84de1012d685418.tar.gz chromium_src-86aa005b33fb99dbeb02bc38c84de1012d685418.tar.bz2 |
These changes are needed for when we turn on REAL
OpenGL ES 2.0 GLSL and for the new texImage2D
TBR=petersont@google.com
Review URL: http://codereview.chromium.org/3035012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@53898 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples')
-rw-r--r-- | o3d/samples/o3d-webgl/effect.js | 4 | ||||
-rw-r--r-- | o3d/samples/o3d-webgl/texture.js | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/o3d/samples/o3d-webgl/effect.js b/o3d/samples/o3d-webgl/effect.js index 93932b0..65da4a3 100644 --- a/o3d/samples/o3d-webgl/effect.js +++ b/o3d/samples/o3d-webgl/effect.js @@ -204,9 +204,9 @@ o3d.Effect.prototype.loadShaderFromString = function(shaderString, type) { var success = true; var shader = this.gl.createShader(type); - this.gl.shaderSource(shader, shaderString); + this.gl.shaderSource( + shader, "#ifdef GL_ES\nprecision highp float;\n#endif\n" + shaderString); this.gl.compileShader(shader); - if (!this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS)) { success = false; var log = this.gl.getShaderInfoLog(shader); diff --git a/o3d/samples/o3d-webgl/texture.js b/o3d/samples/o3d-webgl/texture.js index cfc7b77..176ca0e 100644 --- a/o3d/samples/o3d-webgl/texture.js +++ b/o3d/samples/o3d-webgl/texture.js @@ -225,7 +225,8 @@ o3d.Texture.prototype.getGLTextureFormat_ = function() { */ o3d.Texture.prototype.setFromCanvas_ = function(canvas, resize_to_pot, flip, generate_mips, face) { - this.gl.bindTexture(this.texture_target_, this.texture_); + var gl = this.gl; + gl.bindTexture(this.texture_target_, this.texture_); if (resize_to_pot && (!o3d.Texture.isPowerOfTwo_(canvas.width) || !o3d.Texture.isPowerOfTwo_(canvas.height))) { @@ -246,7 +247,10 @@ o3d.Texture.prototype.setFromCanvas_ = target = this.gl.TEXTURE_CUBE_MAP_POSITIVE_X + face; } - this.gl.texImage2D(target, 0 /*level*/, canvas, flip); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flip); + gl.texImage2D( + target, 0 /*level*/, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0); this.texture_width_ = canvas.width; this.texture_height_ = canvas.height; @@ -498,10 +502,12 @@ o3d.Texture2D.prototype.drawImage = context.drawImage(source_img.canvas_, 0, 0, source_img.canvas_.width, source_img.canvas_.height); - this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture_); + var gl = this.gl; + gl.bindTexture(gl.TEXTURE_2D, this.texture_); // TODO(petersont): replace this with a call to texSubImage2D once // Firefox supports it. - this.gl.texImage2D(this.gl.TEXTURE_2D, 0, canvas); + gl.texImage2D( + gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas); // this.gl.texSubImage2D(this.gl.TEXTURE_2D, 0, 0, 0, canvas); this.texture_width_ = canvas.width; this.texture_height_ = canvas.height; |