/**
  * Creates a SurfaceData object representing the back buffer of a double-buffered on-screen
  * Window.
  */
 public static D3DSurfaceData createData(WComponentPeer peer, Image image) {
   D3DGraphicsConfig gc = getGC(peer);
   if (gc == null || !peer.isAccelCapable()) {
     return null;
   }
   BufferCapabilities caps = peer.getBackBufferCaps();
   VSyncType vSyncType = VSYNC_DEFAULT;
   if (caps instanceof ExtendedBufferCapabilities) {
     vSyncType = ((ExtendedBufferCapabilities) caps).getVSync();
   }
   Rectangle r = peer.getBounds();
   BufferCapabilities.FlipContents flip = caps.getFlipContents();
   int swapEffect;
   if (flip == FlipContents.COPIED) {
     swapEffect = SWAP_COPY;
   } else if (flip == FlipContents.PRIOR) {
     swapEffect = SWAP_FLIP;
   } else { // flip == FlipContents.UNDEFINED || .BACKGROUND
     swapEffect = SWAP_DISCARD;
   }
   return new D3DSurfaceData(
       peer,
       gc,
       r.width,
       r.height,
       image,
       peer.getColorModel(),
       peer.getBackBuffersNum(),
       swapEffect,
       vSyncType,
       FLIP_BACKBUFFER);
 }
  public FrameRenderer(final JFrame target, boolean isFullscreen, RenderFitMode renderFitMode) {
    m_renderTarget = target;
    m_renderFitMode = renderFitMode;

    m_renderTarget.setSize(target.getSize());

    m_canvasRenderWidth = target.getWidth();
    m_canvasRenderHeight = target.getHeight();

    target.setIgnoreRepaint(true);
    target.createBufferStrategy(2);
    m_bufferStrategy = target.getBufferStrategy();

    BufferCapabilities cap = m_bufferStrategy.getCapabilities();

    if (!cap.getBackBufferCapabilities().isAccelerated())
      m_logger.warn("Backbuffer is not accelerated, may result in poorer render performance.");

    if (!cap.isPageFlipping())
      m_logger.warn(
          "Page flipping is not supported by this device. This may result in increased image flicker or tearing.");

    if (!cap.isMultiBufferAvailable())
      m_logger.warn(
          "Multiple buffering for page flipping is not supported by this device. This may result in poorer performance.");

    if (cap.isFullScreenRequired() && !isFullscreen)
      m_logger.warn(
          "Full screen required for hardware acceleration - not running in fullscreen may cause performance issues.");

    if (isFullscreen) {
      enterFullscreen();

      target.addKeyListener(
          new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {}

            @Override
            public void keyReleased(KeyEvent e) {}

            @Override
            public void keyPressed(KeyEvent e) {
              if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                GraphicsDevice device = target.getGraphicsConfiguration().getDevice();

                Window fullscreen = device.getFullScreenWindow();

                if (fullscreen != target) fullscreen = null;

                if (fullscreen == null) enterFullscreen();
                else exitFullscreen();
              }
            }
          });
    }
  }
Example #3
0
 private void gcChanged() {
   GCWrapper wrap = (GCWrapper) gcSelection.getSelectedItem();
   // assert wrap != null;
   GraphicsConfiguration gc = wrap.getGC();
   // assert gc != null;
   // Image Caps
   ImageCapabilities imageCaps = gc.getImageCapabilities();
   imageAccelerated.setSelected(imageCaps.isAccelerated());
   imageTrueVolatile.setSelected(imageCaps.isTrueVolatile());
   // Buffer Caps
   BufferCapabilities bufferCaps = gc.getBufferCapabilities();
   flipping.setSelected(bufferCaps.isPageFlipping());
   flippingMethod.setText(getFlipText(bufferCaps.getFlipContents()));
   fullScreen.setSelected(bufferCaps.isFullScreenRequired());
   multiBuffer.setSelected(bufferCaps.isMultiBufferAvailable());
   // Front buffer caps
   imageCaps = bufferCaps.getFrontBufferCapabilities();
   fbAccelerated.setSelected(imageCaps.isAccelerated());
   fbTrueVolatile.setSelected(imageCaps.isTrueVolatile());
   imageCaps = bufferCaps.getFrontBufferCapabilities();
   // Back buffer caps
   imageCaps = bufferCaps.getBackBufferCapabilities();
   bbAccelerated.setSelected(imageCaps.isAccelerated());
   bbTrueVolatile.setSelected(imageCaps.isTrueVolatile());
 }
Example #4
0
 public String toString() {
   BufferCapabilities b = device.getFullScreenWindow().getBufferStrategy().getCapabilities();
   String cadena = "";
   cadena +=
       "\nInformacion de video:\n"
           + "PageFlipping: "
           + b.isPageFlipping()
           + "\nEs necesario que sea fullscreen para ello: "
           + b.isFullScreenRequired()
           + "\nMultiBuffer: "
           + ((Boolean) (b.isMultiBufferAvailable())).toString()
           + "\n Memoria de video disponible: "
           + device.getAvailableAcceleratedMemory();
   return cadena;
 }
Example #5
0
  /**
   * Attempts to create a GLX-based backbuffer for the given peer. If the requested configuration is
   * not natively supported, an AWTException is thrown. Otherwise, if the backbuffer creation is
   * successful, a value of 1 is returned.
   */
  @Override
  public long createBackBuffer(X11ComponentPeer peer, int numBuffers, BufferCapabilities caps)
      throws AWTException {
    if (numBuffers > 2) {
      throw new AWTException("Only double or single buffering is supported");
    }
    BufferCapabilities configCaps = getBufferCapabilities();
    if (!configCaps.isPageFlipping()) {
      throw new AWTException("Page flipping is not supported");
    }
    if (caps.getFlipContents() == BufferCapabilities.FlipContents.PRIOR) {
      throw new AWTException("FlipContents.PRIOR is not supported");
    }

    // non-zero return value means backbuffer creation was successful
    // (checked in X11ComponentPeer.flip(), etc.)
    return 1;
  }