Skip to content

Commit 2c89992

Browse files
committed
- fixed check for if texture bound image is a valid image object to create texture from
1 parent 7e0b9fa commit 2c89992

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

scripts/Builders/yyPrimBuilder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function WebGL_draw_primitive_begin_texture_RELEASE(_kind, _tex) {
133133
// If they've managed to find a path through the code without this texture being bound...
134134
if (g_PrimTexture && !g_PrimTexture.webgl_textureid) {
135135
WebGL_BindTexture({texture: g_PrimTexture});
136-
if(WebGL_IsTextureImageValid(g_PrimTexture.webgl_textureid)) {
136+
if(!WebGL_IsTextureImageValid(g_PrimTexture.webgl_textureid)) {
137137
yyError("draw_primitive_begin_texture: trying to use an invalid texture");
138138
return;
139139
}

scripts/Builders/yyVBufferBuilder.js

Lines changed: 2 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(WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
388+
if(!WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
389389
yyError("vertex_submit: trying to use an invalid texture");
390390
return;
391391
}
@@ -401,7 +401,7 @@ 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_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
404+
if(!WebGL_IsTextureImageValid(_texture.WebGLTexture.webgl_textureid)) {
405405
yyError("vertex_submit: trying to use an invalid texture");
406406
return;
407407
}

scripts/yyWebGL.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5048,15 +5048,18 @@ function WebGL_IsTextureValid(_tex, _mipoptions)
50485048

50495049
function WebGL_IsTextureImageValid(_tex)
50505050
{
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-
)
5051+
// check if bound image is a valid object that a texture can be created from
5052+
if(_tex.Image == undefined || _tex.Image == null)
50565053
{
50575054
return false;
50585055
}
5059-
return true;
5056+
5057+
if(_tex.Image instanceof HTMLImageElement
5058+
|| _tex.Image instanceof Uint8Array)
5059+
{
5060+
return true;
5061+
}
5062+
return false;
50605063
}
50615064

50625065

0 commit comments

Comments
 (0)