Skip to content

Commit d044b9e

Browse files
committed
Merge branch '2024.02.0-main' into develop
2 parents 2042b37 + 926937a commit d044b9e

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

scripts/Builders/yyVBufferBuilder.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,10 @@ 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 (!WebGL_IsTextureValid(_texture.WebGLTexture.webgl_textureid, WebGL_gpu_get_tex_mip_enable())) {
389-
yyError("vertex_submit: trying to use a texture that does not exist");
390-
return;
391-
}
388+
if(!WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
389+
yyError("vertex_submit: trying to use an invalid texture");
390+
return;
391+
}
392392
}
393393
g_webGL.DispatchVBuffer(_primType, _texture.WebGLTexture.webgl_textureid, m_VBuffer, _offset, vertexCount);
394394
}
@@ -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 (!WebGL_IsTextureValid(_texture.WebGLTexture.webgl_textureid, WebGL_gpu_get_tex_mip_enable())) {
405-
yyError("vertex_submit: trying to use a texture that does not exist");
406-
return;
407-
}
404+
if(!WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
405+
yyError("vertex_submit: trying to use an invalid texture");
406+
return;
407+
}
408+
408409
}
409410
pBuff = g_webGL.AllocVerts(_primType, _texture.WebGLTexture.webgl_textureid, m_FVF, vertexCount);
410411
}

scripts/yyWebGL.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5046,6 +5046,26 @@ 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 || _tex.Image == null)
5053+
{
5054+
return false;
5055+
}
5056+
5057+
if(_tex.Image instanceof HTMLImageElement
5058+
|| _tex.Image instanceof HTMLCanvasElement
5059+
|| _tex.Image instanceof HTMLVideoElement
5060+
|| _tex.Image instanceof ImageData
5061+
|| _tex.Image instanceof Uint8Array
5062+
)
5063+
{
5064+
return true;
5065+
}
5066+
return false;
5067+
}
5068+
50495069

50505070

50515071

0 commit comments

Comments
 (0)