hello guys,
one question, i got a d3d9 hook.
Sometimes my FPS gets from 90 to 70-75( maybe because too much strings drawed? or its normal? )
can this be a problem if im reading from memory within the hook ?
this will be called in my hkPresent (endscene)
Code:
// function for updating the positions, and drawing maybe bad solution?
// 4096 is the maximum number of elements can be in the pool
for (int i = 0; i < 4096; ++i)
{
D3DXVECTOR3 position, positionScreen;
DWORD pickupModel = *(DWORD*)(g_pStatic->g_Pickups + 0xF004 + i * 0x14);
if (pickupModel != 1484)
continue;
position.x = *(float*)(g_pStatic->g_Pickups + 0xF00C + i * 0x14);
position.y = *(float*)(g_pStatic->g_Pickups + 0xF010 + i * 0x14);
position.z = *(float*)(g_pStatic->g_Pickups + 0xF014 + i * 0x14);
if (g_pSAFuncs->WorldToScreen(&position, &positionScreen))
{
// if is visible on screen
if (positionScreen.x <= g_pStatic->g_ScreenLenX && positionScreen.y <= g_pStatic->g_ScreenLenY && positionScreen.z > 1)
{
D3DXVECTOR3 myPosition;
g_pSAFuncs->GetPlayerPosition(g_pStatic->g_CPED, &myPosition);
float dist = g_pSAFuncs->Get3DDistance(&D3DXVECToCVec(myPosition), &D3DXVECToCVec(position));
if (dist > 350)
continue;
char buf[256];
sprintf_s(buf, "< Item > \n%.fm", dist);
g_pRender->DrawString(positionScreen.x, positionScreen.y, 0, 0, buf, D3DCOLOR_XRGB(140, 176, 143), DT_NOCLIP, pFont);
}
}
}
// function to draw strings
void Render::DrawString(int x, int y, int w, int h, char* text, DWORD color, DWORD Flags, ID3DXFont * font)
{
RECT pos = { x, y, x + w, x + h };
font->DrawTextA(NULL, text, -1, &pos, Flags, color);
}
what can improve the performance of drawing? ( or what should i not do inside a hook ? )
thanks in advance
