@@ -26,6 +26,14 @@ var LibraryFixWebCamWebGL = {
26
26
27
27
JS_WebCamVideo_SetLatestTextureId : function ( textureId ) {
28
28
webcamLatestTextureId = textureId ;
29
+ // Webcam texture is created with texStorage2D so we have to recreate it
30
+ GLctx . deleteTexture ( GL . textures [ textureId ] ) ;
31
+ GL . textures [ textureId ] = GLctx . createTexture ( ) ;
32
+ GL . textures [ textureId ] . name = textureId ;
33
+ GLctx . bindTexture ( GLctx . TEXTURE_2D , GL . textures [ textureId ] ) ;
34
+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_WRAP_S , GLctx . CLAMP_TO_EDGE ) ;
35
+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_WRAP_T , GLctx . CLAMP_TO_EDGE ) ;
36
+ GLctx . texParameteri ( GLctx . TEXTURE_2D , GLctx . TEXTURE_MIN_FILTER , GLctx . LINEAR ) ;
29
37
} ,
30
38
31
39
JS_WebCamVideo_RemoveWhereTextureId : function ( textureId ) {
@@ -67,7 +75,7 @@ var LibraryFixWebCamWebGL = {
67
75
}
68
76
GLctx . bindTexture ( GLctx . TEXTURE_2D , GL . textures [ webcamBufferToTextureTable [ buffer ] ] ) ;
69
77
GLctx . pixelStorei ( GLctx . UNPACK_FLIP_Y_WEBGL , true ) ;
70
- GLctx . texSubImage2D ( GLctx . TEXTURE_2D , 0 , 0 , 0 , GLctx . RGBA , GLctx . UNSIGNED_BYTE , videoElement ) ;
78
+ GLctx . texImage2D ( GLctx . TEXTURE_2D , 0 , GLctx . RGBA , GLctx . RGBA , GLctx . UNSIGNED_BYTE , videoElement ) ;
71
79
GLctx . pixelStorei ( GLctx . UNPACK_FLIP_Y_WEBGL , false ) ;
72
80
disableNextSubImage = true ;
73
81
return 1 ;
0 commit comments