# Thread: DrawSquare() Function [by Topblast]

1. Hmm for the Solid Square, it would be much easier using FillRGB.

this way you can use same function for xhair as you would for square.

example:

Globals:
Code:
```int CenterX = GetSystemMetrics( 0 ) / 2;//Gets screen X resolution then cutting it in half to get the center.
int CenterY = GetSystemMetrics( 1 ) / 2;//Gets screen Y resolution then cutting it in half to get the center.```

Void:
Code:
```void cBase::FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}```

Then for the xhair:
Code:
`FillRGB(CenterX-15, CenterY, 30, 1,Red,pDevice);FillRGB(CenterX, CenterY-15, 1, 30,Red,pDevice);`
Or for the Box (Left Side for Menu):
Code:
`FillRGB(20, 200, 150, 400,Red,pDevice);`

2. Originally Posted by CAFlames
Hmm for the Solid Square, it would be much easier using FillRGB.

this way you can use same function for xhair as you would for square.

example:

Globals:
Code:
```int CenterX = GetSystemMetrics( 0 ) / 2;//Gets screen X resolution then cutting it in half to get the center.
int CenterY = GetSystemMetrics( 1 ) / 2;//Gets screen Y resolution then cutting it in half to get the center.```

Void:
Code:
```void cBase::FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}```

Then for the xhair:
Code:
`FillRGB(CenterX-15, CenterY, 30, 1,Red,pDevice);FillRGB(CenterX, CenterY-15, 1, 30,Red,pDevice);`
Or for the Box (Left Side for Menu):
Code:
`FillRGB(20, 200, 150, 400,Red,pDevice);`

My friend do u understand what Clear() Really does?

That will not do Transparency.

3. Originally Posted by topblast

My friend do u understand what Clear() Really does?

That will not do Transparency.
he said a solid square. He does not need transparency.

4. Originally Posted by topblast

My friend do u understand what Clear() Really does?

That will not do Transparency.
Where did I say it was transparent? if i wanted transparent I would add an alpha blend.... this is for a solid box / line anywhere on screen for a box, random line, or xhair.

5. Originally Posted by CAFlames

Where did I say it was transparent? if i wanted transparent I would add an alpha blend.... this is for a solid box / line anywhere on screen for a box, random line, or xhair.
Do u kno the real reason for Clear?

Both of you.

6. Originally Posted by topblast

Do u have to be so technical about things.
I wasn't being technical, but a clearly misleading post had been posted (by yourself).

Originally Posted by topblast

Do u kno the real reason for Clear?

Both of you.
I believe I know more than you. Bloody annoying me << That's just my honest belief right now, not being stuck up or anything.. which might change very soon

The IDIRECT3DDDEVICE::Clear() method clears a specified area of one or more surfaces to a specified color.

7. Originally Posted by topblast

Do u kno the real reason for Clear?

Both of you.
Honestly I used thatfillrgb method but i named some stuff different and never used the clear... but I saw on a thread about d3d xhairs that he used it so i just included it and used his. So no I dont.

8. Originally Posted by freedompeace
I wasn't being technical, but a clearly misleading post had been posted (by yourself).

I believe I know more than you. Bloody annoying me << That's just my honest belief right now, not being stuck up or anything.. which might change very soon

The IDIRECT3DDDEVICE::Clear() method clears a specified area of one or more surfaces to a specified color.
And in the cast of speed?

9. Originally Posted by topblast

And in the cast of speed?
cast or case of speed?

If it is case then Clear() is much faster than the publxly released FillRGB functions.

10. Originally Posted by freedompeace
cast or case of speed?

If it is case then Clear() is much faster than the publxly released FillRGB functions.
Vs DrawPrimitive

11. Thanks for sharing this this will go great with my next hack

12. Originally Posted by topblast

Vs DrawPrimitive
Clear is faster, duh <<

13. Originally Posted by freedompeace
Clear is faster, duh <<