Gamesystem gui

Built-in scripting functions.

Namespace: dmGameSystem
Include: #include <dmsdk/gamesys/gui.h>
TYPES
CompGetConstantCallback Used in GetMaterialConstant to resolve a render co...
CompSetConstantCallback Used in SetMaterialConstant to set a render consta...
FontInfo Used to retrieve the information of a font.
GuiNodeTypeDestroyFunction
GuiNodeTypeDestroyFunction
HComponentRenderConstants Render constants handle
ENUMS
FontGlyphCompression Describes what compression is used for the glyph i...
STRUCTS
struct CompGuiNodeTypeCtx Gui component node type create/destroy context
struct FontGlyph Represents a glyph
struct FontResource Handle to font resource
struct GuiNodeType Gui component node type
FUNCTIONS
int AreRenderConstantsUpdated(dmGameSystem::HComponentRenderConstants constants) check if the constants have changed
int ClearRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash) Removes a render constant from the container
dmGameSystem::HComponentRenderConstants CreateRenderConstants() Create a new HComponentRenderConstants container
void DestroyRenderConstants(dmGameSystem::HComponentRenderConstants constants) Destroys a render constants container
void EnableRenderObjectConstants(dmRender::RenderObject* ro, dmGameSystem::HComponentRenderConstants constants) set the constants of a render object
bool GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmRender::Constant** out_constant) Destroys a render constants container
dmRender::HConstant GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, uint32_t index) Get a render constant by index
uint32_t GetRenderConstantCount(dmGameSystem::HComponentRenderConstants constants) Get the number of render constants
dmGameObject::PropertyResult GetResourceProperty(const PropVector4& property, void* resource, dmGameObject::PropertyDesc& out_value) Gets the resource path hash
void HashRenderConstants(dmGameSystem::HComponentRenderConstants constants, HashState32* state) Hashes the constants
bool IsReferencingProperty(const PropVector3& property, dmhash_t query) Checks if the name matches any field in the proper...
bool IsReferencingProperty(const PropVector4& property, dmhash_t query) Checks if the name matches any field in the proper...
dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)
dmResource::Result ResFontGetCacheCellSize(FontResource* font, uint32_t* width, uint32_t* height, uint32_t* max_ascent)
dmRender::HFont ResFontGetHandle(FontResource* font)
dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)
dmResource::Result ResFontGetLineHeight(FontResource* font, float* max_ascent, float* max_descent) Get the font line height (max_ascent + max_descent...
bool ResFontHasGlyph(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)
dmResource::Result ResFontSetCacheCellSize(FontResource* font, uint32_t cell_width, uint32_t cell_height, uint32_t max_ascent) Resets the glyph cache and sets the cell size.
dmResource::Result ResFontSetLineHeight(FontResource* font, float max_ascent, float max_descent) Set the font line height, by specifying the max as...
void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmRender::HMaterial material, dmhash_t name_hash, uint32_t value_index, uint32_t* element_index, const dmGameObject::PropertyVar& var) Set a render constant by name. The constant must e...
void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values) Set a render constant by name. The constant must e...
dmGameObject::PropertyResult SetResourceProperty(dmGameObject::HFactory factory, const dmGameObject::PropertyVar& value, dmhash_t ext, void** out_resource) Updates the reference count of the resources, and ...
MACROS
DM_DECLARE_COMPGUI_TYPE(symbol, name, type_create_fn, type_destroy_fn) Registers a new gui node type to the Gui component

Functions

AreRenderConstantsUpdated

int AreRenderConstantsUpdated(dmGameSystem::HComponentRenderConstants constants)

check if the constants have changed

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants

RETURNS

int non zero if the constants were changed

ClearRenderConstant

int ClearRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash)

Removes a render constant from the container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the constant

RETURNS

int non zero if the constant was removed

CreateRenderConstants

dmGameSystem::HComponentRenderConstants CreateRenderConstants()

Create a new HComponentRenderConstants container

PARAMETERS

RETURNS

dmGameSystem::HComponentRenderConstants

DestroyRenderConstants

void DestroyRenderConstants(dmGameSystem::HComponentRenderConstants constants)

Destroys a render constants container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants (must not be 0)

EnableRenderObjectConstants

