BeginHUD

From ZDoom Wiki
Jump to navigation Jump to search

BaseStatusBar

native void BeginHUD(double Alpha = 1., bool forcescaled = false, int resW = -1, int resH = -1)

Usage

A BaseStatusBar function that begins the process of drawing a fullscreen HUD. It sets up the virtual canvas for the HUD and aligns it to the current screen resolution, so all relevant orientation flags (such as DI_SCREEN* and DI_ITEM* flags used by many drawing functions) work as expected.

When drawing a fullscreen HUD, this must be called before any drawing is done.

In contrast, if you want to draw a classic-style statusbar HUD (which is limited to a specific area of the screen, not the whole screen), BeginStatusBar is typically used instead.

Parameters

  • double Alpha
The base overall translucency of the HUD (alpha of individual elements is applied on top). Default is 1.0 (opaque).
  • bool forcescaled
If true, the size of the HUD will be fixed, and the player won't be able to change it via HUD options.
Note: using this argument simply to override how position coordinates work in drawing functions is highly discouraged. Authors are recommended to familiarize themselves with DI_SCREEN* and DI_ITEM* flags to make sure their HUD elements are attached to screen corners/edges, which will make their position size-agnostic. Forcing fixed size of a HUD is generally not recommended.
  • int resW
Horizontal virtual resolution of the fullscreen HUD. The default is -1, which is interpreted as 320.
  • int resH
Vertical virtual resolution of the fullscreen HUD. The default is -1, which is interpreted as 200.

Note 1: The virtual resolution does not necessarily correspond to the actual size of the HUD's virtual canvas, because that size will be adjusted according to the user's resolution and its aspect ratio. Resolution specific in the function is meant to server as a base.

Note 2: While BeginHUD is designed for fullscreen HUDs, it can be used for statusbar-styled HUDs as well, if you want those HUDs to use the whole screen as a canvas rather than bunch up close to the bottom center of the screen like the classic statusbar does.

Examples

This example is from DoomStatusBar, the HUD class used by Doom. First, it checks the state argument of its Draw virtual function, and then calls either BeginStatusBar or BeginHUD depending on the type of the HUD currently used by the player:

	override void Draw (int state, double TicFrac)
	{
		Super.Draw (state, TicFrac);

		if (state == HUD_StatusBar) // this begins classic statusbar drawing
		{
			BeginStatusBar();
			DrawMainBar (TicFrac); // draws statusbar elements
		}
		else if (state == HUD_Fullscreen) // this begins fullscreen HUD drawing
		{
			BeginHUD();
			DrawFullScreenStuff (); // draws fullscreen HUD elements
		}
	}

See also