DrawTexture

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


Screen

native static vararg void DrawTexture(TextureID tex, bool animate, double x, double y, ...)

Usage

Draws the specified texture on the screen at the given coordinates. The texture offsets determine which point the texture is drawn from (e.g. if the offsets are in the center of the texture it will be drawn from the center). The texture has no scaling applied to it unless specified by the tags. If drawing a texture like the status bar is desired, the status bar's DrawTexture should be used instead. Coordinates are absolute and start from the top left of the screen with positive x values shifting to the right and positive y values shifting downward.

Note: ARGB colors are best specified by a hex value. For instance, if a color of pure red with full opaqueness is desired, the value 0xFFFF0000 should be used. The first FF specifies the alpha, the second FF specifies the level of red, and the next two 00 specify the level of green and blue respectively. If a tag says only "RGB" then the first FF specifying the alpha can be completely left out.

Warning: This can only be called from within functions that are specifically designed to draw HUD elements (e.g. BaseStatusBar's Draw or EventHandler's RenderOverlay).

Parameters

  • tex - The id of the texture to draw. The id of a texture can be found by calling TexMan's CheckForTexture function
  • animate - Whether or not to animate the image if it has a definition in ANIMDEFS
  • x - The x offset for where to draw the image
  • y - The y offset for where to draw the image
  • tags - Tags allow for any number of optional arguments to be specified in any order. Tags are set with the following syntax:
Screen.DrawTexture(myTex, false, 0, 0, DTA_DestWidth, 200, DTA_DestHeight, 200); // etc

