Jump to content
  • Advertisement
Sign in to follow this  
SystemFiles

Drawing lines with Sprites

This topic is 3163 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

Heey my question is: Is it possible to draw simple lines with a color from X1, Y1 to X2, Y2. Draw a Rectangle whas easy but. I dont actuelly know if it is possible but I am sure you guys know. I also found out that when I use DrawPrimitiveUP and Sprites to draw and when I got the Sprite open ( I did call Begin but not jet End because I call End at the end of my frame ) the DrawPrimitiveUP lines arent drawed, why? Also when I use DrawPrimtiveUP I get and a line at the good position and a ugly lines at the top of my game: http://img36.imageshack.us/img36/7365/naamloospp.jpg This is how I set my vertex list: D3DTLVERTEX VertexList[2]; VertexList[0].X = X; VertexList[0].Y = Y; VertexList[0].Z = 0.0f; VertexList[0].RHW = 1.0f; VertexList[0].dColor = dColor; VertexList[1].X = X2; VertexList[1].Y = Y2; VertexList[1].Z = 0.0f; VertexList[1].RHW = 1.0f; VertexList[1].dColor = dColor; oDevice->DrawPrimitiveUP( D3DPT_LINELIST, 2, VertexList, sizeof( D3DTLVERTEX ) );

Share this post


Link to post
Share on other sites
Advertisement
You're getting two lines because the second argument for DrawPrimitiveUp is the number of primitives (i.e., lines), not the number of vertices.

You're telling the device to draw 2 lines.

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
You're getting two lines because the second argument for DrawPrimitiveUp is the number of primitives (i.e., lines), not the number of vertices.

You're telling the device to draw 2 lines.


Yeah it looks perfect now, somebody got answer on the other questions?

Share this post


Link to post
Share on other sites
Sorry. Didn't go back to see your other questions.

With regard to "simple" lines, (in Dx9 ) there isn't a D3DXDrawLine(from-here, to there, with-color) function. DrawPrimitive(UP) is pretty much your choice for simple lines. For a more complicated version, you can use ID3DXLine (similar to a sprite).

You can use a sprite for drawing a horizontal or vertical line by selecting just a portion of the texture (1 or more pixels wide).

RECT srect;
srect.left = 0;
srect.right = 1;
srect.top = 0;
srect.bottom = 128;
sprite->Draw(texture,&srect,NULL,&D3DXVECTOR3(top-end of line),some-color);


You can call sprite->Flush() to render what's accumulated before you make other rendering calls to the same area of the screen as the sprite. Then sprite->End() will render what's accumulated since the Flush().

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Sorry. Didn't go back to see your other questions.

With regard to "simple" lines, (in Dx9 ) there isn't a D3DXDrawLine(from-here, to there, with-color) function. DrawPrimitive(UP) is pretty much your choice for simple lines. For a more complicated version, you can use ID3DXLine (similar to a sprite).

You can use a sprite for drawing a horizontal or vertical line by selecting just a portion of the texture (1 or more pixels wide).

RECT srect;
srect.left = 0;
srect.right = 1;
srect.top = 0;
srect.bottom = 128;
sprite->Draw(texture,&srect,NULL,&D3DXVECTOR3(top-end of line),some-color);


You can call sprite->Flush() to render what's accumulated before you make other rendering calls to the same area of the screen as the sprite. Then sprite->End() will render what's accumulated since the Flush().


Much people say DrawPrimitive( UP because it is easy ) is better with performance then ID3DXLine.

Share this post


Link to post
Share on other sites
Quote:
Much people say DrawPrimitive( UP because it is easy ) is better with performance then ID3DXLine.

Absolutely. Just wanted to let you know there are alternatives. If performance speed is a consideration, you may want to choose one method over another.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!