ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


functions:hudlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
functions:hudlib [2016/05/07 19:03] korshunfunctions:hudlib [2016/10/16 13:29] – [Hudlib] korshun
Line 7: Line 7:
 Only drawing functions actually draw stuff. All other functions only manipulate render state. Only drawing functions actually draw stuff. All other functions only manipulate render state.
  
-Only drawing functions change ZDoom's global message settings[[zdoom>SetHudSize]] and [[zdoom>SetFont]].+Drawing functions change ZDoom's global message settings ([[zdoom>SetHudSize]] and [[zdoom>SetFont]]) every time they are calledOther functions do not touch them. 
 + 
 +===== Examples ===== 
 + 
 +==== Simple 2D drawing ==== 
 + 
 +<code> 
 +HudSetPoint(320.0, 240.0); 
 +HudDrawText(1, "Hello!"); 
 +</code> 
 + 
 +==== Simple 3D drawing ==== 
 + 
 +<code> 
 +HudSetCameraActor(0); 
 +HudSetPoint3D(0.0, 0.0, 0.0); 
 +HudDrawText(2, "This is the center of the map!"); 
 +</code>
  
 ===== Virtual screen size ===== ===== Virtual screen size =====
Line 13: Line 30:
 These functions replace ''[[zdoom>SetHudSize]]''. They work exactly the same, but hudlib needs to wrap ''SetHudSize'' for message scaling. These functions replace ''[[zdoom>SetHudSize]]''. They work exactly the same, but hudlib needs to wrap ''SetHudSize'' for message scaling.
  
-<note important>Virtual screen size affects the size 3D messages.</note>+<note important>Virtual screen size affects the size of 3D messages.</note>
  
 ==== HudSetVirtualSize ==== ==== HudSetVirtualSize ====
 ''void HudSetVirtualSize(fixed width, fixed height)'' ''void HudSetVirtualSize(fixed width, fixed height)''
  
-Sets the virtual screen size to the given dimensions. The default size is 640x480. This works exactly like ''SetHudSize''.+Sets the virtual screen size to the given dimensions. The default size is 640x480. This works exactly like ''[[zdoom>SetHudSize]]''.
  
 ==== HudUseRealSize ==== ==== HudUseRealSize ====
Line 34: Line 51:
  
 Controls whether the statusbar area should be included into the virtual screen. This corresponds to the third parameter of ''[[zdoom>SetHudSize]]'' Controls whether the statusbar area should be included into the virtual screen. This corresponds to the third parameter of ''[[zdoom>SetHudSize]]''
 +
 +===== Widescreen support =====
 +
 +==== Hud boundaries ====
 +''fixed HudLeft()''
 +
 +''fixed HudRight()''
 +
 +''fixed HudTop()''
 +
 +''fixed HudBottom()''
 +
 +Return the boundaries of the screen for current virtual screen size, accounting for current **physical** aspect ratio. Equivalent to adding or subtracting a hud border manually.
 +
 +**Example**
 +
 +<code>
 +// This message will stick to the left border of the screen (with a gap), even in widescren.
 +HudSetPoint(HudLeft() + 3.0, 240.0);
 +</code>
 +
 +==== Hud borders ====
 +''fixed HudBorderX()''
 +
 +''fixed HudBorderY()''
 +
 +Return hud borders for current virtual screen size, accounting for current **physical** aspect ratio.
  
 ===== 2D positioning ===== ===== 2D positioning =====
Line 210: Line 254:
 ''void HudSetShowToEveryone(bool showToEveryone)'' ''void HudSetShowToEveryone(bool showToEveryone)''
  
-If set to true, the message will be shown to everyone, and not just to the activator. This settings toggles between ''[[zdoom>HudMessage]]'' and ''[[zdoom>HudMessageBold]]'' in hudlib.+If set to true, the message will be shown to everyone, and not just to the activator. This setting toggles between ''[[zdoom>HudMessage]]'' and ''[[zdoom>HudMessageBold]]'' in hudlib.
  
 ==== HudSetLayer ==== ==== HudSetLayer ====
Line 255: Line 299:
  
 Default: (0, 0). Default: (0, 0).
 +
 +<note important>Remember that actor pitch in ZDoom is inverted.</note>
 +
 +<note tip>If you want to do ''HudSetCameraAngles(GetActorAngle(tid), -GetActorPitch(tid))'', use ''HudSetCameraActor(tid)'' instead.</note>
  
 ==== HudSetCameraActor ==== ==== HudSetCameraActor ====
Line 285: Line 333:
  
 Default: (0, 0). Default: (0, 0).
 +
 +===== 3D Projection =====
 +
 +==== HudSetProjectionMode ====
 +''void HudSetProjectionMode(int mode)''
 +
 +Sets the method to use when projecting 3D points to the screen.
 +
 +Available modes are:
 +  * ''HUD_PROJECTION_AUTO'' -- use Y-shearing projection in Software renderer and true 3D projection in OpenGL (renderer is determined using ''IsOpenGL()'').
 +  * ''HUD_PROJECTION_YSHEARING'' -- always use Y-shearing projection
 +  * ''HUD_PROJECTION_3D'' -- always use true 3D projection
  
 ===== 3D Distance ===== ===== 3D Distance =====
Line 298: Line 358:
 ''fixed HudGetDistance()'' ''fixed HudGetDistance()''
  
-Returns the distance from the 3D point to the camera plane.+Returns the distance from the 3D point to the camera plane. Note that this is **not** the the distance between the camera and the point. 
 + 
 +Returns negative distances if the point is behind the camera.
  
 **Example** **Example**
Line 310: Line 372:
  
 ===== State management ===== ===== State management =====
 +
 +You can save and retrieve hudlib states using these functions. The maximum amount of saved states is configured through ''#define ACSUTILS_HUDLIB_SAVEDSTATES'' in your project's ACSUtils settings.
  
 ==== HudResetState ==== ==== HudResetState ====
Line 323: Line 387:
 Saves the current render state to a stack. Saves the current render state to a stack.
  
-<note important>There is a limit on how many states can be saved. If you save too many states, you will be notified through [[.error|the error system]].</note>+<note important>There is a limit on how many states can be saved. If you save more than ''ACSUTILS_HUDLIB_SAVEDSTATES'' states, you will be notified through [[.error|the error system]].</note>
 ==== HudPopState ==== ==== HudPopState ====
 ''void HudPopState()'' ''void HudPopState()''