I am new to OpenGL all together. I am making a color blind app on Android for academic purposes. I have all the code needed in the shader to do the manipulations I need, but I still have to get the shader to be able to see the data I create in my Java code. In my Java code, I ended up with a large int array of size 262144. I tried to pass this array into the shader any way I could, but it was too large. I have been informed that I can pass this much information easily into the shader if I turn my data into a texture.
I have converted my int array into a byte array as instructed by a colleague, but now I am lost as to how I create the opengl texture and input my byte data into it for the shader to see and use.
So, I need to create a opengl texture, fill it with my data (is byte array best?) and then be able to use that texture in my shader. If anyone can help me out, it would be much appreciated. I work well after seeing examples, not explanations because I am very opengl illiterate but I welcome any help.
I did try to code some. I ended up trying to make a GLES20.glTexImage2D. I figured I could just pass in my byte array, but it takes a buffer?? Please give me all the steps necessary to complete my task.
Thanks a lot!
Mike
I think you need to do following;
byte data[4 * 262144]; // your byte array, 4 * int count
ByteBuffer buffer = ByteBuffer.allocateDirect(4 * 262144);
buffer.put(data);
buffer.position(0);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0,
GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, buffer);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With