예제 #1
0
 @Test
 public void test01_DefaultNorm()
     throws AWTException, InterruptedException, InvocationTargetException {
   final GLProfile glp;
   if (forceGL3) {
     glp = GLProfile.get(GLProfile.GL3);
   } else if (forceES3) {
     glp = GLProfile.get(GLProfile.GLES3);
   } else if (forceES2) {
     glp = GLProfile.get(GLProfile.GLES2);
   } else if (forceGLFFP) {
     glp = GLProfile.getMaxFixedFunc(true);
   } else {
     glp = GLProfile.getDefault();
   }
   final GLCapabilities caps = new GLCapabilities(glp);
   if (useMSAA) {
     caps.setNumSamples(msaaNumSamples);
     caps.setSampleBuffers(true);
   }
   if (shallUsePBuffer) {
     caps.setPBuffer(true);
   }
   if (shallUseBitmap) {
     caps.setBitmap(true);
   }
   runTestGL(caps);
 }
 protected void loadTexture() {
   try {
     BufferedImage image = ImageIO.read(new File("images/raindrop.png"));
     texture = AWTTextureIO.newTexture(GLProfile.getDefault(), image, true);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
예제 #3
0
 @Test
 public void test05_BitmapNorm()
     throws AWTException, InterruptedException, InvocationTargetException {
   if (manualTest) {
     return;
   }
   final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
   caps.setBitmap(true);
   runTestGL(caps);
 }
예제 #4
0
 @Test
 public void test02_DefaultMsaa()
     throws AWTException, InterruptedException, InvocationTargetException {
   if (manualTest) {
     return;
   }
   final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
   caps.setNumSamples(4);
   caps.setSampleBuffers(true);
   runTestGL(caps);
 }
예제 #5
0
  @Test
  public void test99_PixelScale1_DefaultNorm()
      throws AWTException, InterruptedException, InvocationTargetException {
    if (manualTest) {
      return;
    }
    reqSurfacePixelScale[0] = ScalableSurface.IDENTITY_PIXELSCALE;
    reqSurfacePixelScale[1] = ScalableSurface.IDENTITY_PIXELSCALE;

    final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
    runTestGL(caps);
  }
예제 #6
0
  public MyFrame() {
    glprof_ = GLProfile.getDefault();
    glcap_ = new GLCapabilities(glprof_);

    camera_ = new Camera();
    light_ = new Light();

    terrain_ = new Terrain();

    input_ = new Input();

    initUI();
  }
예제 #7
0
  void test01GLDebug01EnableDisable(final boolean enable) throws InterruptedException {
    final GLProfile glp = GLProfile.getDefault();

    final WindowContext winctx = createWindow(glp, enable);
    final String glDebugExt = winctx.context.getGLDebugMessageExtension();
    System.err.println("glDebug extension: " + glDebugExt);
    System.err.println("glDebug enabled: " + winctx.context.isGLDebugMessageEnabled());
    System.err.println("glDebug sync: " + winctx.context.isGLDebugSynchronous());
    System.err.println("context version: " + winctx.context.getGLVersion());

    Assert.assertEquals(
        (null == glDebugExt) ? false : enable, winctx.context.isGLDebugMessageEnabled());

    destroyWindow(winctx);
  }
예제 #8
0
파일: jogl.java 프로젝트: jpmaligne/Jogl
  public static void main(String[] args) {
    GLProfile glp = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(glp);
    GLCanvas canvas = new GLCanvas(caps);
    cube unCube = new cube();
    canvas.addGLEventListener(unCube);
    Frame frame = new Frame("AWT Window Test");
    FPSAnimator anim = new FPSAnimator(canvas, 60);
    anim.start();
    frame.setSize(400, 400);
    frame.add(canvas);
    frame.setVisible(true);

    frame.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub
            int keyCode = e.getKeyCode();
            unCube.handleKeyPress(keyCode); // Here is the handleKeyPress function's call
            frame.add(canvas);
          }

          @Override
          public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub

          }
        });

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
  public static void main(String[] args) {
    GLProfile glprofile = GLProfile.getDefault();
    GLCapabilities glcapabilities = new GLCapabilities(glprofile);
    final GLCanvas glcanvas = new GLCanvas(glcapabilities);

    glcanvas.addGLEventListener(
        new GLEventListener() {

          @Override
          public void reshape(GLAutoDrawable glautodrawable, int x, int y, int width, int height) {
            OneTriangle.setup(glautodrawable.getGL().getGL2(), width, height);
          }

          @Override
          public void init(GLAutoDrawable glautodrawable) {}

          @Override
          public void dispose(GLAutoDrawable glautodrawable) {}

          @Override
          public void display(GLAutoDrawable glautodrawable) {
            OneTriangle.render(
                glautodrawable.getGL().getGL2(),
                glautodrawable.getSurfaceWidth(),
                glautodrawable.getSurfaceHeight());
          }
        });

    // "One Triangle Swing GLCanvas JWindow"
    final JWindow jwindow = new JWindow();
    jwindow.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent windowevent) {
            jwindow.dispose();
            System.exit(0);
          }
        });

    jwindow.getContentPane().add(glcanvas, BorderLayout.CENTER);
    jwindow.setSize(640, 480);
    jwindow.setVisible(true);
  }
