From 795f4c4b0133c1a8429235b3b610f5120878cd06 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 1 Aug 2008 17:28:41 +0000 Subject: [PATCH] support ScissorAttrib --- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 24 +++++++++++++++++++ panda/src/dxgsg9/dxGraphicsStateGuardian9.h | 1 + 2 files changed, 25 insertions(+) diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 78e098411c..2e850675ed 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -893,6 +893,7 @@ prepare_display_region(DisplayRegionPipelineReader *dr, << "GetViewport(" << vp_old.X << ", " << vp_old.Y << ", " << vp_old.Width << ", " << vp_old.Height << ") returned: Trying to set that vp---->\n"; hr = _d3d_device->SetViewport(&vp_old); + set_render_state(D3DRS_SCISSORTESTENABLE, FALSE); if (FAILED(hr)) { dxgsg9_cat.error() << "Failed again\n"; @@ -3621,6 +3622,11 @@ set_state_and_transform(const RenderState *target, _state._stencil = _target._stencil; } + if (_target._scissor != _state._scissor) { + do_issue_scissor(); + _state._scissor = _target._scissor; + } + _state_rs = _target_rs; } @@ -5649,6 +5655,24 @@ do_issue_stencil() { } } +//////////////////////////////////////////////////////////////////// +// Function: dxGraphicsStateGuardian9::do_issue_scissor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +void DXGraphicsStateGuardian9:: +do_issue_scissor() { + const LVecBase4f &frame = _target._scissor->get_frame(); + + RECT r; + r.left = _current_viewport.X + _current_viewport.Width * frame[0]; + r.top = _current_viewport.Y + _current_viewport.Height * (1.0f - frame[3]); + r.right = _current_viewport.X + _current_viewport.Width * frame[1]; + r.bottom = _current_viewport.Y + _current_viewport.Height * (1.0f - frame[2]); + _d3d_device->SetScissorRect(&r); + set_render_state(D3DRS_SCISSORTESTENABLE, TRUE); +} + //////////////////////////////////////////////////////////////////// // Function: dxGraphicsStateGuardian9::calc_fb_properties // Access: Public diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h index c4d6a73972..8df910fada 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.h +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.h @@ -187,6 +187,7 @@ protected: void do_issue_texture(); void do_issue_blending(); void do_issue_stencil(); + void do_issue_scissor(); virtual void enable_lighting(bool enable); virtual void set_ambient_light(const Colorf &color);