Пример #1
0
  virtual void DidChangeView(const pp::View& view) {
    // Pepper specifies dimensions in DIPs (device-independent pixels). To
    // generate a context that is at device-pixel resolution on HiDPI devices,
    // scale the dimensions by view.GetDeviceScale().
    int32_t new_width = view.GetRect().width() * view.GetDeviceScale();
    int32_t new_height = view.GetRect().height() * view.GetDeviceScale();

    if (context_.is_null()) {
      if (!InitGL(new_width, new_height)) {
        // failed.
        return;
      }

      verify(gles_init() == true);
      RenderLoop(0);
    } else {
      // Resize the buffers to the new size of the module.
      int32_t result = context_.ResizeBuffers(new_width, new_height);
      if (result < 0) {
        printf("Unable to resize buffers to %d x %d!\n");
        return;
      }
    }

    width_ = new_width;
    height_ = new_height;
    glViewport(0, 0, width_, height_);
    printf("Resize: %d x %d\n", new_width, new_height);
  }
Пример #2
0
void DiagrammarInterface::DidChangeView(const pp::View& view) {
  int32_t width = view.GetRect().width();
  int32_t height = view.GetRect().height();
  std::cerr << "view changed\n";
  if (context_.is_null()) {
    if (!InitGL(width, height)) {
      return;
    }
    // only launch once (created with opengl context)
    simulation_thread_ = std::thread(&DiagrammarInterface::LaunchWorld, this);
  } else {
    int32_t result = context_.ResizeBuffers(width, height);
    if (result < 0) std::cerr << "Unable to resize\n";
  }
}
Пример #3
0
void NaCl::DidChangeView(const pp::View& view) {
    int32_t new_width = view.GetRect().width() * view.GetDeviceScale();
    int32_t new_height = view.GetRect().height() * view.GetDeviceScale();

    if(context.is_null()) {
        if(!init(new_width,new_height)) {
            lerr << "Failed to init opengl" << endl;
            return;
        }

        lout << "Success on opengl" << endl;
        loop(0);
    } else {
        int32_t result = context.ResizeBuffers(new_width, new_height);
        if(result < 0) {
            lerr << "Unsuccesful view change" << endl;
        } else {
            game.resize(new_width, new_height);
        }
    }
}
Пример #4
0
void NaClApplication::DidChangeView(const pp::View& view) {
    /* Fullscreen switch in progress */
    if(_flags & Flag::FullscreenSwitchInProgress) {
        /* Done, remove the progress flag */
        if(isFullscreen() == bool(_flags & Flag::WillBeFullscreen)) {
            _flags &= ~Flag::FullscreenSwitchInProgress;
            _flags |= Flag::Redraw;
        }

        /* Don't process anything during the switch */
        else return;
    }

    Vector2i size(view.GetRect().width(), view.GetRect().height());

    /* Canvas resized */
    if(_viewportSize != size) {
        _graphics->ResizeBuffers(size.x(), size.y());
        viewportEvent(_viewportSize = size);
    }

    drawEvent();
}