static void swapBuffers(long window) {
   OGLRenderQueue rq = OGLRenderQueue.getInstance();
   rq.lock();
   try {
     RenderBuffer buf = rq.getBuffer();
     rq.ensureCapacityAndAlignment(12, 4);
     buf.putInt(SWAP_BUFFERS);
     buf.putLong(window);
     rq.flushNow();
   } finally {
     rq.unlock();
   }
 }
  /**
   * Disposes the native resources associated with the given OGLSurfaceData (referenced by the pData
   * parameter). This method is invoked from the native Dispose() method from the Disposer thread
   * when the Java-level OGLSurfaceData object is about to go away. Note that we also pass a
   * reference to the native GLX/WGLGraphicsConfigInfo (pConfigInfo) for the purposes of making a
   * context current.
   */
  static void dispose(long pData, long pConfigInfo) {
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
      // make sure we have a current context before
      // disposing the native resources (e.g. texture object)
      OGLContext.setScratchSurface(pConfigInfo);

      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(DISPOSE_SURFACE);
      buf.putLong(pData);

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }
  public void flush() {
    invalidate();
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
      // make sure we have a current context before
      // disposing the native resources (e.g. texture object)
      OGLContext.setScratchSurface(graphicsConfig);

      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(FLUSH_SURFACE);
      buf.putLong(getNativeOps());

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }