PDA

Просмотр полной версии : [SF API] Draw


Uztor
10.04.2015, 19:49
Hello, how can I fix the resolution problem?

Code:

Код:






pFont->Print("Hello, this is a test!", D3DCOLOR_ARGB(255, 255, 255, 0), 500, 500, false);




Screenshots:

1024x768:

http://host-it.tk/Upload/5527f0d63c5cc/sa_mp_007.png

1920x1080:

http://host-it.tk/Upload/5527f0d6a1e78/sa_mp_005.png

SR_team
10.04.2015, 20:28
int Resolution[2];

SF->getGame()->getScreenResolution(&Resolution[0], &Resolution[1]);

Font->Print("Hello, this is a test!", D3DCOLOR_ARGB(255, 255, 255, 0), Resolution[0] / 2, Resolution[1] / 2, false);

Dark_Knight
10.04.2015, 20:38
in the center

char buf[32] = "Hello, this is a test!";

Font->Print(buf, D3DCOLOR_ARGB(255, 255, 255, 0), Resolution[0] / 2 - Font->DrawLenght(buf, false) / 2, Resolution[1] / 2 - Font->DrawHeight()/2, false);

Dark_Knight
10.04.2015, 20:39
But u can use Game coordinates and then convert to Window coords/

Uztor
10.04.2015, 20:52
But u can use Game coordinates and then convert to Window coords/


What the game coordinates?

Uztor
10.04.2015, 21:05
My problem is:

I draw a box (my "coordinates")

Код:






SF->getRender()->DrawBorderedBox(1300, 700, 600, 300, D3DCOLOR_ARGB(255, 0, 0, 0), 3, D3DCOLOR_ARGB(50, 255, 255, 255));




But... how can convert for every screen resolution?

@SR_team (https://www.blast.hk/members/11231/)

@Dark_Knight (https://www.blast.hk/members/34/)

/edit:

My solution.. (not the best :D )

Код:






int Resolution[2];
SF->getGame()->getScreenResolution(&Resolution[0], &Resolution[1]);
X = Resolution[0] / 2;
Y = Resolution[1] / 2;
SF->getRender()->DrawBorderedBox(X + X - 610, Y + Y - 310, 600, 300, D3DCOLOR_ARGB(255, 0, 0, 0), 3, D3DCOLOR_ARGB(50, 255, 255, 255));

spiceman
10.04.2015, 22:19
Код:





[CODE]
int resolution[2];
SF->getGame()->getScreenResolution(&resolution[0], &resolution[1]);
kX = resolution[0] / 640;
kY = resolution[1] / 448;
SF->getRender()->DrawBorderedBox(pos1 * kX, pos2 * kY, size1 * kX, size2 * kY, D3DCOLOR_ARGB(255, 0, 0, 0), 3, D3DCOLOR_ARGB(50, 255, 255, 255));
// 0

Dark_Knight
10.04.2015, 22:48
[QUOTE="spiceman"]

Код:





[CODE]
int resolution[2];
SF->getGame()->getScreenResolution(&resolution[0], &resolution[1]);
kX = resolution[0] / 640;
kY = resolution[1] / 448;
SF->getRender()->DrawBorderedBox(pos1 * kX, pos2 * kY, size1 * kX, size2 * kY, D3DCOLOR_ARGB(255, 0, 0, 0), 3, D3DCOLOR_ARGB(50, 255, 255, 255));
// 0

spiceman
11.04.2015, 00:10
Kidding?


что не так. находим коэффициент подобия, используя его, мы можем преобразовывать игровые координаты в координаты экрана.

ведь k = resolution / game_resolution = point / game_point

допустим, мое разрешение экрана 1440x900, мне нужно нарисовать в центре точку.

середина по горизонтали по игровым координатам = 320px

k = 1440 / 640 = 2.25

x = k * 320 = 720 ( 1440 / 2 = 720 )

1440 / 640 = 720 / 320 = 2.25