greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.67k stars 260 forks source link

typescript Qaud primitives returns wrong types #142

Closed Zaitsev closed 4 years ago

Zaitsev commented 4 years ago

Seems that types are swapped...

    export function createXYQuadBufferInfo(gl: WebGLRenderingContext, size?: number, xOffset?: number, yOffset?: number): {
        [key: string]: WebGLBuffer;
    };
    export function createXYQuadBuffers(gl: WebGLRenderingContext, size?: number, xOffset?: number, yOffset?: number): BufferInfo;
Zaitsev commented 4 years ago

also in typsecript:

export function bindFramebufferInfo(gl: WebGLRenderingContext, framebufferInfo?: FramebufferInfo, target?: number): void;

calling it as twgl.bindFramebufferInfo(gl, null) has more clear intention to unbind (we pass null, and this is consistent with gl.bindFremabuffer) so may be its better to define it as framebufferInfo: FramebufferInfo|null (required nullable parameter or make it nullable optional for backward compability)

greggman commented 4 years ago

made both of those changes.

2a2a841f516d98da72ca9b5c63b44b28ef8f8f7e

9965723a31ade9fdc555a39184e55982ca3f3f66

Funny that even though the documentation says passing no 2nd parameter to twgl.bindFramebufferIInfo binds the canvas I always passed null in actual usage 😅

Zaitsev commented 4 years ago

If not passed will ~bind~ the canvas If not passed or null will unbind the buffer