BlazorExtensions / Canvas

HTML5 Canvas API implementation for Microsoft Blazor
MIT License
620 stars 144 forks source link

8 is not a valid argument count for any overload. #106

Open nurbat opened 3 years ago

nurbat commented 3 years ago

изображение

изображение

JacobClinton commented 3 years ago

I'm pretty sure TexImage2DAsync is currently not functional. At least, if it is, I haven't been able to figure out how to use it. The only workaround I could find was to create and call a js function that gets the canvas and runs texImage2D.

function addTextureToCanvas(imgId) {
    canvas = document.getElementsByTagName("canvas");
    var gl = canvas[0].getContext("webgl");

    var image = document.getElementById(imgId);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
    //gl.generateMipmap(gl.TEXTURE_2D);
}

I hope that helps.

nurbat commented 3 years ago

it is no longer relevant, but thanks to your sources.. I was able to write an image generation based on byte [] await _context.DrawImageAsync(imagePngBytes, ImageFormat.PNG, OffsetX, OffSetY, (int)maxX, (int)maxY);

erictuvesson commented 3 years ago

The border is missing, more information here.

Duplicate Issues

Sample

await context.TexImage2DAsync(Texture2DType.TEXTURE_2D, 0, PixelFormat.RGBA, data.Width, data.Height, PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, data.Pixels);
glpMipmapViewer.prototype.texImage2D = function(original, args) {
  if (!this.textureExists(this.activeTexture)) {
    return;
  }

  if(args.length == 9 && args[8] == this.mipmapPixels && args[1] == this.currentLevel) {
    return;
  }
  // figure out which function type it's using
  var textureObj = this.textureUsage[this.activeTexture.__uuid];
  var level = args[1];
  if (args.length == 6) {
    textureObj.imageLevels.splice(level, 0, {
      functionType : this.texImage2DFcnType.TEX_IMAGE_2D_6,
      arguments : args });
  } else if (args.length == 9) {
    textureObj.imageLevels.splice(level, 0, {
      functionType : this.texImage2DFcnType.TEX_IMAGE_2D_9,
      arguments : args });
  } else {
    console.error("texImage2D function args is not valid");
    return;
  }

  textureObj.fcnUsages.push( { fcn : original, args: args } );
}