4
\$\begingroup\$

I'm following this guide and the related blog post to implement a basic game overlay for DirectX 9 games using SharpDX.

So the tutorial already have an example for text rendering but I need to be also able to render a provided image to the overlay.

Any ideas, guides?

\$\endgroup\$
1
\$\begingroup\$

For DirectX 9 you can use a texture and a sprite. In DXHookD3D9.cs you could do something like the following in "DoCaptureRenderTarget". Don't create the resources each frame but for simplicity here it is all together.

// Create resources
SharpDX.Direct3D9.Texture tex = null;
Sprite sprite = null;
tex = SharpDX.Direct3D9.Texture.FromFile(device, filename);
sprite = new SharpDX.Direct3D9.Sprite(device);
// to resize/rotate/position sprite.Transform = some 4x4 affine transform matrix (SharpDX.Matrix)

sprite.Begin(SharpDX.Direct3D9.SpriteFlags.None);
SharpDX.Vector3 pos = new SharpDX.Vector3(0, 0, 0);
SharpDX.Color color = new SharpDX.ColorBGRA(0xffffffff);

sprite.Draw(tex, color, null, null, pos);

// Finish drawing
sprite.End();
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.