glTexImage2D/glTexSubImage2D gles20/html5

Monkey Forums/Monkey Bug Reports/glTexImage2D/glTexSubImage2D gles20/html5

DaveC(Posted 2014) [#1]
The definitions for the dataBuffer versions of glTexImage2D & glTexSubImage2D are incorrect in gles20.monkey for html5 targets.

Use of these functions results in:
Monkey Runtime Error : TypeError: undefined is not a function


After much head-scratching and a crash course in WebGL I have provided a solution:

gles20.monkey line 873:
Function glTexImage2D:Void( target, level, internalformat, width, height, border, format, type, pixels:DataBuffer )="_glTexImage2D"
Function glTexSubImage2D:Void( target, level, xoffset, yoffset, width, height, format, type, pixels:DataBuffer )="_glTexSubImage2D"


Should be changed to:
Function glTexImage2D:Void( target, level, internalformat, width, height, border, format, type, pixels:DataBuffer )="_glTexImage2D2"
Function glTexSubImage2D:Void( target, level, xoffset, yoffset, width, height, format, type, pixels:DataBuffer )="_glTexSubImage2D2"


Furthermore.... gles20.html5.js line 263:
function _glTexImage2D2( target,level,internalformat,width,height,border,format,type,pixels ){
	gl.texImage2D( target,level,internalformat,width,height,border,format,type,pixels.byteArray );
}


pixels.byteArray is an invalid member so we change it to:
function _glTexImage2D2( target,level,internalformat,width,height,border,format,type,pixels ){
	gl.texImage2D( target,level,internalformat,width,height,border,format,type,new Uint8Array(pixels.arrayBuffer) );
}


And similarally... gles20.html5.js line 294:
function _glTexSubImage2D2( target,level,xoffset,yoffset,width,height,format,type,pixels ){
	gl.texSubImage2D( target,level,xoffset,yoffset,width,height,format,type,new Uint8Array(pixels.arrayBuffer) );
}



marksibly(Posted 2014) [#2]
Nice find and fix - thanks!


DaveC(Posted 2014) [#3]
My pleasure