Exemple #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);
  }
Exemple #2
0
void OpenGLContext::ResizeContext(int width, int height)
{
    CCLOG("OpenGLContext::ResizeContext %dx%d", width, height);
    _size.SetSize(width, height);
    if (!_graphics3d.is_null())
    {
        _graphics3d.ResizeBuffers(width, height);
    }
}