Re: [webgl-dev-list] ArrayBufferView not big enough for request

1,812 views
Skip to first unread message

Gregg Tavares (社用)

unread,
Sep 7, 2012, 12:22:47 PM9/7/12
to webgl-d...@googlegroups.com
The dataArray needs to be

   var unpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
   var unpaddedRowSize = width * sizeofPixel(type, format);
   var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment)  * unpackAlignment;
   var sizeNeeded = paddedRowSize * (height - 1) + unpaddedRowSize;

I'm assuming you know the size of a pixel. for gl.RGBA, gl_UNSIGNED_BYTE it would be 4
The default unpackAlignment is 4

Try printing the length of dataArray

Maybe you could paste a sample somewhere like jsfiddle.net?





On Fri, Sep 7, 2012 at 12:55 AM, Tomáš Sychra <xsyc...@gmail.com> wrote:
Hi,
can somebody help me please with this error : WebGL: INVALID_OPERATION: texImage2D: ArrayBufferView not big enough for request ?
I don´t understand to that, because ArrayBuffer, that i want to paint isnt big enaught (another one - more bigger - i can paint with any problems)..so where could be problem?
Help me please...

code where the error is : 

i called this :
textures.textureYZ.refreshTextureData(gl, texGen.generateYZTexture(), cube3D.width, cube3D.numCuts, gl.RGBA);

refreshTexture method :
  /**
    * Actualize texture
    */
    function refreshTextureData(gl, dataArray, width, height, type) {
      gl.bindTexture(gl.TEXTURE_2D, texture);
      
// ----> HERE IS THE PROBLEM
gl.texImage2D(gl.TEXTURE_2D, 0, type, width, height, 0, type, gl.UNSIGNED_BYTE, dataArray);
      
      //solution of Power of 2 only textures - we didnt REPEAT
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
      gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
      gl.bindTexture(gl.TEXTURE_2D, null);
    }   



Reply all
Reply to author
Forward
0 new messages