Skip to content
3DExtended edited this page Oct 22, 2017 · 19 revisions

CGameEngine

GUI.FontHandler.Character

A helper class which symbols a character from a font file

Methods

GetxAdvance

Getter for the xAdvance attribute

Return value

The xAdvance

GetsizeY

Getter for the sizeY attribute

Return value

The sizeY

GetsizeX

Getter for the sizeX attribute

Return value

The sizeX

GetyOffset

Getter for the yOffset attribute

Return value

The yOffset

GetxOffset

Getter for the xOffset attribute

Return value

The xOffset

GetyTextureCoord

Getter for the yTextureCoord attribute

Return value

The yTextureCoord

GetxTextureCoord

Getter for the xTextureCoord attribute

Return value

The xTextureCoord

GetID

Getter for the ID attribute

Return value

The ID

Constructor

A constructor that creates a character instance with its specified attributes

Parameters

id: The id of this char (normally ascii representation of char)

xTextureCoord: X component of the upper left corner of this char on its font-texture

yTextureCoord: Y component of the upper left corner of this char on its font-texture

xOffset: A virtual cursor will be used. This value specifies where to locate this chars vertex depending on the x-offset

yOffset: A virtual cursor will be used. This value specifies where to locate this chars vertex depending on the y-offset

sizeX: The width of this character

sizeY: The height of this character

xAdvance: Which offset receives the virtual cursor after writing this letter

Constructor

Default constructor.

GUI.FontHandler

This class is used to represent one font on the screen. It handles the render call that renders every text element on the screen and also is able to return a Text object to represent one text. This class is implemented using the singleton pattern.

Methods

Character.GetxAdvance

Getter for the xAdvance attribute

Return value

The xAdvance

Character.GetsizeY

Getter for the sizeY attribute

Return value

The sizeY

Character.GetsizeX

Getter for the sizeX attribute

Return value

The sizeX

Character.GetyOffset

Getter for the yOffset attribute

Return value

The yOffset

Character.GetxOffset

Getter for the xOffset attribute

Return value

The xOffset

Character.GetyTextureCoord

Getter for the yTextureCoord attribute

Return value

The yTextureCoord

Character.GetxTextureCoord

Getter for the xTextureCoord attribute

Return value

The xTextureCoord

Character.GetID

Getter for the ID attribute

Return value

The ID

Constructor

A constructor that creates a character instance with its specified attributes

Parameters

id: The id of this char (normally ascii representation of char)

xTextureCoord: X component of the upper left corner of this char on its font-texture

yTextureCoord: Y component of the upper left corner of this char on its font-texture

xOffset: A virtual cursor will be used. This value specifies where to locate this chars vertex depending on the x-offset

yOffset: A virtual cursor will be used. This value specifies where to locate this chars vertex depending on the y-offset

sizeX: The width of this character

sizeY: The height of this character

xAdvance: Which offset receives the virtual cursor after writing this letter

Constructor

Default constructor.

RenderAllFonts

This call renders every font stored in the "fonts" vector

AddText(std::string,System.Single)

This method creates a new text by specifying a std::string and the depth of the text.

Parameters

str: The text you want to add to the render list

depth: The depth for the new text

Return value

The Text handler for that str and font-shader combination symbolized with this class

AddText(std::string)

This method creates a new text by specifying a std::string.

Parameters

str: The text you want to add to the render list

Return value

The Text handler for that str and font-shader combination symbolized with this class

GetFontHandler(std::string!System.Runtime.CompilerServices.IsConst,std::string!System.Runtime.CompilerServices.IsConst)

The singleton getter of this class. This call is used to get the fonthandler used for a specified font (by fontfiles and shader)

Parameters

pathToFontFiles: This call expects to find an .png image containing the letters and also the .fnt file which holds detailed information about each char on that image

shaderPath: The path to the shader files used for rendering text

Return value

A pointer to the FontHandler used to render texts in this font-shader combination

Dispose

The deconstructor of this class deletes all text components since they are not valid without their renderer

GUI.Text

This class is used to handle text on screen. In particular this class is a wrapper to a std::string instance which is than rendered to the screen. Note that this class does not have a public constructor since it has to be initialized using a FontHandler instance.

Methods

Constructor

The constructor of this class. You need to pass the string you want to get rendered and an valid instance of a FontHandler to indicate the font the text gets rendered in.

Parameters

text: The string that gets represented

fontHandler: The font handler that creates this text element