void EnableRenderObjectConstants(dmRender::RenderObject* ro, dmGameSystem::HComponentRenderConstants constants)

set the constants of a render object

PARAMETERS

dmRender::RenderObject* ro the render object
dmGameSystem::HComponentRenderConstants constants the constants

GetRenderConstant

bool GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmRender::Constant** out_constant)

Destroys a render constants container

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the property
dmRender::Constant** out_constant the pointer where to store the constant

RETURNS

bool returns true if the constant exists

GetRenderConstant

dmRender::HConstant GetRenderConstant(dmGameSystem::HComponentRenderConstants constants, uint32_t index)

Get a render constant by index

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
uint32_t index the index

RETURNS

dmRender::HConstant the pointer where to store the constant

GetRenderConstantCount

uint32_t GetRenderConstantCount(dmGameSystem::HComponentRenderConstants constants)

Get the number of render constants

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants

RETURNS

uint32_t returns the number of set constants

GetResourceProperty

dmGameObject::PropertyResult GetResourceProperty(const PropVector4& property, void* resource, dmGameObject::PropertyDesc& out_value)

Gets the resource path hash

PARAMETERS

const PropVector4& property the property
void* resource the resource to get the
dmGameObject::PropertyDesc& out_value the out property

RETURNS

dmGameObject::PropertyResult RESULT_OK if successful

HashRenderConstants

void HashRenderConstants(dmGameSystem::HComponentRenderConstants constants, HashState32* state)

Hashes the constants

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
HashState32* state the hash state to update

IsReferencingProperty

bool IsReferencingProperty(const PropVector3& property, dmhash_t query)

Checks if the name matches any field in the property

PARAMETERS

const PropVector3& property the property
dmhash_t query the name to look for (e.g. hash("pos.x"))

RETURNS

bool true if the property contains the name

IsReferencingProperty

bool IsReferencingProperty(const PropVector4& property, dmhash_t query)

Checks if the name matches any field in the property

PARAMETERS

const PropVector4& property the property
dmhash_t query the name to look for (e.g. hash("pos.x"))

RETURNS

bool true if the property contains the name

ResFontAddGlyph

dmResource::Result ResFontAddGlyph(FontResource* font, uint32_t codepoint, FontGlyph* glyph, void* imagedata)

PARAMETERS

FontResource* font The font resource to modify
uint32_t codepoint The glyph codepoint
FontGlyph* glyph The glyph meta data
void* imagedata The bitmap or sdf data. May be null for e.g. white space characters. The font will now own this data.

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetCacheCellSize

dmResource::Result ResFontGetCacheCellSize(FontResource* font, uint32_t* width, uint32_t* height, uint32_t* max_ascent)

PARAMETERS

FontResource* font The font resource to modify
uint32_t* width The cache cell width
uint32_t* height The cache cell height
uint32_t* max_ascent The distance from the top of the cell to the baseline.

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetHandle

dmRender::HFont ResFontGetHandle(FontResource* font)

PARAMETERS

FontResource* font The font resource to modify

RETURNS

dmRender::HFont Handle to a font if successful. 0 otherwise.

ResFontGetInfo

dmResource::Result ResFontGetInfo(FontResource* font, FontInfo* info)

PARAMETERS

FontResource* font The font resource to modify
FontInfo* info The output info

RETURNS

dmResource::Result RESULT_OK if successful

ResFontGetLineHeight

dmResource::Result ResFontGetLineHeight(FontResource* font, float* max_ascent, float* max_descent)

Get the font line height (max_ascent + max_descent)

PARAMETERS

FontResource* font The font resource to modify
float* max_ascent The max distance above the base line of any glyph
float* max_descent The max distance below the base line of any glyph

RETURNS

dmResource::Result RESULT_OK if successful

ResFontHasGlyph

