unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2009, 05:09 AM
Alkatraz Alkatraz is offline
Administrator
 
Join Date: Jan 2007
Posts: 72
Default [Tutorial] - How to draw lines.

Tutorial put together by stefanlg


When drawing a line i tend to use Clear funtion because it doesn't tend to effect the fps much.





ex. If you wanted to draw a line in the center of a screen you can use his method.
Code:
int x = ( GetSystemMetrics( 0 ) / 2); int y = ( GetSystemMetrics( 1 ) / 2); D3DRECT rec = { x - 10, y, x + 10, y + 1};
pDevice->Clear(1, &rec, D3DCLEAR_TARGET, 
D3DCOLOR_ARGB(255, 255, 0, 0)
, 0, 0);
// 10 = the distance to left and right, 1 = how thick the line will be
//This code with draw a red line directly left and right
 
// D3DRECT rec = { -, -, +, +};
By dividing the hight and the width of the screen will set the x and the y directly in the center of the screen, So to make a line you need to draw a line left and right of the x.

By looking at the picture you can tell that to draw a left xy_line you must you must subtract x by the width you want.
To draw the right xy_line you must do the same thing except this time you need to add x by the width you want.
then to make the line visible you must set a width to the line. to do this you can add 1 to y.

To Create a vertical line you need to use this code.

Code:
int x = ( GetSystemMetrics( 0 ) / 2); int y = ( GetSystemMetrics( 1 ) / 2); D3DRECT rec2 = { x, y - 10, x + 10, y + 1}; pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 255, 0, 0), 0, 0);
// 10 = the distance to left and right, 1 = how thick the line will be
//This code with draw a red line verticly
 
// D3DRECT rec = { -, -, +, +};

In order to draw a vertical line you need to take your y cord and and subtract it by the width. That will give you your upper half of the vertical line.
To draw the lower half of the vertical line you must take the y cord and add it by the width you want.
You now have a vertical line, but to make it visable you need to take the x cord and add 1 to it for the thickness of the line.


When you add the code together this is what you end up with.
Code:
int x = ( GetSystemMetrics( 0 ) / 2); int y = ( GetSystemMetrics( 1 ) / 2); D3DRECT rec = { x - 10, y, x + 10, y + 1}; D3DRECT rec2 = { x, y - 10, x + 1, y + 10}; pDevice->Clear(1, &rec, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 255, 0, 0), 0, 0);
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 255, 0, 0), 0, 0);
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
draw, lines, tutorial

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:00 AM.