summaryrefslogtreecommitdiffstats
path: root/o3d/samples/o3djs/io.js
diff options
context:
space:
mode:
authorgman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 00:07:49 +0000
committergman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-19 00:07:49 +0000
commit8653167fd370f88b3bcc2be052a9aa26873dbe44 (patch)
tree602e188104e6d3992adac469f17d5c1605690f73 /o3d/samples/o3djs/io.js
parentc1b7f06be387b3828d38eccbf0e88d1ec71bac3b (diff)
downloadchromium_src-8653167fd370f88b3bcc2be052a9aa26873dbe44.zip
chromium_src-8653167fd370f88b3bcc2be052a9aa26873dbe44.tar.gz
chromium_src-8653167fd370f88b3bcc2be052a9aa26873dbe44.tar.bz2
expose Bitmap to JavaScript.
Also added Texture.drawImage(canvas...) There's still the big question of whether we should flip textures by default in the o3d code. Currently I'm flipping them by default in o3djs.texture.createTextureFromRawData and I'm flipping them by default in o3djs.canvas.CanvasQuad.updateTexture. I'm torn whether or not I should be flipping them. I feel like 2d examples and examples of displaying images, like a picasa viewer, would be simpler if we didn't flip by default but the problem then is if you load some textures through a collada scene they'll be flipped the opposite of any textures you load by hand. Review URL: http://codereview.chromium.org/171060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3djs/io.js')
-rw-r--r--o3d/samples/o3djs/io.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/o3d/samples/o3djs/io.js b/o3d/samples/o3djs/io.js
index 690bd2c..f575eff 100644
--- a/o3d/samples/o3djs/io.js
+++ b/o3d/samples/o3djs/io.js
@@ -36,6 +36,9 @@
o3djs.provide('o3djs.io');
+o3djs.require('o3djs.texture');
+
+
/**
* A Module with various io functions and classes.
* @namespace
@@ -543,11 +546,10 @@ o3djs.io.loadArchiveAdvanced = function(pack,
* texture is loaded. It will be passed the texture and an exception on
* error or null on success.
* @return {!o3djs.io.LoadInfo} A LoadInfo to track progress.
- * @see o3djs.io.createLoader
+ * @see o3djs.loader.createLoader
*/
o3djs.io.loadTexture = function(pack, url, callback) {
- // TODO: change this to get use RawData and Bitmap
- var request = pack.createFileRequest('TEXTURE');
+ var request = pack.createFileRequest('RAWDATA');
var loadInfo = o3djs.io.createLoadInfo(
/** @type {!o3d.FileRequest} */ (request),
false);
@@ -557,9 +559,13 @@ o3djs.io.loadTexture = function(pack, url, callback) {
*/
request.onreadystatechange = function() {
if (request.done) {
- var texture = request.texture;
+ var rawData = /** @type {!o3d.RawData} */ request.data;
var success = request.success;
var exception = request.error;
+ var texture = null;
+ if (success) {
+ texture = o3djs.texture.createTextureFromRawData(pack, rawData, true);
+ }
loadInfo.finish();
pack.removeObject(request);
if (!success && !exception) {
@@ -572,4 +578,3 @@ o3djs.io.loadTexture = function(pack, url, callback) {
return loadInfo;
};
-