Author Topic: d3d9 drawings glitching out  (Read 581 times)

0 Members and 1 Guest are viewing this topic.

Mercenary_Frank

  • Online Villain
  • ***
  • Posts: 177
    • View Profile
d3d9 drawings glitching out
« 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.



my triangle being drawn fine



one of my vertices randomly going to the top corner



my code

Code: [Select]
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 :)

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: d3d9 drawings glitching out
« Reply #1 on: April 14, 2017, 09:56:47 pm »
your rendering in endscene i take it ? where you should be rendering primatives in drawprimitives not draw indexed?
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

Mercenary_Frank

  • Online Villain
  • ***
  • Posts: 177
    • View Profile
Re: d3d9 drawings glitching out
« Reply #2 on: April 14, 2017, 10:05:04 pm »
I am rendering in present just like you, if I draw primitves I get nothing

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: d3d9 drawings glitching out
« Reply #3 on: April 14, 2017, 11:31:40 pm »
i dont render in present mate. try endscene.
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: d3d9 drawings glitching out
« Reply #4 on: April 14, 2017, 11:37:08 pm »
remember this game is old and doesn't use normal rendering techniques. so you will have to adapt your hack to the game.
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

Mercenary_Frank

  • Online Villain
  • ***
  • Posts: 177
    • View Profile
Re: d3d9 drawings glitching out
« Reply #5 on: April 15, 2017, 06:36:31 pm »
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
« Last Edit: April 15, 2017, 06:51:55 pm by Mercenary_Frank »

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: d3d9 drawings glitching out
« Reply #6 on: April 15, 2017, 07:12:08 pm »
well done buddy.
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157

MrMedic

  • MasstKer
  • ********
  • Posts: 8900
  • programmer/dev/software engineer
    • View Profile
Re: d3d9 drawings glitching out
« Reply #7 on: April 15, 2017, 07:12:42 pm »
i need some keys so i can annoy the ludus mate lol get me some
EnCoded Message: i3iy9yl8kr2xf3g2Txs3pr6ye3ya7jg5ty2z

https://www.youtube.com/watch?v=62_7-AYfdkQ
you need a paypal account for the private versions.

Website:
http://bit.ly/medic101

Teamspeak 3: 85.236.101.5:10157