Directx9 line translation
i have trouble translate a line
the function
void DrawLine(LPDIRECT3DDEVICE9 d3ddev, float x, float y, float x2, float y2, DWORD color)
{
D3DXMATRIX world, t, r;
LPDIRECT3DVERTEXBUFFER9 vBuffer = NULL;
VERTEXDATA2 vertex =
{
{ -1.0f, -1.0f ,1.0f, color, },
{ 1.0f, 1.0f, 1.0f, color, },
};
Vec2 diff(x2 - x, y2 - y);
D3DXMatrixTranslation(&t, TransfromNormalizeX(x , (float)SCREEN_WIDTH), TransfromNormalizeY(y, (float)SCREEN_HEIGHT), 0);
D3DXMatrixRotationZ(&r, -D3DXToRadian(45));
D3DXMatrixIdentity(&world);
world._11 = NormalizeSacle(diff.x, (float)SCREEN_WIDTH);
world._22 = NormalizeSacle(diff.y, (float)SCREEN_HEIGHT);
world = world * r ;
d3ddev->SetTransform(D3DTS_WORLD,&world);
d3ddev->SetFVF(CUSTOMFVF);
d3ddev->SetStreamSource(0, vBuffer, 0, sizeof(VERTEXDATA2));
d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 1);
}
my question is how i scale rotate and translate it appropriate way
cuz the does draw right
thanks for all the info
matrix directx-9
add a comment |
i have trouble translate a line
the function
void DrawLine(LPDIRECT3DDEVICE9 d3ddev, float x, float y, float x2, float y2, DWORD color)
{
D3DXMATRIX world, t, r;
LPDIRECT3DVERTEXBUFFER9 vBuffer = NULL;
VERTEXDATA2 vertex =
{
{ -1.0f, -1.0f ,1.0f, color, },
{ 1.0f, 1.0f, 1.0f, color, },
};
Vec2 diff(x2 - x, y2 - y);
D3DXMatrixTranslation(&t, TransfromNormalizeX(x , (float)SCREEN_WIDTH), TransfromNormalizeY(y, (float)SCREEN_HEIGHT), 0);
D3DXMatrixRotationZ(&r, -D3DXToRadian(45));
D3DXMatrixIdentity(&world);
world._11 = NormalizeSacle(diff.x, (float)SCREEN_WIDTH);
world._22 = NormalizeSacle(diff.y, (float)SCREEN_HEIGHT);
world = world * r ;
d3ddev->SetTransform(D3DTS_WORLD,&world);
d3ddev->SetFVF(CUSTOMFVF);
d3ddev->SetStreamSource(0, vBuffer, 0, sizeof(VERTEXDATA2));
d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 1);
}
my question is how i scale rotate and translate it appropriate way
cuz the does draw right
thanks for all the info
matrix directx-9
add a comment |
i have trouble translate a line
the function
void DrawLine(LPDIRECT3DDEVICE9 d3ddev, float x, float y, float x2, float y2, DWORD color)
{
D3DXMATRIX world, t, r;
LPDIRECT3DVERTEXBUFFER9 vBuffer = NULL;
VERTEXDATA2 vertex =
{
{ -1.0f, -1.0f ,1.0f, color, },
{ 1.0f, 1.0f, 1.0f, color, },
};
Vec2 diff(x2 - x, y2 - y);
D3DXMatrixTranslation(&t, TransfromNormalizeX(x , (float)SCREEN_WIDTH), TransfromNormalizeY(y, (float)SCREEN_HEIGHT), 0);
D3DXMatrixRotationZ(&r, -D3DXToRadian(45));
D3DXMatrixIdentity(&world);
world._11 = NormalizeSacle(diff.x, (float)SCREEN_WIDTH);
world._22 = NormalizeSacle(diff.y, (float)SCREEN_HEIGHT);
world = world * r ;
d3ddev->SetTransform(D3DTS_WORLD,&world);
d3ddev->SetFVF(CUSTOMFVF);
d3ddev->SetStreamSource(0, vBuffer, 0, sizeof(VERTEXDATA2));
d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 1);
}
my question is how i scale rotate and translate it appropriate way
cuz the does draw right
thanks for all the info
matrix directx-9
i have trouble translate a line
the function
void DrawLine(LPDIRECT3DDEVICE9 d3ddev, float x, float y, float x2, float y2, DWORD color)
{
D3DXMATRIX world, t, r;
LPDIRECT3DVERTEXBUFFER9 vBuffer = NULL;
VERTEXDATA2 vertex =
{
{ -1.0f, -1.0f ,1.0f, color, },
{ 1.0f, 1.0f, 1.0f, color, },
};
Vec2 diff(x2 - x, y2 - y);
D3DXMatrixTranslation(&t, TransfromNormalizeX(x , (float)SCREEN_WIDTH), TransfromNormalizeY(y, (float)SCREEN_HEIGHT), 0);
D3DXMatrixRotationZ(&r, -D3DXToRadian(45));
D3DXMatrixIdentity(&world);
world._11 = NormalizeSacle(diff.x, (float)SCREEN_WIDTH);
world._22 = NormalizeSacle(diff.y, (float)SCREEN_HEIGHT);
world = world * r ;
d3ddev->SetTransform(D3DTS_WORLD,&world);
d3ddev->SetFVF(CUSTOMFVF);
d3ddev->SetStreamSource(0, vBuffer, 0, sizeof(VERTEXDATA2));
d3ddev->DrawPrimitive(D3DPT_LINELIST, 0, 1);
}
my question is how i scale rotate and translate it appropriate way
cuz the does draw right
thanks for all the info
matrix directx-9
matrix directx-9
asked Nov 19 '18 at 21:23
Michael BalilitiMichael Baliliti
43
43
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382838%2fdirectx9-line-translation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53382838%2fdirectx9-line-translation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown