Drawing with the debugRenderer

Im trying to draw some geometry with the debugRenderer

   SubscribeToEvent(E_POSTRENDERUPDATE, URHO3D_HANDLER(MyApp, DrawDebug));

    scene_ = new Scene(context_);
    debugRenderer_ = scene_->CreateComponent<DebugRenderer>();

    // Let the scene have an Octree component!

    // We need a camera from which the viewport can render.
    cameraNode_ = scene_->CreateChild("Camera");
    Camera* camera = cameraNode_->CreateComponent<Camera>();
    // Now we setup the viewport. Of course, you can have more than one!
    Renderer* renderer = GetSubsystem<Renderer>();
    SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
    renderer->SetViewport(0, viewport);
void MyApp::DrawDebug(StringHash eventType, VariantMap& eventData)
    debugRenderer_->AddLine(Vector3(-10, -10, -100), Vector3(10, 10,100), Color(255,0,0), false);

But im not seeing anything. Am i missing a step or is my geometry simply not on screen?

Is the camera pointed at the line?

1 Like

It turns out my camera was not pointing at the line, now it works fine, thanks

1 Like