Hello programmers,
I am sure that i am in the correct section because this is opengl with regards to android game development.
I study a book which is a pdf and i found early chapters using FloatBuffer.put(float vertices[]) and i understand that. But for the next chapters they use FloatBuffer.put(float[] src, int offset, int length). I am hoping someone can answer what is the difference between the two. What is the meaning and what is the importance of offset and length in FloatBuffer.put(float[] src, int offset, int length). Thanks a lot.
FloatBuffer.put(float vertices[]) vs FloatBuffer.put(float[] src, int offset, int length)
FloatBuffer.put(float[] vertices) adds all elements of the vertices array to the buffer.
FloatBuffer.put(float[] src,int offset, int length) adds "length" elements of the src array starting at the "offset" element of the src array to the buffer. e.g. starting at src[offset] and continuing for "length" elements.
Actually, this isn't really an OpenGL question. FloatBuffer is part of Java and is not specific to OpenGL at all.
FloatBuffer.put(float[] vertices) adds all elements of the vertices array to the buffer.
FloatBuffer.put(float[] src,int offset, int length) adds "length" elements of the src array starting at the "offset" element of the src array to the buffer. e.g. starting at src[offset] and continuing for "length" elements.
Actually, this isn't really an OpenGL question. FloatBuffer is part of Java and is not specific to OpenGL at all.
A thanks. i get it. If you have:
float v[] = {1,2,3,4,5,6,7,8,9,10};
FloatBuffer.put[v,2,2];
It adds 3 and 4.
Yes, this is not opengl.
A thanks. i get it. If you have:
float v[] = {1,2,3,4,5,6,7,8,9,10};
FloatBuffer.put[v,2,2];
It adds 3 and 4.
You got it!