elect
elect

Reputation: 7190

How to get unsigned float in java

I have a sample where I need to put float values (as imageSize.x and imageSize.x) as unsigned floats inside a bytebuffer, because this is how the fragment shader expects them to be.

Since for this specific sample, I needed to upload twice an unsigned 256.0f, that in binary is 1 0000 0000, I tried to upload (byte) 0100 (small endian + 2 zero bytes for padding) twice, and it worked flawless.

But I would like to have a more elegant and general case to avoid passing throught byte....Any suggestion?

Upvotes: 1

Views: 2445

Answers (1)

23nikoloz
23nikoloz

Reputation: 70

try this

Float.intBitsToFloat(int bits)

Upvotes: 2

Related Questions