How to Draw a Line in Flexi 12
We strive to provide all our services for free and not interrupt your visit with intrusive advertisements or restrictions - support us by disabling your ad blocker or whitelisting our site.
|
Thread Tools |
How To Draw A Line in DirectX |
7th March 2010, 10:02 PM | #1 | |||||||||||
Master Roaster TM Join Date: Feb 2010 Posts: 1,216 Reputation: 35685 Points: 52,021, Level: 34 Level up: 18%, 2,979 Points needed Activity: 1.9% | How To Draw A Line in DirectX okay for some quick info, so here is the first line of the code Code: void DrawLine(LPDIRECT3DDEVICE9 Device_Interface,int bx,int by,int bw,D3DCOLOR COLOR) { } that is going to be the base function, THIS WILL NOT RENDER ANYTHING YET now add D3DRECT rec; to your function, it should look like this now Code: void DrawLine(LPDIRECT3DDEVICE9 Device_Interface,int bx,int by,int bw,D3DCOLOR COLOR) { D3DRECT rec; } now we add the x,y,w, color etc rec.x1 = bx-bw; should look like this Code: void DrawLine(LPDIRECT3DDEVICE9 Device_Interface,int bx,int by,int bw,D3DCOLOR COLOR) { D3DRECT rec; rec.x1 = bx-bw;//makes line longer/shorter going left rec.y1 = by;/base y rec.x2 = bx+bw;//makes line longer/shorter going right rec.y2 = by+1;//makes line one pixel tall } add pDevice->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); here is the final function Code: void DrawLine(LPDIRECT3DDEVICE9 Device_Interface,int bx,int by,int bw,D3DCOLOR COLOR) { D3DRECT rec; rec.x1 = bx-bw;//makes line longer/shorter going lef rec.y1 = by;/base y rec.x2 = bx+bw;//makes line longer/shorter going right rec.y2 = by+1;//makes line one pixel tall Device_Interface->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); } now a call example Code: drawline(pDevice,40,60,100,D3DCOLOR_ARGB(0,0,0,0); that will draw a black line have fun,
Last edited by Pyro666; 8th March 2010 at 12:41 PM. Reason: added ss | |||||||||||
|
7th March 2010, 10:45 PM | #2 |
Posting Well Join Date: Feb 2010 Posts: 33 Reputation: -181 | Good, now make a crosshair out of it! |
|
7th March 2010, 10:50 PM | #3 |
Supreme H4x0|2 Join Date: Dec 2009 Posts: 695 Reputation: 734 | That's a screenspace line how about a worldspace line? |
|
7th March 2010, 11:46 PM | #4 | |||||||||||
Master Roaster TM Join Date: Feb 2010 Posts: 1,216 Reputation: 35685 Points: 52,021, Level: 34 Level up: 18%, 2,979 Points needed Activity: 1.9% | Quote: Originally Posted by Anddos That's a screenspace line how about a worldspace line? fine -.- Riffe420, [Auto Merged - 0:00:37 UTC] Quote: Originally Posted by Riffe420 Good, now make a crosshair out of it! Quote: void crosstwo(LPDIRECT3DDEVICE9 pDevice,int tx,int ty,int tw,int th,D3DCOLOR COLORZ) theres the crosshair func i made, ill explain it later via edit. Quote: crosstwo(pDevice,GetSystemMetrics(0)/2,GetSystemMetrics(1)/2,35,35,red); have fun guys Last edited by Pyro666; 8th March 2010 at 12:01 AM. | |||||||||||
|
8th March 2010, 01:40 AM | #5 |
Supreme H4x0|2 Join Date: Dec 2009 Posts: 695 Reputation: 734 | Thats still screenspace as you're working with rect's |
|
8th March 2010, 01:58 AM | #6 |
Guess who's back? Join Date: Dec 2009 Location: Behind a computer Posts: 754 Reputation: 1752 | you made a mistake: Quote: Originally Posted by prototype666 add pDevice->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); here is the final function Code: void DrawLine(LPDIRECT3DDEVICE9 Device_Interface,int bx,int by,int bw,D3DCOLOR COLOR) { D3DRECT rec; rec.x1 = bx-bw;//makes line longer/shorter going lef rec.y1 = by;/base y rec.x2 = bx+bw;//makes line longer/shorter going right rec.y2 = by+1;//makes line one pixel tall pDevice->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); } you have to add Code: Device_Interface->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); or am I wrong? __________________ ...From the ashes I rise... |
|
8th March 2010, 06:35 AM | #7 | |||||||||||
Master Roaster TM Join Date: Feb 2010 Posts: 1,216 Reputation: 35685 Points: 52,021, Level: 34 Level up: 18%, 2,979 Points needed Activity: 1.9% | Quote: Originally Posted by shamwow100 you made a mistake: you have to add Code: Device_Interface->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); or am I wrong? no your not wrong at all, but i have clear in my function Last edited by Pyro666; 8th March 2010 at 12:40 PM. | |||||||||||
|
8th March 2010, 07:28 AM | #8 |
Super H4x0r Join Date: Jan 2009 Posts: 321 Reputation: 138 | Quote: Originally Posted by shamwow100 you made a mistake: you have to add Code: Device_Interface->Clear(1,&rec,D3DCLEAR_TARGET,Color,0,0); or am I wrong? No, it's the same analogy, it's just that you may declare it as Device_Interface and OP declares it as pDevice. Obviously not everyone declares the same name for all devices. |
|
8th March 2010, 07:40 AM | #9 |
The Legendary Cheater Join Date: Nov 2007 Location: msdn Posts: 563 Reputation: 5519 | I like mine better, Code: void Direct3D::DrawCrosshair( int ScreenW, int ScreenH, DWORD Color ) { if( !cVar.Var.pDevice ) return; int DrawSpotX = ( ScreenW / 2 ) - 1; int DrawSpotY = ( ScreenH / 2 ) - 1; D3DRECT Line1 = { DrawSpotX - 20, DrawSpotY, DrawSpotX + 20, DrawSpotY + 3 }; D3DRECT Line2 = { DrawSpotX, DrawSpotY - 20, DrawSpotX + 3, DrawSpotY + 20 }; cVar.Var.pDevice->Clear( 1, &Line1, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0 ); cVar.Var.pDevice->Clear( 1, &Line2, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0 ); } __________________
|
|
8th March 2010, 12:34 PM | #10 | |||||||||||
Retired Administrator Join Date: Sep 2006 Posts: 14,758 Reputation: 160116 Points: 250,133, Level: 59 Level up: 25%, 243,867 Points needed Activity: 2.7% | device is not a cvar :/ __________________ ~ UC-Downloads ~ UC-Forum Rules ~ UC-Wiki ~ | |||||||||||
|
8th March 2010, 01:49 PM | #11 | |||||||||||
Site Adviser Join Date: Feb 2005 Posts: 7,175 Reputation: 128306 Points: 196,122, Level: 59 Level up: 8%, 297,878 Points needed Activity: 2.9% | Quote: Originally Posted by iExclusive No, it's the same analogy, it's just that you may declare it as Device_Interface and OP declares it as pDevice. Obviously not everyone declares the same name for all devices. No, prototype666 was using Device_Interface AND pDevice in the function. That is just the normal C+P errors you see floating around most times though...
__________________ I've learned that something constructive comes from every defeat. Real programmers don't document, if it was hard to write, it should be hard to understand. First learn computer science and all the theory, next develop a programming style, then forget all that and just hack. Learning is creation and not consumption. Knowledge is not something a learner absorbs, but something a learner creates. The path to success is paved with small wins. Even the grandest and most glorious victories rest on a string of modest but constructive steps forward. Note: I am not a member of any other community, any communication from this username outside of UC is not from myself. | |||||||||||
|
8th March 2010, 06:39 PM | #12 | |||||||||||
Master Roaster TM Join Date: Feb 2010 Posts: 1,216 Reputation: 35685 Points: 52,021, Level: 34 Level up: 18%, 2,979 Points needed Activity: 1.9% |
Quote: Originally Posted by Roverturbo No, prototype666 was using Device_Interface AND pDevice in the function. That is just the normal C+P errors you see floating around most times though...
I DID NOT C+P this, i made this from an idea in my head oh and by the way i was tired and i did it as a mistake, i use pdevice thats why it was in there | |||||||||||
|
11th March 2010, 05:34 AM | #13 |
h4x0!2 Join Date: Oct 2007 Posts: 105 Reputation: 228 | there is allready a tut. http://www.unknowncheats.me/forum/tu...raw-lines.html |
|
We strive to provide all our services for free and not interrupt your visit with intrusive advertisements or restrictions - support us by disabling your ad blocker or whitelisting our site.
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Question] [C++] Reading line by line from streaming webpage | Brownstone | C and C++ | 6 | 10th August 2012 12:57 AM |
[Help] [C++] Reading line by line from streaming webpage | Brownstone | Programming for Beginners | 0 | 5th August 2012 11:04 PM |
[Question] on line demo? | U$eLe$$ | Call Of Duty 1 | 4 | 13th July 2005 10:39 PM |
Is there a line to draw in hacking? | Alkatraz | America's Army Operations 2.x | 17 | 22nd March 2005 03:38 PM |
Tags |
directx, draw, line |
« Previous Thread | Next Thread »
|
All times are GMT. The time now is 11:39 PM.
no new posts
How to Draw a Line in Flexi 12
Source: https://www.unknowncheats.me/forum/d3d-tutorials-and-source/62490-draw-line-directx.html
0 Response to "How to Draw a Line in Flexi 12"
Post a Comment