My issue is in commen by ChurchSkiz on this web-page https://www.gamedev.net/forums/topic/577397-making-a-2d-menu-in-directx/. Everything is simple, but I cannot understand how to scale that texture. I want to do it like image for game main menu. How it seems to me, it's only a way which scale any texture to display's resolution of a user (1024x768, 1920x1080 etc).
I also made a non-generic way to scale texture. It depends on centain texture's and display's resolution
// The texture are 1024x768 and my display's resolution are 1440x900.
D3DXVECTOR3 center(-200,-50, 0);
sprite_handler->Draw(KidRightTexture, nullptr, ¢er, nullptr, D3DCOLOR_XRGB(255, 255, 255));
Any ideas? Also, is there a better way to draw my texture? For example, maybe without the sprite? I am very new to DirectX. But everything changes when our display are 1600x1050.
You can adjust sprite size, rotattion and world position using ID3DXSprite::SetTransform
method. You can use it by building transformation matrix.
::D3DXMATRIX scaling_matrix;
::D3DXMATRIX rotation_matrix;
::D3DXMATRIX move_matrix;
::D3DXMATRIX intermediate_matrix;
::D3DXMATRIX final_matrix;
::D3DXMatrixScaling(&scaling_matrix, scale_x, scale_y, 1.0f);
::D3DXMatrixRotationZ(&rotation_matrix, rotation);
::D3DXMatrixTranslation(&move_matrix, x, y, 1.0f);
::D3DXMatrixMultiply(&intermediate_matrix, &scaling_matrix, &rotation_matrix);
::D3DXMatrixMultiply(&final_matrix, &intermediate_matrix, &move_matrix);
sprite_handler->SetTransform(&final_matrix);
But I must mention that the article you posted is outdated. DirectX9 and sprites provided by D3DXSPRITE
are essentially deprecated.