gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
int[] crop = new int[] {
sourceTextureX, sourceTextureY, // Coordinates to use from the SOURCE texture. NOT where it will be drawn to the screen
sourceTextureWidth, -sourceTextureHeight // use a negative height to flip the image upside down
}
gl.glEnable(GL10.GL_TEXTURE_2D);
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, crop, 0);
((GL11) gl).glDrawTexiOES(destinationX, destinationY, destinationZ /* typically 0 */, sourceTextureWidth, sourceTextureHeight);
randomcracker wrote:Thanks guys, although it doesn't work with a negative sourceTextureHeight. Had to use the posetive although then it got upsidedown of course...
moblcade.com wrote:randomcracker wrote:Thanks guys, although it doesn't work with a negative sourceTextureHeight. Had to use the posetive although then it got upsidedown of course...
That's why you supply the negative source texture height. It flips the image. Try drawing at destinationY + height and see what happens when you supply negative sourceTextureHeight.
randomcracker wrote:moblcade.com wrote:randomcracker wrote:Thanks guys, although it doesn't work with a negative sourceTextureHeight. Had to use the posetive although then it got upsidedown of course...
That's why you supply the negative source texture height. It flips the image. Try drawing at destinationY + height and see what happens when you supply negative sourceTextureHeight.
Doesn't work, it doesn't draw it correctly.
randomcracker wrote:Yeah no, I got it to work just now, changed the sourceTextureY to include height. Maybe that's what you ment? Anyhow GREAT! Finally an easy way to do this, thanks a lot!! Now I only have to get the 3d stuff to work. I'm trying to implement the modelloader.jar for android but I'm not having much luck with it. I can't understand why it works to draw a model in one place but as soon as I send the gl10 object to another class to draw using the exact same code it just doesn't draw anything. Wierd stuff this is.
Return to Android 2D/3D Graphics - OpenGL Problems
Users browsing this forum: No registered users and 1 guest