Rendering a certain section

Started by
5 comments, last by simotix 16 years, 3 months ago
I am making a window system (basically just creating different windows in direct x). I am at the part when I making a creating scroll bar for the data. Basically I have an area of say 800x800. If I only wanted to display the area of 200x200 to 600x600 (so basically an upper portion and a lower portion would not be displayed) how would I do this? I tried changing some of the view matrix variables for this but I have not found anything. Does anyone have a good idea?
Advertisement
You may want to check the DirectX Docs for "scissor test", specifically the SetScissorRect function that allows you to "cut away" a region of the viewing area.
"There is no dark side of the moon." - Pink Floyd
Scissor test or SetViewport, depending on what you want
  oooooo   ????????   ???????? ooooool   ????????   ????????XXXXXXll   ???XXX??   ??? oo??XXXXXXll   ???XXX??   ???xxl??XXXXXXl    ???XXX??   ???xx ??XXXXXX     ????????   ????????

Above is my crude ascii versions of regular, scissortest, or SetViewport.

Regular is a fullscreen 3D cube.

Scissor test limits drawing to a smaller rectangle.

SetViewport draws the full scene to a smaller rectangle, so the output is scaled.

Which method you use depends on how you want the windows to behave. Perhaps you want to support both. Also be aware the things drawn with RHW coordinates won't scale with a viewport.
I have tried doing that but I think I may have implemented it wrong. I tried doing

RECT temp;
SetRect(&temp, m_nX, m_nY, 300, 300); // m_nX = 200, m_nY = 200
pD3D->GetDirect3DDevice()->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
pD3D->GetDirect3DDevice()->SetScissorRect(&temp);

// Render content

pD3D->GetDirect3DDevice()->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);

Below is a small image that shows what I am trying to do.

http://i266.photobucket.com/albums/ii256/simotix/RenderContent.jpg

I want to draw the entire screen but out of the red rectangle I only want to draw the green rectangle (as shown in image).

[Edited by - simotix on January 2, 2008 12:32:39 PM]
Bit of a long-shot, but have you interrogated the device caps' RasterCaps for D3DPRASTERCAPS_SCISSORTEST? My information suggests it's supported by all Nvidia/ATI hardware but I have no details for Intel IGP's.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I have heard of that but I would to have something that would not break on different video cards.
Does anyone else have any suggestions?

This topic is closed to new replies.

Advertisement