Jump to content
  • Advertisement
Sign in to follow this  
bjogio

render state, closed source

This topic is 4748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys I'm working at a little hack for a game that isn't shipped open source. Now I want to add a little gui that will explain at screen what my part of code is doing. I've intercepted the call to D3DDevice->EndScene() (assuming it's the last d3d call before ->Present() ) and before releasing the control flow to the original program I write my portion of graphic. I've begun with something easy like flat colored panel. I draw it in this way (the game is in directX 8) Direct3D8Device->SetVertexShader(D3DFVF_XYZ | D3DFVF_DIFFUSE); Direct3D8Device->SetStreamSource(0, MenuVertices, sizeof(PanelVertex)); Direct3D8Device->SetRenderState(D3DRS_LIGHTING, FALSE); Direct3D8Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); all the vertices in vb have ].color = 0xffffffff so I can expect a white panel but it's not true cause the panel change color during time. For example in menu screen there is a string that flick from white to red and my panel (during the time I remain in menu) become red when this string is red. I can assume that the color change is driven by a RenderState that the original application set. You know what SetRenderState I need to change? I've tried a lot of things but without luck. My skills in fixed pipeline are very little cause I've always used vsh and psh of dx9. Any suggestion will be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
1) before changing any render states (including the stream source) of the intercepted program, you probably want to save all the existing device state in case it relies on any being set to a specific value.

If you've intercepted the game's SetRenderState calls, this should be pretty easy to do.


2) IDirect3DDevice8::SetTextureStageState() is the mechanism used to specify what happens to pixels in the fixed function pipeline. In particular the COLOROP and COLORARG states are relevent to what you're doing:

// colour pipe = colour from vertex colour
Device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 );
Device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

// alpha pipe = alpha from vertex colour
Device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 );
Device->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );

// mark the end of our setup
Device->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
Device->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );


3) Of course, you may also need to set other device state - depending on how much you can guarantee about the hijacked app sets its states.

Share this post


Link to post
Share on other sites
Instead of setting color with 0xfffff, try D3DCOLOR_ARGB(255, 255, 255, 255), always use ready functions / macros from SDK if possible.

Can't say anything else from that, just check that your PanelVertex is something like this:


class PanelVertex
{
public:
float x, y, z;
D3DCOLOR Color;
};


And then check that you copy the vertices right, I mean that you need to copy the x, y, z and the color to your vertex buffer.

Share this post


Link to post
Share on other sites
yes I don't want to interfer with the existing program. My panel is:
struct {
float x, y, z;
D3DCOLOR color;
};
I've provided a little log function for the SetRenderState and after a little grep I've found what the original programmers wrote.
SetTextureStageState was the key, thanks guys, if someone want the code I will release it as freesource shortly. (not use it for making aimbot :) )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!