MCPcopy Create free account
hub / github.com/ddnet/ddnet / CalcScreenParams

Method CalcScreenParams

src/engine/graphics.cpp:4–29  ·  view source on GitHub ↗

helper functions

Source from the content-addressed store, hash-verified

2
3// helper functions
4void IGraphics::CalcScreenParams(float Aspect, float Zoom, float *pWidth, float *pHeight) const
5{
6 const float Amount = 1150 * 1000;
7 const float WMax = 1500;
8 const float HMax = 1050;
9
10 const float f = std::sqrt(Amount) / std::sqrt(Aspect);
11 *pWidth = f * Aspect;
12 *pHeight = f;
13
14 // limit the view
15 if(*pWidth > WMax)
16 {
17 *pWidth = WMax;
18 *pHeight = *pWidth / Aspect;
19 }
20
21 if(*pHeight > HMax)
22 {
23 *pHeight = HMax;
24 *pWidth = *pHeight * Aspect;
25 }
26
27 *pWidth *= Zoom;
28 *pHeight *= Zoom;
29}
30
31void IGraphics::MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
32 float ParallaxZoom, float OffsetX, float OffsetY, float Aspect, float Zoom, float *pPoints) const

Callers 4

OnNewSnapshotMethod · 0.80
InitMultiViewMethod · 0.80
OnUpdateMethod · 0.80
UpdateButtonsGameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected