Jump to content

Take screenshot of a camera in UnigineScript 2.19


photo

Recommended Posts

Posted

Hi,

I was trying to save an image of what a camera sees and i don't see something similar as we can do in C++ like save a texture or image.

I saw this example in Viewport class but i need to save the image

// initialization
Viewport viewport = new Viewport();

Texture texture = new Texture();
texture.create2D(512, 512, TEXTURE_FORMAT_RGBA8);// create 512 x 512 render target

CameraPtr camera = new Camera();
// set modelview & projection matrices to camera instance

// rendering an image from the camera to the texture
viewport.renderTexture2D(camera, texture);

Witch is the best way to take a screenshot and save it using UnigineScript in 2.19?

Posted

Hi Alberto,

Unfortunately, there is no way to transfer texture to image from UnigineScript. New graphical APIs are far more complex and deprecated UnigineScript is not designed to handle their complexity (there are no callbacks and access to the textures). So you can only do it from C++ / C# APIs.

However, if your only goal to take a snapshot of the current window (main window) you can do it via few lines of code:

EngineWindow window = engine.window_manager.getMainWindow();
window.screenshot("grab.png");

image.png

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...