Questions tagged [floatbuffer]

31 questions
1
vote
3 answers

Convert FloatBuffer[] to byte[]

I've been searching for a way to convert a FloatBuffer array to a byte array. I have found a way to convert a FloatBuffer object to byte[]: convert from floatbuffer to byte[] But after searching the Internet for several hours I haven't been able to…
1
vote
1 answer

read and write FloatBuffer as binary file in android

I'm playing around with OpenGL ES 2 and FloatBuffers. Actually i try to save the FloatBuffer handling the Vertices Data to a binary file. It seems to work but after reading in the floats and puting them back togehter to a FloatBuffer the object is…
ZeroTek
  • 1,302
  • 1
  • 11
  • 30
1
vote
2 answers

combine ByteBuffer & FloatBufffer

Is there a good way to combine ByteBuffer & FloatBuffer ? For example I get byte[] data and I need to convert it to float[] data and vice versa : byte[] to float[] (java.lang.UnsupportedOperationException) : byte[] bytes = new…
xunien
  • 185
  • 1
  • 9
1
vote
1 answer

OpenGL ES Android Confusion

I am learning OpenGL ES for Android through this website: http://www.learnopengles.com/android-lesson-one-getting-started/ There are a couple of things I don't understand... What exactly do this code do: mTriangle1Vertices =…
foobar5512
  • 2,470
  • 5
  • 36
  • 52
0
votes
1 answer

Making one helper function for ByteBuffer allocation android OpenGL ES

For allocating ByteBuffer memory for vertices, colors, lighting, etc everytime I need to do the following. ByteBuffer bBuff=ByteBuffer.allocateDirect(vertices.length*4); bBuff.order(ByteOrder.nativeOrder()); …
jmishra
  • 2,086
  • 2
  • 24
  • 38
0
votes
3 answers

Java FloatBuffer size error OpenGL

working with LWJGL's implementation of OpenGL, and trying to work with the lighting functions. This requires the creation of FloatBuffers to pass to OpenGL. Relevant code follows: GL11.glClearColor(0,0,0,0); float[]…
sol_var
  • 847
  • 1
  • 9
  • 9
0
votes
2 answers

Is there any difference between giving GL15.glBufferData() a float array or a FloatBuffer in LWJGL 3.0?

I was recently watching a tutorial on writing an OpenGL game in Java with LWJGL. In it, the narrator/author first converts the float array from float[] to a FloatBuffer before giving it toGL15.glBufferData(). Initially I didn't think much of this,…
Newbyte
  • 2,421
  • 5
  • 22
  • 45
0
votes
1 answer

OpenGL buffer problem when adding >= 2^16 numbers

I'm facing some strange difficulties with OpenGL buffer. I tried to shrunk the problem to the minimum source code, so I created program that increment each number of the FloatBuffer in each iteration. When I am adding less than 2^16 float numbers to…
Michal
  • 3
  • 4
0
votes
1 answer

Is it possible to modify by reference the content of a FloatBuffer?

I initialized the content of my FloatBuffer with an array of Float once. And then modify the Floats that I have put in, I would expect that it modifies also the values in the FloatBuffer but I obtain a weird result. Am I doing wrong ? Is it possible…
user2591935
  • 299
  • 1
  • 14
0
votes
1 answer

How do I create a copy of a read-only FloatBuffer?

I'm trying to edit a buffer, but the inputted copy (original) is read-only. The result has the same values but acts differently from the original; I'm not sure what's different. Why might this be the case? private FloatBuffer…
rgoy
  • 1
  • 1
0
votes
0 answers

Is the absolute version of FloatBuffer.put thread-safe?

There are multiple put methods for java.nio.FloatBuffer. As far as I know, most (all?) of them depend on an internal state of the buffer, so they are not thread-safe. My question is if this also applies for the following method? public abstract…
schreon
  • 1,097
  • 11
  • 25
0
votes
0 answers

Efficiently filling a FloatBuffer from part of a ByteBuffer

Currently I am filling a FloatBuffer from a Mapped Byte Buffer in the following way: /** * The vertex lump (Lump 3) is an array of coordinates of all the vertices (corners) of brushes in the map geometry. * Each vertex is a Vector of 3 floats…
Blight
  • 87
  • 1
  • 10
0
votes
1 answer

Get float[] as FloatBuffer class

Having a float[] and I want to put it as argument for glLoadMatrixf(FloatBuffer m) (interface of GLMatrixFunc) . How could I get the float[] as FloatBuffer ? The code is - float[] currentMatrix = {.....} ; gl.glLoadMatrixd(currentMatrix ); The…
URL87
  • 10,667
  • 35
  • 107
  • 174
0
votes
1 answer

Android using float[] as vertices causes OpenGL error 0x502

I am trying to use an array of floats for my verticies in OpenGLES 2.0 on Android instead of a FloatBuffer but When I do I glDrawArrays gives the error 0x502 or GL_INVALID_OPERATION. I do not get this error and everything works fine when I use…
Alchitry
  • 1,369
  • 1
  • 16
  • 29
0
votes
1 answer

FloatBuffer and 3D graphics

I have been looking for a beginners explanation of what a floatBuffer is and how it relates to 3D programming (specifically for use in the LWJGL for java). It seems I have to use it allot for lighting and billboarding and things but I dont fully…
lilroo
  • 2,928
  • 7
  • 25
  • 34