# 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.

## 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 - current_line.top);
float rotation = 0.3f;
D3DXMATRIX matrix; // Build our matrix to rotate, scale and position our sprite
for(; i < 7; ++i)
{
++line_z[0].x;
++line_z[1].x;
D3DXVECTOR2 translation(line_z[0].x, displaytop); // Screen position of the beam
// out, scaling center, scaling rotation, scaling, rotation center, rotation, translation
D3DXMatrixTransformation2D(&matrix,NULL,0.0,NULL,&beamcenter,rotation,&translation);
d3dxline->DrawTransform(line_z, 2, &matrix, linecolours);
}



• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 9
• 15
• 14
• 46
• ### Forum Statistics

• Total Topics
634059
• Total Posts
3015292
×