1. Are you ready for the Galaxy S20? Here is everything we know so far!

OpenGL Line

Discussion in 'Android Development' started by zonk, Oct 24, 2014.

  1. zonk

    zonk Newbie
    Thread Starter

    Can anyone tell me why this code crashes my app please?

    Code (Text):
    1.  
    2.  
    3.         float line_vertex[]=
    4.             {
    5.                 x1,y1, x2,y2
    6.             };
    7.        
    8.         FloatBuffer vertexBuffer;
    9.         ByteBuffer byteBuffer = ByteBuffer.allocateDirect(line_vertex.length * 4);
    10.         byteBuffer.order(ByteOrder.nativeOrder());
    11.         vertexBuffer = byteBuffer.asFloatBuffer();
    12.         vertexBuffer.put(line_vertex);
    13.         vertexBuffer.position(0);
    14.        
    15.         gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertexBuffer);
    16.         gl.glDrawArrays(GL10.GL_LINES, 0, 2);
    17.  
     



    1. Download the Forums for Android™ app!


      Download

       
  2. zonk

    zonk Newbie
    Thread Starter

Loading...

Share This Page

Loading...