Java + OpenGL ES: Test for Transparency?
-
ByteBuffer pixel = ByteBuffer.allocateDirect(1);
byte transparentByte = 0;gl.glBindTexture(GL10.GL_TEXTURE_2D, _id);
pixel.position(0);
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, 1, 1, GL10.GL_ALPHA, GL10.GL_UNSIGNED_BYTE, pixel); pixel.position(0);if(pixel.get() != transparentByte)
{
//DO STUFF
}This never hits... It'll cycle through every pixel in the texture and never hit on a non-transparent pixel. What am I doing wrong? EDIT: It looks like whether or not I use GL_ALPHA or GL_RGBA, pixel.get() returns 0 for every pixel... it's not grabbing it from the texture or I'm not using ByteBuffer correctly... hmm...
-
ByteBuffer pixel = ByteBuffer.allocateDirect(1);
byte transparentByte = 0;gl.glBindTexture(GL10.GL_TEXTURE_2D, _id);
pixel.position(0);
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, x, y, 1, 1, GL10.GL_ALPHA, GL10.GL_UNSIGNED_BYTE, pixel); pixel.position(0);if(pixel.get() != transparentByte)
{
//DO STUFF
}This never hits... It'll cycle through every pixel in the texture and never hit on a non-transparent pixel. What am I doing wrong? EDIT: It looks like whether or not I use GL_ALPHA or GL_RGBA, pixel.get() returns 0 for every pixel... it's not grabbing it from the texture or I'm not using ByteBuffer correctly... hmm...
Well... I fixed my problem by just not using OpenGL so the question still stands for anyone who comes across this thread.