コード例 #1
0
ファイル: MovieCubeActivity0.java プロジェクト: petr-s/jogl
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] urls0 =
        new String[] {
          System.getProperty("jnlp.media0_url2"),
          System.getProperty("jnlp.media0_url1"),
          System.getProperty("jnlp.media0_url0")
        };
    final URLConnection urlConnection0 = getResource(urls0, 0);
    if (null == urlConnection0) {
      throw new RuntimeException("no media reachable: " + Arrays.asList(urls0));
    }

    // also initializes JOGL
    final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2());
    capsMain.setBackgroundOpaque(false);

    // screen for layout params ..
    final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null);
    final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0);
    scrn.addReference();

    try {
      final Animator animator = new Animator();

      // Main
      final MovieCube demoMain =
          new MovieCube(
              urlConnection0,
              GLMediaPlayer.STREAM_ID_AUTO,
              GLMediaPlayer.STREAM_ID_AUTO,
              -2.3f,
              0f,
              0f);
      final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
      glWindowMain.setFullscreen(true);
      setContentView(getWindow(), glWindowMain);
      glWindowMain.addMouseListener(showKeyboardMouseListener);
      glWindowMain.addGLEventListener(demoMain);
      animator.add(glWindowMain);
      glWindowMain.setVisible(true);

      // animator.setUpdateFPSFrames(60, System.err);
      animator.setUpdateFPSFrames(-1, null);
      animator.resetFPSCounter();
    } catch (IOException e) {
      e.printStackTrace();
    }

    scrn.removeReference();

    Log.d(TAG, "onCreate - X");
  }
コード例 #2
0
ファイル: Bug735Inv0AppletAWT.java プロジェクト: metsci/jogl
  private void initGL() {
    GLProfile profile = GLProfile.getDefault();
    GLCapabilities caps = new GLCapabilities(profile);
    caps.setBackgroundOpaque(true);
    caps.setOnscreen(true);
    caps.setSampleBuffers(false);

    if (TOOLKIT == AWT) {
      awtCanvas = new GLCanvas(caps);
      awtCanvas.setBounds(0, 0, applet.width, applet.height);
      awtCanvas.setBackground(new Color(0xFFCCCCCC, true));
      awtCanvas.setFocusable(true);

      applet.setLayout(new BorderLayout());
      applet.add(awtCanvas, BorderLayout.CENTER);

      if (MANUAL_FRAME_HANDLING) {
        awtCanvas.setIgnoreRepaint(true);
        awtCanvas.setAutoSwapBufferMode(false);
      }
    } else if (TOOLKIT == NEWT) {
      newtWindow = GLWindow.create(caps);
      newtCanvas = new NewtCanvasAWT(newtWindow);
      newtCanvas.setBounds(0, 0, applet.width, applet.height);
      newtCanvas.setBackground(new Color(0xFFCCCCCC, true));
      newtCanvas.setFocusable(true);

      applet.setLayout(new BorderLayout());
      applet.add(newtCanvas, BorderLayout.CENTER);

      if (MANUAL_FRAME_HANDLING) {
        newtCanvas.setIgnoreRepaint(true);
        newtWindow.setAutoSwapBufferMode(false);
      }
    }
  }
コード例 #3
0
  /**
   * Constructor for this class. Sets up the window and enables common features like anti-aliasing
   * and hardware acceleration.
   *
   * @param forceGL2ES2 Force GL2ES2 support (default on), currently Unused
   * @param inputHandler A predefined InputHandler that is added as event handler for input events.
   * @param glEventListener A predefined GLEventListener that is added as event handler for openGL
   *     events.
   * @param width The initial window width.
   * @param height The initial window height.
   * @param windowTitle The window title.
   */
  public ESightNewtWindow(
      boolean forceGL2ES2,
      InputHandler inputHandler,
      final GLEventListener glEventListener,
      int width,
      int height,
      String windowTitle) {
    final GLProfile glp;
    // if (forceGL2ES2) {
    // glp = GLProfile.get(GLProfile.GL2ES2);
    // } else {
    glp = GLProfile.get(GLProfile.GL3);
    // }

    // Set up the GL context
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setBackgroundOpaque(true);
    caps.setHardwareAccelerated(true);
    caps.setDoubleBuffered(true);

    // Add Anti-Aliasing
    caps.setSampleBuffers(true);
    caps.setAlphaBits(4);
    caps.setNumSamples(4);

    // Create the Newt Window
    Display dpy = NewtFactory.createDisplay(null);
    Screen screen = NewtFactory.createScreen(dpy, screenIdx);
    final GLWindow glWindow = GLWindow.create(screen, caps);

    glWindow.setTitle(windowTitle);

    // Add listeners
    glWindow.addMouseListener(inputHandler);
    glWindow.addKeyListener(inputHandler);
    // glWindow.setFullscreen(true);

    WindowListener[] listeners = glWindow.getWindowListeners();
    final WindowListener original = listeners[0];
    glWindow.addWindowListener(
        0,
        new WindowAdapter() {
          @Override
          public void windowDestroyNotify(WindowEvent arg0) {
            glWindow.getAnimator().stop();
            System.exit(0);
          }

          @Override
          public void windowDestroyed(WindowEvent arg0) {
            glWindow.getAnimator().stop();
            System.exit(0);
          }

          @Override
          public void windowGainedFocus(WindowEvent arg0) {
            original.windowGainedFocus(arg0);
          }

          @Override
          public void windowLostFocus(WindowEvent arg0) {
            original.windowLostFocus(arg0);
          }

          @Override
          public void windowMoved(WindowEvent arg0) {
            original.windowMoved(arg0);
          }

          @Override
          public void windowRepaint(WindowUpdateEvent arg0) {
            original.windowRepaint(arg0);
          }

          @Override
          public void windowResized(WindowEvent arg0) {
            original.windowResized(arg0);
          }
        });

    glWindow.addGLEventListener(glEventListener);

    // Create the Animator
    final Animator animator = new Animator();
    animator.add(glWindow);
    animator.start();

    glWindow.setSize(width, height);

    glWindow.setVisible(true);
  }