Add fallback option class (currently unused)
This commit is contained in:
parent
9fc63e5cd3
commit
7be6fb9501
32
src/ext/lib/aard/gl/FallbackCanvas.ts
Normal file
32
src/ext/lib/aard/gl/FallbackCanvas.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { GlCanvas, GlCanvasOptions } from './GlCanvas';
|
||||
|
||||
|
||||
export class FallbackCanvas extends GlCanvas {
|
||||
|
||||
context: CanvasRenderingContext2D;
|
||||
|
||||
constructor(options: GlCanvasOptions) {
|
||||
super(options);
|
||||
this.context = this.canvas.getContext('2d');
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to override the following methods in order to avoid default behaviour,
|
||||
* since these methods in GlCanvas touch some webGL properties that we cannot really
|
||||
* touch in this class.
|
||||
*/
|
||||
|
||||
destroy() { }
|
||||
|
||||
protected initWebgl() { }
|
||||
|
||||
drawVideoFrame(video: HTMLVideoElement) {
|
||||
this.context.drawImage(video, this.context.canvas.width, this.context.canvas.height);
|
||||
}
|
||||
|
||||
getImageData() {
|
||||
this.frameBuffer = this.context.getImageData(0,0,this.context.canvas.width,this.context.canvas.height).data as any as Uint8Array;
|
||||
return this.frameBuffer;
|
||||
}
|
||||
|
||||
}
|
@ -71,7 +71,7 @@ export class GlCanvas {
|
||||
|
||||
private frameBufferSize: number;
|
||||
private _frameBuffer: Uint8Array;
|
||||
private set frameBuffer(x: Uint8Array) {
|
||||
protected set frameBuffer(x: Uint8Array) {
|
||||
this._frameBuffer = x;
|
||||
}
|
||||
public get frameBuffer(): Uint8Array {
|
||||
@ -118,7 +118,7 @@ export class GlCanvas {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads pixels from the canvas
|
||||
* Reads pixels from the canvas into framebuffer, and returns pointer to the framebuffer
|
||||
* @returns
|
||||
*/
|
||||
getImageData(): Uint8Array {
|
||||
@ -156,7 +156,7 @@ export class GlCanvas {
|
||||
this.gl.deleteTexture(this.texture);
|
||||
}
|
||||
|
||||
private initWebgl() {
|
||||
protected initWebgl() {
|
||||
// Initialize the GL context
|
||||
this.gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
||||
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
||||
|
Loading…
Reference in New Issue
Block a user