Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: samples/o3d-webgl/param.js

Issue 1092003: Fixed a lot of bugs with render surfaces and bitmaps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/o3d-webgl/pack.js ('k') | samples/o3d-webgl/primitive.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/o3d-webgl/param.js
===================================================================
--- samples/o3d-webgl/param.js (revision 41482)
+++ samples/o3d-webgl/param.js (working copy)
@@ -749,16 +749,29 @@
};
/**
+ * A counter to ensure each texture sampler gets a unqiue id.
+ * @private
+ */
+o3d.Param.texture_index_ = 0;
+
+/**
* Called to specify the value of a uniform variable.
*/
o3d.ParamSampler.prototype.applyToLocation = function(gl, location) {
- var i = 0;
+ // When before the effect object assigns values to parameters,
+ // it sets this variable to 0.
+ var i = o3d.Param.texture_index_;
gl.activeTexture(gl.TEXTURE0 + i);
- if (!this.value || !this.value.texture || !this.value.texture.texture_) {
- throw ('Attempt to use texture parameter before texture value set.');
+
+ var value = null;
+
+ if (this.value && this.value.texture && this.value.texture.texture_) {
+ value = this.value.texture.texture_;
}
- gl.bindTexture(gl.TEXTURE_2D, this.value.texture.texture_);
+
+ gl.bindTexture(gl.TEXTURE_2D, value);
gl.uniform1i(location, i);
+ o3d.Param.texture_index_++;
};
« no previous file with comments | « samples/o3d-webgl/pack.js ('k') | samples/o3d-webgl/primitive.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698