long id = clgli.clCreateFromGLTexture2D(context.ID, flags, target, mipLevel, texture, result, 0);
checkForError((int)id, "can not share memory with texture #"+texture+".");
CLImageInfoAccessor accessor = new CLImageInfoAccessor(cl, id);
CLImageFormat format = createUninitializedImageFormat();
accessor.getInfo(CL_IMAGE_FORMAT, CLImageFormatImpl.size(), format.getFormatImpl().getBuffer(), null);
int width = (int)accessor.getLong(CL_IMAGE_WIDTH);
int height = (int)accessor.getLong(CL_IMAGE_HEIGHT);
return new CLGLTexture2d<B>(context, directBuffer, format, accessor, target, mipLevel, width, height, id, texture, flags);