예제 #10
0
  @Test
  public void test02GLDebugError() throws InterruptedException {
    final GLProfile glp = GLProfile.getDefault();

    final WindowContext winctx = createWindow(glp, true);

    final MyGLDebugListener myGLDebugListener =
        new MyGLDebugListener(
            GL2ES2.GL_DEBUG_SOURCE_API, GL2ES2.GL_DEBUG_TYPE_ERROR, GL2ES2.GL_DEBUG_SEVERITY_HIGH);
    winctx.context.addGLDebugListener(myGLDebugListener);

    final GL gl = winctx.context.getGL();

    gl.glBindFramebuffer(-1, -1); // ERROR !

    if (winctx.context.isGLDebugMessageEnabled()) {
      Assert.assertEquals(true, myGLDebugListener.received());
    }

    destroyWindow(winctx);
  }
예제 #11
0
  @Test
  public void test03GLDebugInsert() throws InterruptedException {
    final GLProfile glp = GLProfile.getDefault();
    final WindowContext winctx = createWindow(glp, true);
    final MyGLDebugListener myGLDebugListener = new MyGLDebugListener(dbgTstMsg0, dbgTstId0);
    winctx.context.addGLDebugListener(myGLDebugListener);

    final String glDebugExt = winctx.context.getGLDebugMessageExtension();
    Assert.assertEquals(
        (null == glDebugExt) ? false : true, winctx.context.isGLDebugMessageEnabled());

    if (winctx.context.isGLDebugMessageEnabled()) {
      winctx.context.glDebugMessageInsert(
          GL2ES2.GL_DEBUG_SOURCE_APPLICATION,
          GL2ES2.GL_DEBUG_TYPE_OTHER,
          dbgTstId0,
          GL2ES2.GL_DEBUG_SEVERITY_MEDIUM,
          dbgTstMsg0);
      Assert.assertEquals(true, myGLDebugListener.received());
    }

    destroyWindow(winctx);
  }
  protected void runJOGLTasks(
      final int animThreadCount,
      final int frameCount,
      final int reszThreadCount,
      final int resizeCount)
      throws InterruptedException {
    final GLWindow glWindow = GLWindow.create(new GLCapabilities(GLProfile.getDefault()));
    final MyEventCounter myEventCounter = new MyEventCounter();

    glWindow.addGLEventListener(new GearsES2(0));
    glWindow.addGLEventListener(myEventCounter);
    glWindow.setSize(demoSize, demoSize);
    glWindow.setVisible(true);

    final String currentThreadName = Thread.currentThread().getName();
    final Object sync = new Object();
    final MyRunnable[] animTasks = new MyRunnable[animThreadCount];
    final MyRunnable[] resizeTasks = new MyRunnable[animThreadCount];
    final Thread[] animThreads = new Thread[reszThreadCount];
    final Thread[] resizeThreads = new Thread[reszThreadCount];

    System.err.println("animThreadCount " + animThreadCount + ", frameCount " + frameCount);
    System.err.println("reszThreadCount " + reszThreadCount + ", resizeCount " + resizeCount);
    System.err.println(
        "tasks "
            + (animTasks.length + resizeTasks.length)
            + ", threads "
            + (animThreads.length + resizeThreads.length));

    for (int i = 0; i < animThreadCount; i++) {
      System.err.println("create anim task/thread " + i);
      animTasks[i] = new RudeAnimator(glWindow, frameCount, sync, i);
      animThreads[i] = new Thread(animTasks[i], currentThreadName + "-anim" + i);
    }
    for (int i = 0; i < reszThreadCount; i++) {
      System.err.println("create resz task/thread " + i);
      resizeTasks[i] = new RudeResizer(glWindow, resizeCount, sync, i);
      resizeThreads[i] = new Thread(resizeTasks[i], currentThreadName + "-resz" + i);
    }

    myEventCounter.reset();

    int j = 0, k = 0;
    for (int i = 0; i < reszThreadCount + animThreadCount; i++) {
      if (0 == i % 2) {
        System.err.println("start resize thread " + j);
        resizeThreads[j++].start();
      } else {
        System.err.println("start anim thread " + k);
        animThreads[k++].start();
      }
    }
    synchronized (sync) {
      while (!done(resizeTasks) || !done(animTasks)) {
        try {
          sync.wait();
        } catch (final InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
    }
    int i = 0;
    while (i < 30 && !isDead(animThreads) && !isDead(resizeThreads)) {
      Thread.sleep(100);
      i++;
    }

    glWindow.destroy();
  }