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

Side by Side Diff: samples/o3d-webgl/pack.js

Issue 1745002: Incremental progress toward archive loading in o3d-webgl. Implemented... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/o3d/
Patch Set: Created 10 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/o3d-webgl/file_request.js ('k') | samples/o3d-webgl/param_object.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 * Matrix4Translation 164 * Matrix4Translation
165 * ParamOp2FloatsToFloat2 165 * ParamOp2FloatsToFloat2
166 * ParamOp3FloatsToFloat3 166 * ParamOp3FloatsToFloat3
167 * ParamOp4FloatsToFloat4 167 * ParamOp4FloatsToFloat4
168 * ParamOp16FloatsToMatrix4 168 * ParamOp16FloatsToMatrix4
169 * TRSToMatrix4 169 * TRSToMatrix4
170 * @return {o3d.ObjectBase} The created object. 170 * @return {o3d.ObjectBase} The created object.
171 */ 171 */
172 o3d.Pack.prototype.createObject = 172 o3d.Pack.prototype.createObject =
173 function(type_name) { 173 function(type_name) {
174 var foo = o3d.global.o3d[type_name]; 174 var foo = o3d.global.o3d[o3d.filterTypeName_(type_name)];
175 if (typeof foo != 'function') { 175 if (typeof foo != 'function') {
176 throw 'cannot find type in o3d namespace: ' + type_name 176 throw 'cannot find type in o3d namespace: ' + type_name
177 } 177 }
178 var object = new foo(); 178 var object = new foo();
179 object.gl = this.gl; 179 object.gl = this.gl;
180 this.objects_.push(object); 180 this.objects_.push(object);
181 return object; 181 return object;
182 }; 182 };
183 183
184 184
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return texture; 225 return texture;
226 }; 226 };
227 227
228 228
229 /** 229 /**
230 * Creates a new TextureCUBE object of the specified size and format and 230 * Creates a new TextureCUBE object of the specified size and format and
231 * reserves the necessary resources for it. 231 * reserves the necessary resources for it.
232 * Note: If enable_render_surfaces is true, then the dimensions must be a 232 * Note: If enable_render_surfaces is true, then the dimensions must be a
233 * power of two. 233 * power of two.
234 * 234 *
235 * @param {number} edge_length The edge of the texture area in texels 235 * @param {number} edgeLength The edge of the texture area in texels
236 * (max = 2048) 236 * (max = 2048)
237 * @param {o3d.Texture.Format} format The memory format of each texel. 237 * @param {o3d.Texture.Format} format The memory format of each texel.
238 * @param {number} levels The number of mipmap levels. Use zero to create 238 * @param {number} levels The number of mipmap levels. Use zero to create
239 * the compelete mipmap chain. 239 * the compelete mipmap chain.
240 * @param {boolean} enable_render_surfaces If true, the texture object 240 * @param {boolean} enableRenderSurfaces If true, the texture object
241 * will expose RenderSurface objects through GetRenderSurface(...). 241 * will expose RenderSurface objects through GetRenderSurface(...).
242 * @return {!o3d.TextureCUBE} The TextureCUBE object. 242 * @return {!o3d.TextureCUBE} The TextureCUBE object.
243 */ 243 */
244 o3d.Pack.prototype.createTextureCUBE = 244 o3d.Pack.prototype.createTextureCUBE =
245 function(edge_length, format, levels, enable_render_surfaces) { 245 function(edgeLength, format, levels, enableRenderSurfaces) {
246 o3d.notImplemented(); 246 var texture = this.createObject('TextureCUBE');
247 texture.edgeLength = edgeLength;
248 texture.texture_ = this.gl.createTexture();
249
250 this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, texture.texture_);
251 for (var ii = 0; ii < 6; ++ii) {
252 this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X + ii,
253 0, this.gl.RGBA, edgeLength, edgeLength, 0,
254 this.gl.RGBA, this.gl.UNSIGNED_BYTE, null);
255 }
256 this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,
257 this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
258 this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,
259 this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
260 this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,
261 this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
262 this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,
263 this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
264
265 return texture;
247 }; 266 };
248 267
249 268
250 /** 269 /**
251 * Creates a new RenderDepthStencilSurface object of a format suitable for use 270 * Creates a new RenderDepthStencilSurface object of a format suitable for use
252 * as a depth-stencil render target. 271 * as a depth-stencil render target.
253 * Note: The dimensions of the RenderDepthStencilSurface must be a power of 272 * Note: The dimensions of the RenderDepthStencilSurface must be a power of
254 * two. 273 * two.
255 * 274 *
256 * @param {number} width The width of the RenderSurface in pixels 275 * @param {number} width The width of the RenderSurface in pixels
(...skipping 16 matching lines...) Expand all
273 * will affect them. 292 * will affect them.
274 * 293 *
275 * @param {string} name Name to look for 294 * @param {string} name Name to look for
276 * @param {string} class_type_name the Class of the object. It is okay 295 * @param {string} class_type_name the Class of the object. It is okay
277 * to pass base types for example "o3d.RenderNode" will return 296 * to pass base types for example "o3d.RenderNode" will return
278 * ClearBuffers, DrawPasses, etc... 297 * ClearBuffers, DrawPasses, etc...
279 * @return {!Array.<!o3d.ObjectBase>} Array of Objects. 298 * @return {!Array.<!o3d.ObjectBase>} Array of Objects.
280 */ 299 */
281 o3d.Pack.prototype.getObjects = 300 o3d.Pack.prototype.getObjects =
282 function(name, class_type_name) { 301 function(name, class_type_name) {
283 if (class_type_name.substr(0, 4) == 'o3d.') { 302 class_type_name = o3d.filterTypeName_(class_type_name);
284 class_type_name = class_type_name.substr(4);
285 }
286 303
287 var found = []; 304 var found = [];
288 305
289 for (var i = 0; i < this.objects_.length; ++i) { 306 for (var i = 0; i < this.objects_.length; ++i) {
290 var object = this.objects_[i]; 307 var object = this.objects_[i];
291 if (object.isAClassName(class_type_name) && 308 if (object.isAClassName(class_type_name) &&
292 object.name == name) { 309 object.name == name) {
293 found.push(object); 310 found.push(object);
294 } 311 }
295 } 312 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 * load a texture is to load a RawData, use that to create Bitmap, Massage 371 * load a texture is to load a RawData, use that to create Bitmap, Massage
355 * the Bitmap to your liking the use that to create a Texture. 372 * the Bitmap to your liking the use that to create a Texture.
356 * @param {string} type Must be "TEXTURE" or "RAWDATA" 373 * @param {string} type Must be "TEXTURE" or "RAWDATA"
357 * @return {!o3d.FileRequest} a FileRequest 374 * @return {!o3d.FileRequest} a FileRequest
358 */ 375 */
359 o3d.Pack.prototype.createFileRequest = 376 o3d.Pack.prototype.createFileRequest =
360 function(type) { 377 function(type) {
361 return this.createObject('FileRequest'); 378 return this.createObject('FileRequest');
362 }; 379 };
363 380
381 /**
382 * Creates an ArchiveRequest so we can stream in assets from an archive.
383 * @return {!o3d.ArchiveRequest} an ArchiveRequest
384 */
385 o3d.Pack.prototype.createArchiveRequest =
386 function() {
387 return this.createObject('ArchiveRequest');
388 };
364 389
365 /** 390 /**
366 * Create Bitmaps from RawData. 391 * Create Bitmaps from RawData.
367 * 392 *
368 * If you load a cube map you'll get an array of 6 Bitmaps. 393 * If you load a cube map you'll get an array of 6 Bitmaps.
369 * If you load a volume map you'll get an array of n Bitmaps. 394 * If you load a volume map you'll get an array of n Bitmaps.
370 * If there is an error you'll get an empty array. 395 * If there is an error you'll get an empty array.
371 * 396 *
372 * @param {!o3d.RawData} raw_data contains the bitmap data in a supported 397 * @param {!o3d.RawData} raw_data contains the bitmap data in a supported
373 * format. 398 * format.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 /** 432 /**
408 * Create RawData given a data URL. 433 * Create RawData given a data URL.
409 * @param {string} data_url The data URL from which to create the RawData. 434 * @param {string} data_url The data URL from which to create the RawData.
410 * @return {!o3d.RawData} The RawData. 435 * @return {!o3d.RawData} The RawData.
411 */ 436 */
412 o3d.Pack.prototype.createRawDataFromDataURL = 437 o3d.Pack.prototype.createRawDataFromDataURL =
413 function(data_url) { 438 function(data_url) {
414 o3d.notImplemented(); 439 o3d.notImplemented();
415 }; 440 };
416 441
OLDNEW
« no previous file with comments | « samples/o3d-webgl/file_request.js ('k') | samples/o3d-webgl/param_object.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698