Results 1 to 2 of 2

Thread: drawElements with gl.POINTS

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    1

    drawElements with gl.POINTS

    Hey guys, I'm trying to render two points using drawElements() API, but I'm getting only one rendered on my MBP 13", with Intel HD Graphics 3000 384 MB card. Chrome and FF. I don't see any errors neither in dev console nor in webgl inspector.

    I must be missing something very obvious. Can someone help please?

    Here is the test page.

    Shaders:
    Code :
        // vertex shader:
        attribute vec3 aVertexPos;
     
        void main(){
          gl_Position = vec4(aVertexPos.xy, 0, 1);
          gl_PointSize = 32.0;
        }
     
       // fragment shader:
        precision mediump float;
     
        void main(){
          gl_FragColor = vec4(0., 1., 0., 1.);
        }

    And JS:
    Code :
      var program = webgl.createProgram(vs, fs),
          vertexPositionAttributeLocation = gl.getAttribLocation(program, 'aVertexPos'),
          verticesPositionsBuffer = gl.createBuffer(),
          verticesPositions = new Float32Array([0, 0.5, 0,   0, 0, 0]),
     
          verticesIndecesBuffer = gl.createBuffer(),
          verticesIndeces = new Float32Array([0, 1]);
     
      gl.useProgram(program);
     
      gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, verticesIndecesBuffer);
      gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, verticesIndeces, gl.STATIC_DRAW);
     
      gl.bindBuffer(gl.ARRAY_BUFFER, verticesPositionsBuffer);
      gl.bufferData(gl.ARRAY_BUFFER, verticesPositions, gl.STATIC_DRAW);
      gl.enableVertexAttribArray(vertexPositionAttributeLocation);
      gl.vertexAttribPointer(vertexPositionAttributeLocation, 3, gl.FLOAT, false, 0, 0);
     
      gl.drawElements(gl.POINTS, 2, gl.UNSIGNED_SHORT, 0);

  2. #2

    Re: drawElements with gl.POINTS

    Have you tried using drawArrays?
    Also, when I view your test page, I see both elements.
    Are you using osx or windows?

Posting Permissions

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