copyteximage2D 在状态机方面

copyteximage2D in terms of state machine

我不知道 copyteximage2D 是如何工作的, 我想要一个关于 webgl 状态机的解释:

多亏了 gman 我有了这个 :

gl = { 
    activeTextureUnit: 0,
    textureUnits: [],
};

gl.activeTexture = function(unit) {
    this.activeTextureUnit = unit - this.TEXTURE_0;  
};

gl.bindTexture = function(bindPoint, texture) {
    var textureUnit = this.textureUnits[this.activeTextureUnit];
    switch (bindPoint) {
       case this.TEXTURE_2D:
         textureUnit.texture2D = texture;
         break;
       case ....
    }
};
gl.copyTexImage2D = function( target, level, iformat, x, y, w,h,b) {
.....
..... gman please your code here thanks very much!!!
.....
}

copyTexImage2D 从当前帧缓冲区或canvas 复制到当前纹理单元的给定目标

gl = {
  activeTextureUnit: 0,
  textureUnits: [
    { gl.TEXTURE_2D: null, gl.TEXTURE_CUBE_MAP: null, ... },
    { gl.TEXTURE_2D: null, gl.TEXTURE_CUBE_MAP: null, ... },
    { gl.TEXTURE_2D: null, gl.TEXTURE_CUBE_MAP: null, ... },
    { gl.TEXTURE_2D: null, gl.TEXTURE_CUBE_MAP: null, ... },
    ...
  ],
  framebufferBindPoints: {
    gl.FRAMEBUFFER: gl.canvas.internalFramebuffer,
  },
};

gl.bindFramebuffer = function(bindPoint, framebuffer) {
  this.framebufferBindPoints[bindPoint] = 
     framebuffer ? framebuffer : gl.canvas.internalFramebuffer;
}; 

gl.copyTexImage2D = function( target, level, iformat, x, y, w,h,b) {
  var textureUnit = this.textureUnits[this.activeTextureUnit];
  var texture = textureUnit[target];
  var framebuffer = this.framebufferBindPoints[gl.FRAMEBUFFER];
  // copy from framebuffer into texture
}