Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Drawing visible lines with D3D 8

This topic is 5614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I go about drawing visible 3D lines in D3D 8? I can set up an object in my game that''ll render line lists, but I don''t seem to get any output from it - what exact procedure do I need to use to draw just a straightline from one point in 3D space to another? ##UnknownPlayer##

Share this post

Link to post
Share on other sites

      void ssD3D::DrawLine(Vector start, Vector end, WSCOLOR clrStart, WSCOLOR clrEnd)

pLineBuffer->Lock(0,2 * sizeof(SPRITEVERTEX),(BYTE**)&pVertices,0);

pVertices[0].color = D3DCOLOR_RGBA(clrStart.r,clrStart.g,clrStart.b,clrStart.a);
pVertices[1].color = D3DCOLOR_RGBA(clrEnd.r,clrEnd.g,clrEnd.b,clrEnd.a);

pVertices[0].x = start.x;
pVertices[0].y = start.y;
pVertices[1].x = end.x;
pVertices[1].y = end.y;


//pDevice->SetTransform(D3DTS_WORLD, NULL);

D3DXMATRIX Identity;
pDevice->SetTransform(D3DTS_WORLD, &Identity);

pDevice->SetStreamSource(0, pLineBuffer, sizeof(SPRITEVERTEX));
pDevice->DrawPrimitive(D3DPT_LINELIST, 0, 1);

Ripped straight from source code to one of my games (2D side-scroller, so you'll have to add the extra dimension), but hope it helps you with the general procedure.

[EDIT:] SPRITEVERTEX is defined as:

float x, y, z;
DWORD color;
float u, v;

All this obviously assuming you've set up a D3D device and world/projection matrices etc.

[edited by - YodaTheCoda on March 5, 2003 2:51:33 AM]

Share this post

Link to post
Share on other sites
Ok I''ve got that, but now my screen is generating a seizure robot type effect that''s blocking out everything else on the screen? Did you suffer from this at some point, and if so what was the fix?


Share this post

Link to post
Share on other sites
Sounds fun Can''t say I''ve ever encountered that particular problem though - what exactly are the symptoms? Also, did you initialize pLineBuffer correctly? Maybe you could post some code?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!