Results 1 to 2 of 2

Thread: glDrawxxx attempt to access out of range vertices

  1. #1

    glDrawxxx attempt to access out of range vertices

    Howdy guys, I've been following the tutorials on and I've run into a snag with my current project.

    I am trying to render a point cloud from a text file. I can parse the file and build an array of vertices. Yet there seems to be an issue with loading the array into the buffer.
    Because of this, I get an out of range error when trying to draw the scene.

    My parsing code:
    Code :
    	function handleFile(responseText)
    		var splitByLine = responseText.split("\r\n"); 
    		numVerts=splitByLine.length; // Array of lines, each line represents a point
    		for(var j = 0; j<splitByLine.length;j++)
    			var tmpArray = new Array();
    			tmpArray = splitByLine[j].split("\t");

    My init Buffer code:
    Code :
    	function initBuffers()
    		vertexPosBuffer = gl.createBuffer();
    		gl.bufferData(gl.ARRAY_BUFFER,new Float32Array(vertexLocations),gl.STATIC_DRAW);
    		vertexPosBuffer.numVerts= numVerts;

    My draw scene code:
    Code :
    	function drawScene()
    	gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    	gl.drawArrays(gl.POINTS,0, numVerts);
    External to this code is where I declare my global variables:
    var vertexLocations = new Array();
    var numVerts;
    var verts;

    Any help would be appreciated in figuring out the issue. When I look at the buffer with webgl inspector, it says that the array of vertex data that I am passing it, is null. Yet when I step through the code I can see that the array contains the proper data.

  2. #2

    Re: glDrawxxx attempt to access out of range vertices

    If anyone else ever has such a problem, I found that my buffer initialization function was being called before my file handler finished loading.
    I fixed this by calling the buffer inside the file handler instead of in the main part of my code.

Similar Threads

  1. simple example - attempt to access out of range vertices err
    By saruniitr in forum Developers Coding:Beginner
    Replies: 2
    Last Post: 10-15-2012, 02:29 PM
  2. float4 and possible out of range?
    By sean.settle in forum OpenCL
    Replies: 4
    Last Post: 02-02-2012, 09:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts