So I am trying to adapt some c++ code into java, because I wasn’t unable to find an example in java for what I wanted.
Basic problem
no unsigned bytes in java
byte = -127 to 127
unsigned byte would be 0 to 255
so I use int instead, which is fine
except, when I try passing it to the GL11.glTexImage2D
which requires a bytebuffer, which I can convert bytes to bytebuffer no problem.
So basically what I am trying to accomplish is converting a int to a byte
all the examples I find are shifting a single byte into a 4 long array of a byte. for the added potential values
all my values of int are 0 to 255, so I dont need the added values.
but I need to shift my int down -127 so it falls into proper range of byte, then convert to byte.
Any suggestions?
All online things show int to byte arrays, though I just need an int to byte
or a conversion process that supports int arrays, an easy way to discard the unnecessary 0s of the byte array[][]
Sorry for the hugely wordy/messy example.
int[] pix = new int[250000];
// blah blah random shit
//each value of pix is between 0 and 255
ByteBuffer bb = ByteBuffer.allocate(pix.length);
bb.put(pix);
GL11.glTexImage2D( GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 256, 256, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, bb); //for lwjgl,
//plan B, rewrite the whole thing to use bytes -127 to 127(from the start), which requires a painfully manual modification of a huge reference table 
///edit
So one possibility?
int[] pix = new int[250000];
byte[] b = new byte[250000];
//large for loop…
b[value]=(byte) (pix[value]-127);
