Code help with Syphon enabled browser

Home Forums Syphon Syphon Development – Developer Code help with Syphon enabled browser

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34594
    Udart
    Participant

    As mentioned in a previous thread I have managed to create a Chrome-based web browser that outputs Syphon. You can get it here.

    https://github.com/vibber/CefWithSyphon

    However I would like to enable Syphon outputs that are bigger than what fits on the main screen, and right now my browser window size and the Syphon size are linked. So whenever I resize my browser window the Syphon output resizes. How would be the best way to enable very big Syphon outputs while displaying a scaled version in the browser window? As osx windows generally cannot be taller than the display they are on, I currently have no way of outputting big Syphon sizes the way they are currently linked.

    I have included the relevant place in the code below – but I would also appreciate more general advice on the best approach.

    void ClientOSRHandler::OnPaint(CefRefPtr<CefBrowser> browser,
                                   PaintElementType type,
                                   const RectList& dirtyRects,
                                   const void* buffer,
                                   int width, int height) {
        
        unsigned int texId;
        
      REQUIRE_UI_THREAD();
    
      if (!view_)
        return;
    
      if (painting_popup_) {
        RectList scaled_dirty_rects;
        NSSize scaled_size = NSMakeSize(0, 0);
        [view_ convertRects:dirtyRects
             toBackingRects:&scaled_dirty_rects
                    andSize:NSMakeSize(width, height)
              toBackingSize:&scaled_size];
        view_->renderer_->OnPaint(browser, type, scaled_dirty_rects, buffer,
                                  scaled_size.width, scaled_size.height);
        return;
      }
    
      NSOpenGLContext* context = [view_ openGLContext];
      [context makeCurrentContext];
    
      RectList scaled_dirty_rects;
    
        NSSize scaled_size = NSMakeSize(0, 0);
    
      [view_ convertRects:dirtyRects
           toBackingRects:&scaled_dirty_rects
                  andSize:NSMakeSize(width, height)
            toBackingSize:&scaled_size];
    
        
      texId = view_->renderer_->OnPaint(browser, type, scaled_dirty_rects, buffer,
                                scaled_size.width, scaled_size.height);
        
      if (type == PET_VIEW && !view_->renderer_->popup_rect().IsEmpty()) {
        painting_popup_ = true;
        CefRect client_popup_rect(0, 0,
                                  view_->renderer_->popup_rect().width,
                                  view_->renderer_->popup_rect().height);
    
        CefRect scaled_popup_rect =
            [view_ convertRectFromBackingInternal:client_popup_rect];
    
        browser->GetHost()->Invalidate(scaled_popup_rect, PET_POPUP);
        painting_popup_ = false;
      }
    //syph start - publish syphon frame
        // We only publish our frame if we have clients
        if ([syServer hasClients])
        {
            NSRect rect = NSMakeRect(0, 0, view_->renderer_->GetViewWidth(), view_->renderer_->GetViewHeight());
            
            // publish our frame to our server. We use the whole texture, but we could just publish a region of it
            CGLLockContext(syServer.context);
            [syServer publishFrameTexture:texId
                            textureTarget:GL_TEXTURE_2D //was GL_TEXTURE_RECTANGLE_EXT
                              imageRegion:rect
                        textureDimensions:rect.size
                                  flipped:YES];
            CGLUnlockContext(syServer.context);
        }
    //syph end
        
        
        view_->renderer_->Render();
        
      [context flushBuffer];
    }
    • This topic was modified 7 years, 5 months ago by Udart.
    #34874
    Udart
    Participant

    Nevermind – I figured it out. I will hopefully be releasing something soon.

    #34889
    bangnoise
    Keymaster

    Cool – sorry neither of us got around to looking at this sooner.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.