Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 PaulJabs   Members   

130
Like
0Likes
Like

Posted 16 July 2013 - 06:29 AM

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.



#2 Dave Hunt   Members   

4872
Like
0Likes
Like

Posted 16 July 2013 - 11:41 AM

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.



#3 PaulJabs   Members   

130
Like
0Likes
Like

Posted 16 July 2013 - 01:17 PM

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.


Edited by PaulJabs, 16 July 2013 - 01:19 PM.


#4 Dave Hunt   Members   

4872
Like
0Likes
Like

Posted 16 July 2013 - 01:38 PM


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!






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.