Exemplo n.º 1
0
Arquivo: Main.java Projeto: io7m/r2
  /**
   * Main program.
   *
   * @param args Command line arguments
   * @throws Exception On errors
   */
  public static void main(final String[] args) throws Exception {
    if (args.length != 3 && args.length != 4) {
      Main.LOG.info("usage: root file.vert [file.geom] file.frag");
      System.exit(1);
    }

    final File root = new File(args[0]);

    final R2ShaderPreprocessorType p = R2ShaderPreprocessor.newPreprocessor(root);

    List<String> vs = null;
    Optional<List<String>> gs = null;
    List<String> fs = null;

    try {
      if (args.length == 4) {
        vs = p.preprocessFile(args[1]);
        gs = Optional.of(p.preprocessFile(args[2]));
        fs = p.preprocessFile(args[3]);
      } else {
        vs = p.preprocessFile(args[1]);
        gs = Optional.empty();
        fs = p.preprocessFile(args[2]);
      }
    } catch (final Exception e) {
      Main.LOG.error("Preprocessing failure: ", e);
      System.exit(1);
    }

    final GLProfile pro = GLProfile.get(GLProfile.GL3);
    final GLCapabilities caps = new GLCapabilities(pro);
    final GLDrawableFactory f = GLDrawableFactory.getFactory(pro);
    final GLOffscreenAutoDrawable drawable =
        f.createOffscreenAutoDrawable(null, caps, null, 32, 32);
    drawable.display();
    final GLContext ctx = drawable.getContext();
    ctx.makeCurrent();

    try {
      final JCGLImplementationJOGLType i = JCGLImplementationJOGL.getInstance();
      final JCGLContextType jc = i.newContextFrom(ctx, "offscreen");
      final JCGLInterfaceGL33Type gi = jc.contextGetGL33();
      final R2ShaderCheckerType ch = R2ShaderChecker.newChecker(gi.getShaders());

      ch.check(vs, gs, fs);
    } finally {
      ctx.release();
      drawable.destroy();
    }
  }
Exemplo n.º 2
0
  private void prepareSideContext() {
    if (sideContext == null) {
      GLDrawableFactory factory = canvas.getFactory();
      sideContext = factory.createOffscreenAutoDrawable(null, chosenCapabilities, null, 1, 1);
      ((GLOffscreenAutoDrawable) sideContext).setSharedContext(canvas.getContext());
      sideContext.addGLEventListener(g2dglListener);
    }

    Runnable work =
        new Runnable() {
          @Override
          public void run() {
            sideContext.display();
          }
        };

    if (Threading.isOpenGLThread()) {
      work.run();
    } else {
      Threading.invokeOnOpenGLThread(false, work);
    }
  }