Home › Forums › Syphon › Syphon Development – Developer › Code help with Syphon enabled browser
- This topic has 2 replies, 2 voices, and was last updated 7 years, 5 months ago by bangnoise.
-
AuthorPosts
-
October 10, 2013 at 11:43 am #34594UdartParticipant
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.
October 14, 2013 at 2:09 am #34874UdartParticipantNevermind – I figured it out. I will hopefully be releasing something soon.
October 14, 2013 at 1:08 pm #34889bangnoiseKeymasterCool – sorry neither of us got around to looking at this sooner.
-
AuthorPosts
- You must be logged in to reply to this topic.