Skip to main content
gamedev.net
🔒 Locked

FloatBuffer.put(float vertices[]) vs FloatBuffer.put(float[] src, int offset, int length)

Started by Paul Benedict Jabines 2 replies 2.1k views
Original Post
Paul Benedict Jabines
Paul Benedict Jabines

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.

Dave Hunt
Dave Hunt

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.

Paul Benedict Jabines
Paul Benedict Jabines

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.

Dave Hunt
Dave Hunt




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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.