[SOLVED] Render to texture

Hi.
Create texture and surface thus:

[code] Node* nodeCameraTarget = gScene->CreateChild(“CameraTarget”);
Camera* cameraTarget = nodeCameraTarget->CreateComponent();
cameraTarget->SetNearClip(1.0f);
cameraTarget->SetFarClip(radiusDetect);

SharedPtr<Texture2D> renderTexture = new Texture2D(gContext);
renderTexture->SetSize(SIZE_WINDOW_TARGET, SIZE_WINDOW_TARGET, D3DFMT_X8R8G8B8, Urho3D::TEXTURE_RENDERTARGET);
renderTexture->SetFilterMode(Urho3D::FILTER_DEFAULT);

SharedPtr<RenderSurface> renderSurface = renderTexture->GetRenderSurface();
SharedPtr<Viewport> viewport(new Viewport(gContext, gScene, cameraTarget));
renderSurface->SetViewport(0, viewport);
renderSurface->SetUpdateMode(Urho3D::SURFACE_UPDATEALWAYS);[/code]

In event E_POSTRENDERUPDATE call

contents buffer is 0xcd, 0xcd, 0xcd …

renderTexture It is stored separately, the image from it is planned to bring to UI.

[quote=“Sinoid”]Can you post the code for this “buffer” you’re passing in?

Many thanks! Parameter D3DFMT_X8R8G8B8 was wrong (And how I could forget to look at the log?)
Returned to an initial state Graphics::GetRGBFormat() and everything earned.
Thanks very big!

Very useful remarks.
Thanks.