with the tag first followed by its value. Valid tags:

  • (int) DTA_DestWidth - Scales the width of the texture to the specified width
  • (double) DTA_DestWidthF - Same as DTA_DestWidth but accepts floating point values
  • (int) DTA_DestHeight - Scales the height of the texture to the specified height
  • (double) DTA_DestHeightF - Same as DTA_DestHeight but accepts floating point values
  • (double) DTA_ScaleX - Scales the width of the texture about its offset point
  • (double) DTA_ScaleY - Scales the height of the texture about its offset point
  • (double) DTA_Alpha - Sets the alpha of the texture. A value of 1 is fully opaque while 0 is fully transparent. If less than 1 and DTA_LegacyRenderStyle is not specified then the render style is set to Translucent
  • (int) DTA_Color - An ARGB color that the texture's final colors (after all other color operations) are blended with
  • (int) DTA_FillColor - An RGB color to stencil on top of the texture. If DTA_LegacyRenderStyle is not specified then the render style is set to TranslucentStencil if DTA_Alpha is less than one, otherwise setting it to Stencil
  • (bool) DTA_AlphaChannel - If DTA_LegacyRenderStyle is not specified then the render style is set to Shaded if a color was specified in DTA_FillColor
  • (int) DTA_ColorOverlay - Applies an ARGB color overlay on top of the texture
  • (int) DTA_Desaturate - If DTA_FillColor is set then completely desaturates the texture with a value greater than 0. Otherwise scales the desaturation. A value of 255 is fully desaturated while a value of 0 is fully saturated
  • (int) DTA_TranslationIndex - Id for the translation to translate the color of the texture. Translation.GetID(<translation name>) can be used to get an ID of a translation defined in the TRNSLATE lump
  • (int) DTA_LegacyRenderStyle - Sets the render style via the STYLE_* constants. See: render styles
  • (bool) DTA_Clean - Scale the position and size of the texture by CleanXfac and CleanYfac (see global variables for more information)
  • (bool) DTA_CleanTop - Same as DTA_Clean but aligns to the top of the screen instead of the center
  • (bool) DTA_CleanNoMove - Similar to DTA_Clean except the texture is not repositioned
  • (bool) DTA_CleanNoMove_1 - Similar to DTA_CleanNoMove except it uses CleanXfac_1 and CleanYfac_1 instead (see global variables for more information)
  • (bool) DTA_320x200 - Scale the position and size of the texture as though the screen resolution were 320x200
  • (bool) DTA_Bottom320x200 - The same as DTA_320x200 except it scales from the bottom. Used for tall aspect ratios (e.g. 5:4)
  • (bool) DTA_FlipX - Flips the texture horizontally
  • (bool) DTA_FlipY - Flips the texture vertically
  • (bool) DTA_FlipOffsets - Flips the texture's offsets if one or both DTA_Flip* flags are set
  • (double) DTA_Rotate - Rotates the texture by the given degrees. Positive values rotate counter-clockwise
  • (int) DTA_VirtualWidth - Draws the texture as though the screen resolution were this wide
  • (double) DTA_VirtualWidthF - Same as DTA_VirtualWidth but accepts floating point values
  • (int) DTA_VirtualHeight - Draws the texture as though the screen resolution were this tall
  • (double) DTA_VirtualHeightF - Same as DTA_VirtualHeight but accepts floating point values
  • (bool) DTA_NoOffset - The texture ignores the global offsets for the screen when drawing it
  • (int) DTA_TopOffset - Ignores the top offset set on the texture and draws from the top of the texture with this offset instead
  • (double) DTA_TopOffsetF - Same as DTA_TopOffset but accepts floating point values
  • (int) DTA_LeftOffset - Ignores the left offset set on the texture and draws from the left of the texture with this offset instead
  • (double) DTA_LeftOffsetF - Same as DTA_LeftOffset but accepts floating point values
  • (bool) DTA_CenterOffset - Ignores the top and left offset set on the texture and draws from the center of the texture
  • (bool) DTA_CenterBottomOffset - Similar to DTA_CenterOffset except it draws from the center bottom of the texture
  • (int) DTA_CenterOffsetRel - The texture's offsets are relative to the center of it instead of the top left. 1 is standard behavior while 2 floors the center point.
  • (bool) DTA_TopLeft - If set to true, always draws the texture from the top left
  • (int) DTA_ClipTop - Clip anything above this position on the screen
  • (int) DTA_ClipBottom - Clip anything below this position on the screen
  • (int) DTA_ClipLeft - Clip anything to the left of this position on the screen
  • (int) DTA_ClipRight - Clip anything to the right of this position on the screen
  • Note: Clipping rectangles take precedence over the DTA_Clip* tags
  • (int) DTA_WindowLeft - Works similar to DTA_ClipLeft but only applies to the texture itself instead of the entire screen
  • (double) DTA_WindowLeftF - Same as DTA_WindowLeft but accepts floating point values
  • (int) DTA_WindowRight - Works similar to DTA_ClipRight but only applies to the texture itself instead of the entire screen
  • (double) DTA_WindowRightF - Same as DTA_WindowRight but accepts floating point values
  • (bool) DTA_Masked - If false, don't use the texture's mask
  • (bool) DTA_KeepRatio - If the virtual width or height are set, keep the screen's current aspect ratio instead of forcing 4:3
  • (bool) DTA_Pin - Same as DTA_KeepRatio
  • (bool) DTA_Fullscreen - Draw the texture to fill the entire screen
  • (int) DTA_FullscreenEx - Allows the type of fullscreen mode to be set when filling the screen with the texture
  • (int) DTA_FullScreenScale - Allows the type of fullscreen mode to be set for the virtual resolution. This gives more customization than DTA_KeepRatio
  • (double) DTA_SrcX - Start drawing at this pixel column on the texture
  • (double) DTA_SrcY - Start drawing at this pixel row on the texture
  • (double) DTA_SrcWidth - Stop drawing at [DTA_SrcX + this value] pixel column on the texture
  • (double) DTA_SrcHeight - Stop drawing at [DTA_SrcY + this value] pixel row on the texture
  • See Shapes for more information about uv coordinates
  • (int) DTA_ViewportX - Allows the x offset of the viewport to be manually specified
  • (int) DTA_ViewportY - Allows the y offset of the viewport to be manually specified
  • (int) DTA_ViewportWidth - Allows the width of the viewport to be manually specified
  • (int) DTA_ViewportHeight - Allows the height of the viewport to be manually specified
  • (bool) DTA_Indexed - [Currently Raze only] Marks the texture as indexed for palette emulation

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.