Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Created a Gist with full code <a href="https://gist.github.com/shaunlebron/3854bf4eec5bec297907" rel="noreferrer">here</a></strong></p> <p>This is a pretty esoteric art, and there are several ways to do this. I prefer what's called a <em>Direct3D Wrapper</em>. It's been years since I've done this, but I did it with a game once. I may have left out some details, but I just hope to illustrate the idea.</p> <p>All Direct3D9 games need to call <a href="http://msdn.microsoft.com/en-us/library/ee421698%28VS.85%29.aspx" rel="noreferrer">IDirect3DDevice9::EndScene</a> after the screen is rendered and ready to be drawn. So in theory, we can put custom code inside <code>EndScene</code> that draws what we want over the game. We do this by creating a class that looks like IDirect3DDevice9 to the game, but it's really just a wrapper that forwards all function calls to the real class. So now, in our custom class, our wrapper function for <code>EndScene</code> looks like this:</p> <pre><code>HRESULT IDirect3DDevice9::EndScene() { // draw overlays here realDevice.EndScene(); } </code></pre> <p>Then we compile it into a DLL called d3d9.dll, and drop it in the game executable's directory. The real d3d9.dll should be in the /system32 folder, but the game first looks in the current directory, and instead loads ours. Once the game loads, it uses our DLL to create an instance of our wrapper class. And now each time <code>EndScene</code> is called, our code is executed to draw what we want to the screen.</p> <p>I think you can try the same principle with OpenGL. But to prevent tampering, I think some modern games try to prevent this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload