How do I set the Viewport in directx / c#?

I want to render into a portion of my window. I'm assuming that you use the Viewport structure but I can't find any examples. I'm using a camera based on the dxut camera from the sample framework.

I can do this in openGL but can't seem to figure out the way to do it here. Any help would be appreciated.



Answer this question

How do I set the Viewport in directx / c#?

  • Smartway

    Depends on which version of DirectX you are talking about. I will give you a hint in both directions.

    C#
    Viewport v = new Viewport();
    v.Width = 512;
    v.Height = 512;
    v.MaxZ = 1.0f;
    v.MinZ = 0.0f;
    Device.Viewport = v;

    c++
    D3DVIEWPORT9* v;
    v->Width = 512;
    v->Height = 512;
    v->MaxZ = 1.0f;
    v->MinZ = 0.0f;
    IDirect3DDevice9::SetViewport(v);

    I hope this helps.
    Take care.


  • myaspng

    Thanks Pieter,

    I was kind of thinking there might be some built in function for setting the whole lot. But that's great. Thanks for the quick response.

    Cheers.


  • How do I set the Viewport in directx / c#?