Dispose

The deconstructor for this class. Destroys a text component.

op_LessThan(ENGINE.GUI.Text!System.Runtime.CompilerServices.IsConst*!System.Runtime.CompilerServices.IsImplicitlyDereferenced)

This operator is used to order the text elements by their depth. The text instance with the smaller depth value wins this comparison.

Parameters

b: The text you want to compare against

Return value

True, if the left text element has a smaller depth value. Else false

SetTextsize(System.Single)

Note that the pixel size can vary from screen to screen This sets the textsize using pixels.

Parameters

size: The new text size

GetDepth

This returns the current depth for this item (See also SetDepth for more detail).

Return value

returns the current depth

SetDepth(System.Single)

The depth of this component is used to move a text before or behind another GUI item.

Parameters

val: The new depth for this instance

GetString

This methode returns the string represented by this class

Return value

The string used in this class

AppendText(std::string)

This methods adds a string ("appendText") to the string of this class-instance

Parameters

appendText: The text you want to append

UTIL.Rect

A rect providing info about a 2D-position and width and height either in pixels or in screen location (-1 to 1 on the x- and y-axis)

Fields

height

The height of this rect.

width

The width of this rect

y

the Y value of this rect

x

The X value of this rect

Methods

MouseInRect(System.Int32,System.Int32)

Note that the mouse position has to be in the right coordinate system. (See toPixels() and fromPixels()) Returns true if the specified mouse position is inside the rect.

Parameters

mouseX: The X-Coordinat of the mouse position

mouseY: The Y-Coordinat of the mouse position

Return value

True if the passed mouse position is inside the rect, else false.

MouseInRect(glm.vec<0x2,System.Single,0x0>)

Note that the mouse position has to be in the right coordinate system. (See toPixels() and fromPixels()) Returns true if the specified mouse position is inside the rect.

Parameters

mousePos: The mouse position

Return value

True if the passed mouse position is inside the rect, else false.

fromPixels

Converts this rect from Pixel-Coordinats into Screen-Coordinats based on the current display dimensions

toPixels

Converts this rect from Screen-Coordinats into Pixel-Coordinats based on the current display dimensions

Constructor

creates a new rect with given parameters

Parameters

x: the x position

y: the y position

width: the width for the rect

height: the height for the rect

inScreenCoords: are the passed values in a coord system from -1 to 1

Constructor

Creates a new Rect where every component (x, y, width, height) is initialized with 0.

Texture

This class is a wrapper for using textures. The implementation supports only "*.png" files. Use the SetActivationSlot(...) to set which texture slot you wanna use (GL_TEXTUREi, where i ranges from 0 to (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)).

... //e.g. load texture 
{
	Bind(shader);
	Bind(texture);
	//bind sampler to shader location
	glUniform1i(shader->getUniform("tex"), 0);	//only when the Sampler2D in the shader source code is called "tex"
	... //Render stuff
} // Texture and Shader are unbound automatically

Methods

_unbind

Used to unbind the texture. This call is automated when the BIND(...) macro was used to bind this texture.

_bind

