I obtain Data from another renderer as unsigned char * Data and I create Texture and display it. Problem is, colors are not ok, blue text is red and green is blue.
Here is my code how I create texture
void WG::WGUI::mf_GetRender(unsigned char *& data, double width, double height)
{
IntPtr pdata = static_cast<IntPtr>(data);
mainWindow->UserC->mf_RenderControl(width, height, pdata);
}
// Inside urho Start();
image = new Urho3D::Image(context_);
double width = 1024;
double height = 512;
int RGBA = 4;
image->SetSize((int)width, (int)height, 4);
DATA = (unsigned char *)malloc(width * height * RGBA);
WG::WGUI::wgui->mf_GetRender(DATA, width, height);
image->SetData(DATA);
texture = new Urho3D::Texture2D(context_);
texture->SetFilterMode(Urho3D::TextureFilterMode::FILTER_BILINEAR);
texture->SetNumLevels(1);
texture->SetSize(image->GetWidth(), image->GetHeight(), Urho3D::Graphics::GetRGBAFormat(), Urho3D::TEXTURE_DYNAMIC);
texture->SetData(0, 0, 0, image->GetWidth(), image->GetHeight(), image->GetData());
Urho3D::Sprite * sprite = GetSubsystem<Urho3D::UI>()->GetRoot()->CreateChild<Urho3D::Sprite>();
sprite->SetTexture(texture);
sprite->SetSize(image->GetWidth(), image->GetHeight());
sprite->SetBlendMode(Urho3D::BlendMode::BLEND_ALPHA);