D3D9 Scrolling for DrawText C++

0

I am trying to vertically scroll a multi line text with C++ D3D9 Overlay Hook to an application in a specific rect, but I can't figure out how can I do it. So my question is, how can I somehow limit a region to draw a part of an entire text to that? (I plan to create a scrollbar in the end)

Solution:

void DrawFrame()
{
  RECT rect, scissorRect;

  SetRect(&scissorRect, 100, 100, 400, 400);
  SetRect(&rect, 100, 100 - y, 400, 1000);

  d3ddev->SetScissorRect(&scissorRect);
  d3ddev->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);

  font->DrawTextA(0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", -1, &rect, DT_WORDBREAK, 0xFFFFFFFF);

  d3ddev->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
}
c++
hook
directx-9
vertical-scrolling
drawtext
asked on Stack Overflow Nov 17, 2019 by Matt • edited Nov 17, 2019 by Matt

1 Answer

1

It's 2019, soon-to-be 2020, is there a reason you aren't using at least DirectX 11?

Regardless, the easiest implementation is to keep track of the position of the text (or rectangle that the text is drawn to) to move it up and down/left and right and use a scissor rect to clip the text to only be visible within a certain region.

answered on Stack Overflow Nov 17, 2019 by Casey

User contributions licensed under CC BY-SA 3.0