---
title: "Interactive Viewport Rendering"
canonical: "https://documentation.chaos.com/space/APPSDK/776994829/Interactive%20Viewport%20Rendering"
format: markdown
---
This page describes the Interactive Viewport Rendering, which V-Ray supports. 


## **Overview**

---

In most cases, Interactive rendering is used to display the current state of the rendered image in close to real time. And while you can view it in the built-in V-Ray VFB window, you may want to show it in another one, e.g., inside the host application. (And in some cases, you may even want to fully disable the GUI part of V-Ray and not have the VFB at all, but still show all interactive image updates.)


In order to receive the most recent image, you need to register an event handler (or a callback) for the ProgressiveImageUpdated event and enable passing images to it:

<details>
<summary>Python</summary>

```python
def onNewImage(renderer, image, changeIndex, renderPass, instant):
  # Use image here
renderer.setProgressiveImageUpdatedHasBuffer(True)
renderer.setOnProgressiveImageUpdated(onNewImage)
```
</details>

<details>
<summary>C++</summary>

```c++
void onNewImage(VRayRenderer& renderer, VRayImage* image, unsigned long long changeIndex, ImagePassType pass, double instant, void* userObject) {
  // Use image here
}
renderer.setProgressiveImageUpdatedHasBuffer(true)
renderer.setOnProgressiveImageUpdated(onNewImage)
```
</details>

<details>
<summary>C#.NET</summary>

```csharp
function onNewImage(image, changeIndex, pass, instant) {
  // Use image here
}
renderer.progressiveImageUpdatedHasBuffer = true;
renderer.on('progressiveImageUpdated', onNewImage);
```
</details>

<details>
<summary>Node.js</summary>

```javascript
renderer.ProgressiveImageUpdatedHasBuffer = True;
renderer.ProgressiveImageUpdated += new EventHandler<VRayImageEventArgs>((source, e) =>
{
  // Use image here
}
```
</details>


Using the image provided in the **ProgressiveImageUpdated** event instead of calling **renderer.getImage()** inside the handler ensures there is no tearing or desync between the RGB and Alpha channels.

> ⚠️ Starting with V-Ray for AppSDK 7.30, the image provided in the ProgressiveImageUpdated event / callback is always "the best" one for viewport rendering - **we automatically switch to the RGB or EffectsResult channel** (which includes the Denoiser) with color corrections applied.

If you want to revert to the old behavior, call the new method:

<details>
<summary>C++</summary>

```c++
renderer.setProgressiveImageUpdatedDataType(RenderElement::COLOR, RenderElement::DI_INTENT_FILE_NO_COLOR_CORRECTIONS);
```
</details>

<details>
<summary>C#.NET</summary>

```csharp
renderer.SetProgressiveImageUpdatedDataType(RenderElement.COLOR, RenderElement.DataIntent.FILE_NO_COLOR_CORRECTIONS);
```
</details>

  
This method allows you to select any render channel to receive data from, whether you want color corrections applied, etc.  


> ℹ️ Calling **setProgresiveImageUpdatedHasBuffer()** is redundant in case you call **setProgressiveImageUpdatedDataType()** because it automatically alters the **imageUpdatedHasBuffer** flag.


### **Drawing VRayImage to Bitmap**

---

Because VRayImage pixels are of type AColor, i.e., their RGBA components are float numbers, they often need to be converted to 8-bit unsigned integers suitable for regular bitmaps. There are a few methods to facilitate that functionality:

In addition to the already available method **VRayImage::toBitmapData(..) **in previous versions, in v7.30 we introduced **drawToBitmap(..)** to enable simultaneous conversion and drawing (optionally with alpha-blending) to a pre-allocated bitmap memory buffer whose size can be the same or larger than the drawn image. The drawToBitmap() method is available only in v7.30 in C++ and in the Win32 version of .NET (because the System.Drawing.Bitmap type is available only there).