Is it possible to save WebGL canvas as image like Chromium?

Discussion of current events and participation in intelligent conversation with other CEF users.

Is it possible to save WebGL canvas as image like Chromium?

Postby RadarNyan » Sat Aug 25, 2018 2:53 am

Hi everyone,

I'm building a special browser for a web game, which uses WebGL to render everything onto on canvas element. I want to save the canvas as image (as a screenshot) but Canvas.toDataURL() doesn't work as the canvas is rendered with WebGL.

I have two ways to workaround this, one is by disable GPU which makes the game fall back to 2D rendering, then I can use Canvas.toDataURL() but the game would run slower and have some visual artifacts. Another is to modify the game / game engine code to force "preserveDrawingBuffer = true" - it's not only unsafe and dirty, but also give me a great performance hit on my old laptop. So I gave up getting image from canvas, just captured what's on screen.

Then I noticed in Chromium, if you right click on a canvas, you can save it as image or copy image to clipboard, I've confirmed it works even with WebGL canvas. How did Chromium do this, can we have this feature in Cef?
Posts: 1
Joined: Sat Aug 25, 2018 2:42 am

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest