Hi Petros, sorry for getting late here.
I've tried to replicate the behavior you're reporting, but unfortunately I've succeeded in.
The way i usually handle buffer fill-up in VPData is :
...
VPBuffer* rgba = render->GetBuffer(VPBUFFER_RGBA, 0);
Int32 rgbaBufferCPP = NOTOK, rgbaBufferDepth = NOTOK, rgbaBufferWidth = NOTOK, rgbaBufferHeight = NOTOK;
if (rgba)
{
rgbaBufferCPP = rgba->GetInfo(VPGETINFO::CPP);
rgbaBufferDepth = rgba->GetInfo(VPGETINFO::BITDEPTH);
rgbaBufferWidth = rgba->GetInfo(VPGETINFO::XRESOLUTION);
rgbaBufferHeight = rgba->GetInfo(VPGETINFO::YRESOLUTION);
DiagnosticOutput("rgbaBuffer: @ / @ / @ / @", rgbaBufferCPP, rgbaBufferDepth, rgbaBufferWidth, rgbaBufferHeight);
if (rgbaBufferDepth == 32)
{
iferr (rgbaBuffer = NewMemClear(Float32, rgbaBufferWidth * rgbaBufferCPP))
{
CriticalOutput("Failed to allocate rgba 32-bit buffer");
return RENDERRESULT::OUTOFMEMORY;
};
}
else
{
iferr (rgbaBuffer = NewMemClear(UChar, rgbaBufferWidth * rgbaBufferCPP))
{
CriticalOutput("Failed to allocate rgba 8-bit buffer");
return RENDERRESULT::OUTOFMEMORY;
};
}
}
Float percent = 0.0;
while (percent < 1.0)
{
for (Int32 i = 0; i < rgbaBufferHeight; i++)
{
if (rgbaBuffer)
{
if (rgbaBufferDepth == 32)
r_gigante::FillBufferWithRandomValues((Float32*)rgbaBuffer, rgbaBufferWidth, rgbaBufferCPP);
else
r_gigante::FillBufferWithRandomValues((UChar*)rgbaBuffer, rgbaBufferWidth, rgbaBufferCPP);
rgba->SetLine(0, i, rgbaBufferWidth, rgbaBuffer, rgbaBufferDepth, true);
}
if (thread->TestBreak())
{
if (rgbaBuffer)
DeleteMem(rgbaBuffer);
return RENDERRESULT::USERBREAK;
}
}
}
...
where FillBufferWithRandomValues is
void FillBufferWithRandomValues(Float32* buffer, UInt32 bufferSize, UInt32 channels/* = 4*/)
{
Random rng;
rng.Init(UInt32(rand()));
if (channels == 4)
{
for (UInt32 i = 0; i < bufferSize; i++)
{
buffer[i * channels + 0] = Float32(rng.Get01());
buffer[i * channels + 1] = Float32(rng.Get01());
buffer[i * channels + 2] = Float32(rng.Get01());
buffer[i * channels + 3] = Float32(0);
}
return;
}
if (channels == 3)
{
for (UInt32 i = 0; i < bufferSize; i++)
{
buffer[i * channels + 0] = Float32(rng.Get01());
buffer[i * channels + 1] = Float32(rng.Get01());
buffer[i * channels + 2] = Float32(rng.Get01());
}
return;
}
if (channels == 1)
{
for (UInt32 i = 0; i < bufferSize; i++)
{
buffer[i * channels + 0] = Float32(rng.Get01());
}
return;
}
}
(NOTE - in my code the FillBufferWithRandomValues has definition for both 8-bit and 32-bit buffers)
If you can provide with a complete example showing your issue, I'd be glad to look into, but being blind to your code I really can't be more helpful.
With regard to the second question, I think the above code properly answers here.
In case you got your issue fixed, please mark this thread as solved.
Best, Riccardo