private void initOpenCL1() {
   clContext = context.getOpenCLContext();
   Device device = clContext.getDevices().get(0);
   clQueue = clContext.createQueue(device).register();
   // create kernel
   Program program = null;
   File tmpFolder = JmeSystem.getStorageFolder();
   File binaryFile = new File(tmpFolder, getClass().getSimpleName() + ".clc");
   try {
     // attempt to load cached binary
     byte[] bytes = Files.readAllBytes(binaryFile.toPath());
     ByteBuffer bb = BufferUtils.createByteBuffer(bytes);
     program = clContext.createProgramFromBinary(bb, device);
     program.build();
     LOG.info("reuse program from cached binaries");
   } catch (java.nio.file.NoSuchFileException ex) {
     // do nothing, cache was not created yet
   } catch (Exception ex) {
     LOG.log(Level.INFO, "Unable to use cached program binaries", ex);
   }
   if (program == null) {
     // build from sources
     String source =
         ""
             + "__kernel void ScaleKernel(__global float* vb, float scale)\n"
             + "{\n"
             + "  int idx = get_global_id(0);\n"
             + "  float3 pos = vload3(idx, vb);\n"
             + "  pos *= scale;\n"
             + "  vstore3(pos, idx, vb);\n"
             + "}\n";
     program = clContext.createProgramFromSourceCode(source);
     program.build();
     // Save binary
     try {
       ByteBuffer bb = program.getBinary(device);
       byte[] bytes = new byte[bb.remaining()];
       bb.get(bytes);
       Files.write(binaryFile.toPath(), bytes);
     } catch (UnsupportedOperationException | OpenCLException | IOException ex) {
       LOG.log(Level.SEVERE, "Unable to save program binaries", ex);
     }
     LOG.info("create new program from sources");
   }
   program.register();
   kernel = program.createKernel("ScaleKernel").register();
 }
 private void initOpenCL2() {
   // bind vertex buffer to OpenCL
   VertexBuffer vb = geom.getMesh().getBuffer(VertexBuffer.Type.Position);
   buffer = clContext.bindVertexBuffer(vb, MemoryAccess.READ_WRITE).register();
   ws = new com.jme3.opencl.Kernel.WorkSize(geom.getMesh().getVertexCount());
 }