// find all available OpenCL platforms
int ret = cl.clGetPlatformIDs(0, null, ib);
checkForError(ret, "can not enumerate platforms");
// receive platform ids
NativeSizeBuffer platformId = NativeSizeBuffer.allocateDirect(ib.get(0));
ret = cl.clGetPlatformIDs(platformId.capacity(), platformId, null);
checkForError(ret, "can not enumerate platforms");
List<CLPlatform> platforms = new ArrayList<CLPlatform>();
for (int i = 0; i < platformId.capacity(); i++) {
CLPlatform platform = new CLPlatform(platformId.get(i));
addIfAccepted(platform, platforms, filter);
}
return platforms.toArray(new CLPlatform[platforms.size()]);
}