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

Side by Side Diff: samples/o3d-webgl/client.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/o3d-webgl/buffer.js ('k') | samples/o3d-webgl/draw_list.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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 /** 473 /**
474 * Whether content is displayed in full-screen mode or in a plugin window. The 474 * Whether content is displayed in full-screen mode or in a plugin window. The
475 * default is false [not full-screen]. 475 * default is false [not full-screen].
476 * @type {boolean} 476 * @type {boolean}
477 */ 477 */
478 o3d.Client.prototype.fullscreen = false; 478 o3d.Client.prototype.fullscreen = false;
479 479
480 480
481 /** 481 /**
482 * Whether content is displayed in full-screen mode or in a plugin window. The
483 * default is false [not full-screen].
484 * @type {!Array<function(!o3d.Event): void>}
485 */
486 o3d.Client.prototype.event_callbacks_ = [];
487
488
489 /**
482 * Returns the width of the current drawing area [plugin or full-screen] in 490 * Returns the width of the current drawing area [plugin or full-screen] in
483 * pixels. 491 * pixels.
484 */ 492 */
485 o3d.Client.prototype.__defineGetter__('width', 493 o3d.Client.prototype.__defineGetter__('width',
486 function() { 494 function() {
487 return this.gl.canvas.width; 495 return this.gl.canvas.width;
488 } 496 }
489 ); 497 );
490 498
491 o3d.Client.prototype.__defineSetter__('width', 499 o3d.Client.prototype.__defineSetter__('width',
(...skipping 19 matching lines...) Expand all
511 } 519 }
512 ); 520 );
513 521
514 522
515 /** 523 /**
516 * Initializes this client using the canvas. 524 * Initializes this client using the canvas.
517 * @param {Canvas} 525 * @param {Canvas}
518 */ 526 */
519 o3d.Client.prototype.initWithCanvas = function(canvas) { 527 o3d.Client.prototype.initWithCanvas = function(canvas) {
520 var gl; 528 var gl;
521 try {gl = canvas.getContext("experimental-webgl") } catch(e) { } 529
530 var standard_attributes = {
531 alpha : true,
532 depth : true,
533 stencil : true,
534 antialias : true,
535 premultipliedAlpha : true
536 };
537
538 try {gl = canvas.getContext("experimental-webgl", standard_attributes) } catch (e) { }
522 if (!gl) 539 if (!gl)
523 try {gl = canvas.getContext("moz-webgl") } catch(e) { } 540 try {gl = canvas.getContext("moz-webgl") } catch(e) { }
524 if (!gl) { 541 if (!gl) {
525 alert("No WebGL context found"); 542 alert("No WebGL context found");
526 return null; 543 return null;
527 } 544 }
528 545
529 canvas.client.gl = gl; 546 this.gl = gl;
547
530 gl.client = this; 548 gl.client = this;
531 gl.displayInfo = {width: canvas.width, 549 gl.displayInfo = {width: canvas.width,
532 height: canvas.height}; 550 height: canvas.height};
533 }; 551 };
534 552
535 553
536 /** 554 /**
537 * Sets the per frame render callback. 555 * Sets the per frame render callback.
538 * 556 *
539 * Note: The callback will not be called recursively. When your callback is 557 * Note: The callback will not be called recursively. When your callback is
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 * Sets a callback for a given event type. 651 * Sets a callback for a given event type.
634 * types. 652 * types.
635 * There can be only one callback for a given event type at a time; setting a 653 * There can be only one callback for a given event type at a time; setting a
636 * new one deletes the old one. 654 * new one deletes the old one.
637 * 655 *
638 * @param {string} type Type of event to set callback for. 656 * @param {string} type Type of event to set callback for.
639 * @param {!o3d.EventCallback} handler Function to call on event. 657 * @param {!o3d.EventCallback} handler Function to call on event.
640 */ 658 */
641 o3d.Client.prototype.setEventCallback = 659 o3d.Client.prototype.setEventCallback =
642 function(type, handler) { 660 function(type, handler) {
643 this.eventCallbacks[type] = handler; 661 this.event_callbacks_[type] = handler;
644 }; 662 };
645 663
646 664
647 /** 665 /**
648 * Removes the previously-registered callback for an event of the given type. 666 * Removes the previously-registered callback for an event of the given type.
649 * @param {string} type Type of event to clear callback for. 667 * @param {string} type Type of event to clear callback for.
650 */ 668 */
651 o3d.Client.prototype.clearEventCallback = 669 o3d.Client.prototype.clearEventCallback =
652 function(type) { 670 function(type) {
653 this.eventCallbacks[type] = null; 671 this.event_callbacks_[type] = null;
654 }; 672 };
655 673
656 674
657 /** 675 /**
658 * Sets the texture to use when a Texture or Sampler is missing while 676 * Sets the texture to use when a Texture or Sampler is missing while
659 * rendering. The default is a red texture with a yellow no symbol. 677 * rendering. The default is a red texture with a yellow no symbol.
660 * <span style="color:yellow; background-color: red;">&Oslash;. 678 * <span style="color:yellow; background-color: red;">&Oslash;.
661 * If you set it to null you'll get an error if you try to render something 679 * If you set it to null you'll get an error if you try to render something
662 * that is missing a needed Texture, Sampler or ParamSampler. 680 * that is missing a needed Texture, Sampler or ParamSampler.
663 * 681 *
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 878
861 879
862 880
863 /** 881 /**
864 * The canvas associated with this client. 882 * The canvas associated with this client.
865 * @type {Element} 883 * @type {Element}
866 */ 884 */
867 o3d.Client.prototype.canvas = null; 885 o3d.Client.prototype.canvas = null;
868 886
869 887
OLDNEW
« no previous file with comments | « samples/o3d-webgl/buffer.js ('k') | samples/o3d-webgl/draw_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698