TKC-Community
Hacking and Art => Mount and Blade => Topic started by: Mercenary_Frank on April 14, 2017, 01:52:06 pm
-
I am hacking a game called mount and blade and I want to draw an ESP overlay with directx drawindexedprimitive. However when I try to draw my shape it sometimes glitches out to the top left of the corner. I was hoping somebody could check my code and see what I am doing wrong. Here is an example
my d3dx9 test bench showing my drawing functions work just fine.
(https://i.snag.gy/eYbuqC.jpg)
my triangle being drawn fine
(https://i.snag.gy/mXyYHx.jpg)
one of my vertices randomly going to the top corner
(https://i.snag.gy/dWh5Iq.jpg)
my code
void CDraw::DrawTrapeziumFilled(int x, int y, int h, int w, int s, DWORD color)
{
CUSTOMVERTEX vertices[] =
{
{ x - w, y , 1.0f, 1.0f, color }, // vertex 0
{ x, y - h, 1.0f, 1.0f, color }, // vertex 1
{ x + w, y, 1.0f, 1.0f, color }, // vertex 2
};
unsigned short indexes[] = {
0,1,2
};
pDevice->CreateVertexBuffer(3 * sizeof(vertex), D3DUSAGE_WRITEONLY, D3DFVF_XYZRHW | D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &buffer, NULL);
pDevice->CreateIndexBuffer(1 * sizeof(short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &indexBuffer, NULL);
VOID* pVoid;
buffer->Lock(0, sizeof(vertices), (void**)&pVoid, 0);
memcpy(pVoid, vertices, sizeof(vertices));
buffer->Unlock();
VOID* pIndex;
indexBuffer->Lock(0, sizeof(indexes), (void**)&pIndex, 0);
memcpy(pIndex, indexes, sizeof(indexes));
indexBuffer->Unlock();
pDevice->SetIndices(indexBuffer);
pDevice->SetTexture(0, NULL);
pDevice->SetPixelShader(NULL);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pDevice->SetStreamSource(0, buffer, 0, sizeof(vertex));
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, 3, 0, 2);
buffer->Release();
indexBuffer->Release();
}
These drawings take place in present because in endscene the shaps would cause my entire screen to flicker. weird...
I am but a mere novice in directx and more used to openGL so I would be happy if somebody could point out to me what I am doing wrong :)
-
your rendering in endscene i take it ? where you should be rendering primatives in drawprimitives not draw indexed?
-
I am rendering in present just like you, if I draw primitves I get nothing
-
i dont render in present mate. try endscene.
-
remember this game is old and doesn't use normal rendering techniques. so you will have to adapt your hack to the game.
-
https://snag.gy/X6vAxS.jpg solved :D now I understand what you ment with there is a boolean you need to check before you start drawning
-
well done buddy.
-
i need some keys so i can annoy the ludus mate lol get me some