is there a way to clip drawed texture? (ID3DXSprite)

Started by
10 comments, last by Craazer 20 years ago
Hi, setting the source rectangle as Draw()''s parameter ins''t an option if you scale the texture. So do you know any ways to clip using ID3DXSprite''s draw method? I''m using the summer SDK.
Advertisement
try using the SetViewPort(...) function of DX. Hope that helps.

Well tested it but it clips the entire scene what is unwanted at this case.

Thanks though.
Set a new viewport to the area you want to clip and then when you''re doing rendering just reset the viewport to its original state.
It is a common missconception that changing the viewport alone will allow you to cull away pixels (which is what you're asking basically). To cull pixels by changing the viewport would also require you to manipulate your projection matrix.

An easier way to accomplish this is to use SetScissorRect. First make sure that your card supports this functionality. If it does, then I would imagine this is exactly what you're looking for. This function allows you to define a 2D rectangle in screen space to confine your drawing to. Any pixels outside this 2D rectangle will not be calculated. The coordinates for the rectangle work like standard windows coordinates. (0,0)==(left, top), and (width,height)==(right, bottom).

Also make sure you enable scissor testing by calling SetRenderState.

neneboricua

[edited by - neneboricua19 on March 23, 2004 7:33:56 PM]
quote:Original post by Zorbfish
Set a new viewport to the area you want to clip and then when you''re doing rendering just reset the viewport to its original state.


That requires ending and starting the scene multiple times before the present and the scaling goes wild.


To neneboricua:

Oh the scissor test, I had tested it earlier and now its confirmed, my radeon doesnt suport it.
quote:Original post by Craazer

That requires ending and starting the scene multiple times before the present


No it doesn''t. You need *1* BeginScene and *1* EndScene per frame.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
quote:Original post by DrunkenHyena
quote:Original post by Craazer

That requires ending and starting the scene multiple times before the present


No it doesn''t. You need *1* BeginScene and *1* EndScene per frame.


Stay Casual,

Ken
Drunken Hyena


I dont understand how...

quote:Original post by neneboricua19
It is a common missconception that changing the viewport alone will allow you to cull away pixels (which is what you''re asking basically).


I apologize for my misinformation then. :/ Learn something new everyday I guess. SetScissorRect is DX9 specific isn''t it? Is there an equivalent in version 8?

I''d look it up myself but I don''t have my help files right in front of me and msdn updated their docs to DX9.

To Zorbfish:
My graphics card doesn't suport the scissor test so it doesnt seem to be good method to use... I dunno if installing latests drivers would fix that?
Surely I would test that if they would work at all... (lot of lag comes whit them)

Anyway I think, its new feature in 9.0 becose theres some talk about new renderstate options (as shown below).

heres the stuff you need to use it:
// MethodsHRESULT IDirect3DDevice9::SetScissorRect(CONST RECT* pRect); HRESULT IDirect3DDevice9::GetScissorRect(RECT* pRect);     // New RenderState, values are TRUE or FALSE D3DRS_SCISSORTESTENABLE     // New hardware cap D3D9CAPS.RasterCaps -> D3DPRASTERCAPS_SCISSORTEST;//The default scissor rectangle is the full viewport.






Yet about the clipping.
So what about that projection matrix?
I actualy use D3D for 2D purposes only and im not good whit matrixes, but if somebody can give me some words to look from the SDKs docs it would be great.

[edited by - Craazer on March 26, 2004 7:40:50 PM]

This topic is closed to new replies.

Advertisement