Used to bind the texture (using the BIND(...) macro defined in the AutoUnbind header.

SetActivationSlot(System.UInt32)

This method sets the slot where the texture is bound to. Valid input-range: GL_TEXTUREi, where i ranges from 0 to (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)

Parameters

value: The slot you want to use.

Constructor

The constructor loads the image and pushes it to the GPU. Supported file extensions: .png

Parameters

path: Path to file (including file extension).

Renderer

This class is used to Render a specified model with a given shader.

Note that neither the Model nor the Shader can be used without this class and get rendered.

Methods

Render

This function renders the model using the specified shader to the current context.

Constructor

Creates a new Renderer for a passed shader and a given model.

Parameters

shaderName: The path to the shader

model: A pointer to the model you wanna render

UTIL.AutoUnbind

This class is a wrapper for using the scopewatch. The essential idea is to have a macro (Bind(...)) which can be used to bind a child of this class and gets unbound automatically.

Methods

_unbind

The method used to unbind this object. Has to be implemented!

_bind

The method used to bind this object. Has to be implemented!

GameObject

A gameobject is a object in the scene. It is used as a collection of components with some additional funcionallity: Each GameObject has a transform component which is used to store the position, the rotation and the scale of that object. GameObjects are also used to handle a parent-child relation of objects (for example useful to make a player object with different attatchments).

Note that not every GameObject has to be visible and support some kind of render. It can also be used to create handlers or some other singletons.

Fields

transform

The Transform component is assigned to each GameObject to store position scale and rotation. Note that the Parent-Child-relation has impact on the calculations taking place in the transform instance.

Methods

AddChild(ENGINE.GameObject*)

Adds a child to this gameObject

Parameters

obj: The new child

SetParent(ENGINE.GameObject*)

Sets the parent for this gameObject

Parameters

obj: the parent for this object

GetChilds

This returns a list of all child gameobjects that are assigned to this gameObject.

Return value

A list of all childs, or an empty list

GetParent

This function returns the parent if existing. If not existing, this returns nullptr.

Return value

The parent gameObject if existing, else nullptr

AddComponent(ENGINE.Component*)

This method is used to assign a component to the GameObject. Note that you have to create a lasting component (using the 'new' macro).

Parameters

comp: The component you want to add.

Example
Component *comp = new RotateObjectComponent();
gameObject->AddComponent(comp);

Constructor

Note that it is strongly advised to create a GameObject using the Instantiate() method offered by the Scene or the component class. This creates a new GameObject with a specified name.

Parameters

name: The name of the new GameObject

Constructor

Note that it is strongly advised to create a GameObject using the Instantiate() method offered by the Scene or the component class. This creates a new GameObject with the empty string as name.

Transform

This class is a part of each GameObject which stores rotation position and a three dimensional scale value for the object. It also provides a methods for creating (for the rendering of the object) the model matrix.

Fields

scale

The scale value of the Transform and the corresponding GameObject

rotation

The rotation of the Transform and the corresponding GameObject

position

The position of the Transform and the corresponding GameObject

Methods

GetPosMatrix

This method returns a matrix that positions the object using this Transform

Return value

The position matrix

GetRotationMatrix

This method returns a matrix that rotates the object using this Transform

Return value

The rotation matrix

GetScaleMatrix

This method returns a matrix that scales the object using this Transform

Return value

The scale matrix

GetModelMatrix

This method returns a model matrix for this transform object. Therefore the position matrix the rotation matrix and the scale matrix is multiplied. The parent transform is used to calculate this matrix (if and only if existing).

Return value

Model matrix (with parent transform)

Constructor

Note that this class can be used without a GameObject but will in this case not be used in the scene. This creates a new Transform object where position and rotation can be specified (by default they are 0). This constructor can also be used with a specified scale value (which by default is 1).

Parameters

pos: The three dimensional position of the object

rot: The three dimensional rotation of the object

scale: The three dimensional scale of the object

Component

This class is abstract and has to be inherited. It provides the standard functions as Start() or Update() and when added to an active GameObject instance is called by the engine. It also provides basic functionality to the engine like a ShowMouse function.

Methods

Destroy

This function is called when the component gets destroyed.

Render

This function is called to render the scene (once a frame). Is called AFTER LateUpdate().

LateUpdate

This function is called each frame to update the component (and/or scene). Is called AFTER Update().

Update

This function is called each frame to update the component (and/or scene). Is called as first update function each frame.

Start

This function is called in the following frame after the component was created Is called AFTER Awake().

Awake

This function is called in the following frame after the component was created. Is called BEFORE Start().

SetMousePosition(System.Int32,System.Int32)

Sets the mouse position relative to the window. Note that the mouse position can be set when the mouse is not showing.

Parameters

x: The target mouse position on the X-Axis in pixel.

y: The target mouse position on the Y-Axis in pixel.

ShowMouse(System.Boolean)

Can be used to en-/disable the mouse pointer while the mouse is hovering over the window opened by the Game-Engine.

Parameters

showMouse: If true the mouse is shown, if false it is not.

Instantiate(std::string)

Creates a new gameObject with a specified name. This GameObject is introduced to the current scene.

Parameters

name: The name for the new GameObject

Return value

A pointer to the empty gameObject with the name.

Instantiate

Creates a new gameObject with name "". This GameObject is introduced to the current scene.

Return value

A pointer to the empty gameObject.

GetCurrentGameObject

Returns a pointer to the gameObject the component is running on/connected to.

Return value

A pointer to the gameObject.

GetCurrentCamera

Returns a pointer to the current scene camera. Usefull e.g. to update the cameras location or rotation.

Return value

A pointer to the current/active camera.

GetCurrentScene

Returns a handle to the active scene (to access their functionalities).

Return value

A pointer to the active/current scene.

Clone this wiki locally