bool ResFontHasGlyph(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The glyph codepoint

RETURNS

bool true if the glyph already exists

ResFontRemoveGlyph

dmResource::Result ResFontRemoveGlyph(FontResource* font, uint32_t codepoint)

PARAMETERS

FontResource* font The font resource
uint32_t codepoint The glyph codepoint

RETURNS

dmResource::Result RESULT_OK if successful

ResFontSetCacheCellSize

dmResource::Result ResFontSetCacheCellSize(FontResource* font, uint32_t cell_width, uint32_t cell_height, uint32_t max_ascent)

Resets the glyph cache and sets the cell size.

PARAMETERS

FontResource* font The font resource to modify
uint32_t cell_width The width of a glyph cache cell
uint32_t cell_height The height of a glyph cache cell
uint32_t max_ascent The height of a glyph cache cell

RETURNS

dmResource::Result RESULT_OK if successful

ResFontSetLineHeight

dmResource::Result ResFontSetLineHeight(FontResource* font, float max_ascent, float max_descent)

Set the font line height, by specifying the max ascent and descent

PARAMETERS

FontResource* font The font resource to modify
float max_ascent The max distance above the base line of any glyph
float max_descent The max distance below the base line of any glyph

RETURNS

dmResource::Result RESULT_OK if successful

SetRenderConstant

void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmRender::HMaterial material, dmhash_t name_hash, uint32_t value_index, uint32_t* element_index, const dmGameObject::PropertyVar& var)

Set a render constant by name. The constant must exist in the material

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the render constants buffer
dmRender::HMaterial material the material to get default values from if constant didn't already exist in the render constants buffer
dmhash_t name_hash the hashed name of the constant
uint32_t value_index index of the constant value to set, if the constant is an array
uint32_t* element_index pointer to the index of the element (in range [0,3]). May be 0
const dmGameObject::PropertyVar& var the constant value

SetRenderConstant

void SetRenderConstant(dmGameSystem::HComponentRenderConstants constants, dmhash_t name_hash, dmVMath::Vector4* values, uint32_t num_values)

Set a render constant by name. The constant must exist in the material

PARAMETERS

dmGameSystem::HComponentRenderConstants constants the constants
dmhash_t name_hash the hashed name of the constant
dmVMath::Vector4* values the values
uint32_t num_values number of values in the array

SetResourceProperty

dmGameObject::PropertyResult SetResourceProperty(dmGameObject::HFactory factory, const dmGameObject::PropertyVar& value, dmhash_t ext, void** out_resource)

Updates the reference count of the resources, and returns the new resource.

PARAMETERS

dmGameObject::HFactory factory the factory
const dmGameObject::PropertyVar& value the property containing the hash of the resources to get
dmhash_t ext the hash of the resource file suffix (without the "."). E.g. hash("spritec")
void** out_resource pointer to the current resource. Will also get the pointer to the new resource.

RETURNS

dmGameObject::PropertyResult RESULT_OK if successful

Structs

CompGuiNodeTypeCtx

TYPE

struct CompGuiNodeTypeCtx

Gui component node type create/destroy context


FontGlyph

TYPE

struct FontGlyph

Represents a glyph. If there's an associated image, it is of size width * height * channels.

MEMBERS

float m_Width The glyph bounding width
float m_Height The glyph bounding height
int16_t m_ImageWidth The glyph image width
int16_t m_ImageHeight The glyph image height
int16_t m_Channels The glyph image height
float m_Advance The advance step of the glyph (in pixels)
float m_LeftBearing The left bearing of the glyph (in pixels)
float m_Ascent The ascent of the glyph. (in pixels)
float m_Descent The descent of the glyph. Positive! (in pixels)


FontResource

TYPE

struct FontResource

Handle to font resource


GuiNodeType

TYPE

struct GuiNodeType

Gui component node type


Types

CompGetConstantCallback

Used in GetMaterialConstant to resolve a render constant's value


CompSetConstantCallback

Used in SetMaterialConstant to set a render constant's value


FontInfo

Used to retrieve the information of a font.


GuiNodeTypeDestroyFunction


GuiNodeTypeDestroyFunction


HComponentRenderConstants

Render constants handle


Enums

FontGlyphCompression

Describes what compression is used for the glyph image

FONT_GLYPH_COMPRESSION_NONE No compression
FONT_GLYPH_COMPRESSION_DEFLATE Data is compressed using the deflate() algorithm

Macros

DM_DECLARE_COMPGUI_TYPE

Registers a new gui node type to the Gui component

symbol The unique C++ symbol name
name The name of the node type
type_create_fn the create function
type_destroy_fn the destroy function. May be 0