Advertisement Jump to content
Sign in to follow this  

DX transformed (rotated) 2D line drawing

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

This line gets drawn...
// Line width = 1
	D3DXVECTOR2 line[2];
	line[0].x = displayleft;
	line[1].x = displayright;
	line[0].y = displaytop;
	line[1].y = displaybottom;
	d3dxline->Draw(line, 2, linecolours[0]);

But these don't at all. So I'm wondering what I'm doing wrong here and how to use the rotation variable? If for example I wanted to rotate the line 45 degrees, would rotation value have to be 45.0f or something between 0 and 1?
		D3DXVECTOR3 line_z[2];
		line_z[0].x = displayleft;
		line_z[1].x = displayright;
		line_z[0].y = displaytop;
		line_z[1].y = displaybottom;
		line_z[0].z = 1.0f; // Also tried 0.5f and 0.0f
		line_z[1].z = 1.0f; // Also tried 0.5f and 0.0f
		D3DXVECTOR2 beamcenter(7, current_line.bottom -;
		float rotation = 0.3f;
		D3DXMATRIX matrix; // Build our matrix to rotate, scale and position our sprite
		for(; i < 7; ++i)
			D3DXVECTOR2 translation(line_z[0].x, displaytop); // Screen position of the beam
			// out, scaling center, scaling rotation, scaling, rotation center, rotation, translation
			d3dxline->DrawTransform(line_z, 2, &matrix, linecolours);

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!