final GL gl = GLContext.getCurrentGL();
JoglTextureStateUtil.doTextureBind(tex, 0, true);
if (tex.getType() == Type.TwoDimensional) {
gl.glCopyTexSubImage2D(GL.GL_TEXTURE_2D, 0, xoffset, yoffset, x, y, width, height);
} else if (tex.getType() == Type.CubeMap) {
gl.glCopyTexSubImage2D(JoglTextureStateUtil.getGLCubeMapFace(((TextureCubeMap) tex).getCurrentRTTFace()),
0, xoffset, yoffset, x, y, width, height);
} else {
throw new IllegalArgumentException("Invalid texture type: " + tex.getType());