Skip to content

Commit ca96cee

Browse files
committed
- check for HTMLUnknownElement when checking if bound image is valid for texture creation
1 parent 7ecd917 commit ca96cee

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

scripts/Builders/yyVBufferBuilder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function yyVBufferBuilder(_size) {
385385
// Check whether the webgl texture has been initialised yet and do so if not
386386
if (_texture && !_texture.WebGLTexture.webgl_textureid) {
387387
WebGL_BindTexture(_texture.TPE);
388-
if(_texture.WebGLTexture.webgl_textureid.Image == undefined || _texture.WebGLTexture.webgl_textureid.Image == null) {
388+
if(WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
389389
yyError("vertex_submit: trying to use an invalid texture");
390390
return;
391391
}
@@ -401,10 +401,11 @@ function yyVBufferBuilder(_size) {
401401
// Check whether the webgl texture has been initialised yet and do so if not
402402
if (_texture && !_texture.WebGLTexture.webgl_textureid) {
403403
WebGL_BindTexture(_texture.TPE);
404-
if(_texture.WebGLTexture.webgl_textureid.Image == undefined|| _texture.WebGLTexture.webgl_textureid.Image == null) {
404+
if(WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
405405
yyError("vertex_submit: trying to use an invalid texture");
406406
return;
407407
}
408+
408409
}
409410
pBuff = g_webGL.AllocVerts(_primType, _texture.WebGLTexture.webgl_textureid, m_FVF, vertexCount);
410411
}

scripts/yyWebGL.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5046,6 +5046,19 @@ function WebGL_IsTextureValid(_tex, _mipoptions)
50465046
}
50475047
}
50485048

5049+
function WebGL_IsTextureImageValid(_tex)
5050+
{
5051+
// check if bound image is a valid object that a texture can be created from
5052+
if(_tex.Image == undefined
5053+
|| _tex.Image == null
5054+
|| typeof(_tex.Image) == "HTMLUnknownElement"
5055+
)
5056+
{
5057+
return false;
5058+
}
5059+
return true;
5060+
}
5061+
50495062

50505063

50515064

0 commit comments

Comments
 (0)