ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


hud_library

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hud_library [2017/04/17 16:46]
korshun
hud_library [2017/07/09 14:26] (current)
korshun
Line 1: Line 1:
 ====== HUD Library ====== ====== HUD Library ======
 +HUD Library is an advanced replacement for [[zdoom>HudMessage]]. It uses [[HUD Library state]] instead of many function arguments and implements scaling and 3D HudMessages.
  
 +Here is an example:
 +
 +<code>
 +HudResetState(); // Just like calling SetFont and SetHudSize before HudMessage.
 +HudSetPoint(320.0, 240.0);
 +HudDrawText(1, "Hello");
 +</code>
 +
 +The only drawing functions in HUD Library are [[functions:HudDrawText]] and [[functions:HudDrawImage]]. They call [[zdoom>SetHudSize]], [[zdoom>SetFont]] and then [[zdoom>HudMessage]]([[zdoom>HudMessageBold|Bold]]) every time a message is drawn. This means that if you are mixing HUD Library with HudMesasge, then, after calling one of HudDraw* functions, your SetHudSize and SetFont settings are lost and you need to set them back.
 +
 +===== Scaling =====
 +
 +Scaling is implemented by calling [[zdoom>SetHudSize]] with values that don't match those set in [[functions:HudSetVirtualSize]]. 
 +
 +For example:
 +
 +<code>
 +HudResetState();
 +HudSetVirtualSize(640.0, 480.0);
 +HudSetScale(0.5);
 +HudDrawText(1, "Hello")
 +</code>
 +
 +Will result in the following sequence of calls to ZDoom's functions:
 +<code>
 +SetFont("SMALLFONT"); // Default HUD Library font
 +SetHudSize(1280, 1024, 0); // To implement 0.5 scale
 +HudMessage(s:"Hello"; HUDMSG_PLAIN, 1, etc);
 +</code>
 +
 +===== 3D messages =====
 +HUD Library supports an accurate projection of 3D messages. 3D messages are correctly projected in [[hud_library_state#projection_mode|both software and OpenGL renderers]]. 
 +
 +Example:
 +
 +<code>
 +HudResetState();
 +HudSetPoint3D(x, y, z);
 +HudSetCameraActor(0); // Set HUD Library camera to match the activator
 +HudDrawText(1, "Look here!")
 +</code>
 +
 +[[functions:HudSetPoint3D]] switches HUD Library to 3D drawing mode, while [[functions:HudSetPoint]] switches it back to 2D mode. 3D messages support all features that 2D messages support, including scaling.
 +
 +By default, 3D messages are automatically scaled with distance. You can disable this setting using [[functions:HudSetAutoDistanceScale]].
 +
 +===== State operations =====
 +The whole [[HUD Library state]] can be reset to default using [[functions:HudResetState]]. It can be saved and loaded using [[functions:HudPushState]] and [[functions:HudPopState]] to a stack. The stack can be cleared using [[functions:HudClearStateStack]].
hud_library.1492436781.txt.gz ยท Last modified: 2017/04/17 16:46 by korshun