OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 2011 Apple Computer, Inc. All rights reserved. | 2 Copyright (C) 2011 Apple Computer, Inc. All rights reserved. |
3 | 3 |
4 Redistribution and use in source and binary forms, with or without | 4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions | 5 modification, are permitted provided that the following conditions |
6 are met: | 6 are met: |
7 1. Redistributions of source code must retain the above copyright | 7 1. Redistributions of source code must retain the above copyright |
8 notice, this list of conditions and the following disclaimer. | 8 notice, this list of conditions and the following disclaimer. |
9 2. Redistributions in binary form must reproduce the above copyright | 9 2. Redistributions in binary form must reproduce the above copyright |
10 notice, this list of conditions and the following disclaimer in the | 10 notice, this list of conditions and the following disclaimer in the |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 texture.image = new Image(); | 695 texture.image = new Image(); |
696 texture.image.onload = function() { doLoadImageTexture(ctx, texture.image, t
exture) } | 696 texture.image.onload = function() { doLoadImageTexture(ctx, texture.image, t
exture) } |
697 texture.image.src = url; | 697 texture.image.src = url; |
698 return texture; | 698 return texture; |
699 } | 699 } |
700 | 700 |
701 function doLoadImageTexture(ctx, image, texture) | 701 function doLoadImageTexture(ctx, image, texture) |
702 { | 702 { |
703 ctx.enable(ctx.TEXTURE_2D); | 703 ctx.enable(ctx.TEXTURE_2D); |
704 ctx.bindTexture(ctx.TEXTURE_2D, texture); | 704 ctx.bindTexture(ctx.TEXTURE_2D, texture); |
705 ctx.texImage2D(ctx.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image)
; | 705 ctx.texImage2D(ctx.TEXTURE_2D, 0, ctx.RGBA, ctx.RGBA, ctx.UNSIGNED_BYTE, ima
ge); |
706 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.LINEAR); | 706 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.LINEAR); |
707 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.LINEAR_MIPMAP_
LINEAR); | 707 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.LINEAR_MIPMAP_
LINEAR); |
708 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE); | 708 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE); |
709 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE); | 709 ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE); |
710 ctx.generateMipmap(ctx.TEXTURE_2D) | 710 ctx.generateMipmap(ctx.TEXTURE_2D) |
711 ctx.bindTexture(ctx.TEXTURE_2D, 0); | 711 ctx.bindTexture(ctx.TEXTURE_2D, 0); |
712 } | 712 } |
713 | 713 |
714 // | 714 // |
715 // Framerate object | 715 // Framerate object |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 else { | 749 else { |
750 var newTime = new Date().getTime(); | 750 var newTime = new Date().getTime(); |
751 var t = newTime - this.renderTime; | 751 var t = newTime - this.renderTime; |
752 var framerate = 1000/t; | 752 var framerate = 1000/t; |
753 this.framerates.push(framerate); | 753 this.framerates.push(framerate); |
754 while (this.framerates.length > this.numFramerates) | 754 while (this.framerates.length > this.numFramerates) |
755 this.framerates.shift(); | 755 this.framerates.shift(); |
756 this.renderTime = newTime; | 756 this.renderTime = newTime; |
757 } | 757 } |
758 } | 758 } |
OLD | NEW |