import type { ITexture , ReadableTextureFormat , TextureType , } from "./api/texture.js" ; import { FBO } from "./fbo.js" ; export const readPixels = < T extends Uint8Array | Uint16Array | Uint32Array | Float32Array > ( gl , x , y , w , h , format , type , out ) => { gl . readPixels ( x , y , w , h , format , type , out ) ; return out ; } ; export const readTexture = < T extends Uint8Array | Uint16Array | Uint32Array | Float32Array > ( gl , tex , format , type , out ) => { const fbo = new FBO ( gl , { tex : [ tex ] } ) ; fbo . bind ( ) ; gl . readPixels ( 0 , 0 , tex . size [ 0 ] , tex . size [ 1 ] , format , type , out ) ; fbo . unbind ( ) ; fbo . release ( ) ; return out ; } ;