You.i Engine

Detailed Description

Renderer and associated Materials, Meshes and Shaders.

The renderer is responsible for interfacing with the graphics API on the target platform.

Draw Order

Drawing is done in the order defined by the template file. It can be modified from code by using one of these: CYISceneNode::DrawInFrontOfChildren, CYISceneNode::DrawBehindChildren, CYISceneNode::DrawInFront, CYISceneNode::DrawBehind


Material objects represent all of the drawing parameters required by the renderer to draw a mesh/shape. CYIMaterial can be used to set one or more textures, set a custom shader, blend mode or color.


Precompiled shaders can be loaded from disk using CYIAssetLoader, or a CYIAssetShaderProgram can be compiled by You.i Engine when only source is passed.

Some platforms require the shaders to be pre-compiled. Here is a list of platform support for shaders:

Platform Renderer Shader Language Compile Rule
Android OpenGL ES 2 GLSL Uncompiled
iOS OpenGL ES 2 GLSL Uncompiled
Linux OpenGL 2 GLSL Uncompiled
OS X OpenGL 2 GLSL Uncompiled
PlayStation 4 GNM PSSL Compiled
TvOS OpenGL ES 2 GLSL Uncompiled
Windows Desktop Direct3D11 HLSL Uncompiled
Windows Desktop OpenGL 2 GLSL Uncompiled
UWP Direct3D11 HLSL Uncompiled

Vertex Inputs

The input constants and vertex attributes to custom vertex shaders must use the same semantics used by You.i Engine.

Vertex Elements Semantics

For solids, You.i Engine will bind to these two semantics.

    struct VS_INPUT
        float3 Pos : YiVertexPosition;
        float2 Tex : YiVertexTexCoord;

Constant Matrices

    float4x4 YiCameraMatrix;
    float4x4 YiModelMatrix;
    float4x4 YiMeshMatrix;
    float4x4 YiTextureMatrix0;

Custom semantics can be bound if defined properly in the mesh.


Mesh objects represent an instance of geometry information.

You.i Engine allows to build and display custom mesh data. For simply creating a solid node, look into CYISceneNodeUtility::CreateSolid.

Custom Mesh Sample

The option of interleaving vertex coordinates and UV coordinates is available in You.i Engine for increased performance, but this sample will keep these separate to demonstrate the use of multiple VBOs on a single mesh.

The CYIAssetBufferObjectData::SetType() call is critical. Without this information, You.i Engine would not know how to initialize the GPU objects that will mirror this data.

The buffer that will store vertex coordinates:

std::shared_ptr<CYIAssetBufferObjectData> pVertices(new CYIAssetBufferObjectData);

The buffer that will store store texture coordinates:

std::shared_ptr<CYIAssetBufferObjectData> pTextureCoordinates(new CYIAssetBufferObjectData);

The buffer that will store indices:

std::shared_ptr<CYIAssetBufferObjectData> pIndices(new CYIAssetBufferObjectData);

Defining a unit cube centered on the origin. -z is front, and +y is up.

static const int32_t nVertexCount = 72;
float fVertices[72] = {
    //Rear face
    -0.5, -0.5, 0.5,   //0
    0.5, -0.5, 0.5,    //1
    -0.5, 0.5, 0.5,    //2
    0.5, 0.5, 0.5,     //3

    //Front face
    -0.5, -0.5, -0.5,  //4
    -0.5, 0.5, -0.5,   //5
    0.5, 0.5, -0.5,    //6
    0.5, -0.5, -0.5,   //7

    //Top face
    -0.5, 0.5, -0.5,   //8
    0.5, 0.5, -0.5,    //9
    0.5, 0.5, 0.5,     //10
    -0.5, 0.5, 0.5,    //11

    //Bottom face
    -0.5, -0.5, -0.5,  //12
    -0.5, -0.5, 0.5,   //13
    0.5, -0.5, 0.5,    //14
    0.5, -0.5, -0.5,   //15

    //Left face
    0.5, -0.5, -0.5,   //16
    0.5, -0.5, 0.5,    //17
    0.5, 0.5, 0.5,     //18
    0.5, 0.5, -0.5,    //19

    //Right face
    -0.5, -0.5, -0.5,  //20
    -0.5, 0.5, -0.5,   //21
    -0.5, 0.5, 0.5,    //22
    -0.5, -0.5, 0.5    //23

The cube's texture coordinates:

static const int32_t nUVcount = 48;
float fUVs[48] = {
    0.0, 1.0,           //0
    1.0, 1.0,           //1
    0.0, 0.0,           //2
    1.0, 0.0,           //3

    1.0, 1.0,           //4
    1.0, 0.0,           //5
    0.0, 0.0,           //6
    0.0, 1.0,           //7

    0.0, 1.0,           //8
    1.0, 1.0,           //9
    1.0, 0.0,           //10
    0.0, 0.0,           //11

    0.0, 1.0,           //12
    0.0, 0.0,           //13
    1.0, 0.0,           //14
    1.0, 1.0,           //15

    1.0, 1.0,           //16
    0.0, 1.0,           //17
    0.0, 0.0,           //18
    1.0, 0.0,           //19

    0.0, 1.0,           //20
    0.0, 0.0,           //21
    1.0, 0.0,           //22
    1.0, 1.0            //23

The vertex indices to be used in constructing the geometry, using triangles.

static const int32_t nUndexCount = 36;
uint16_t uIndices[nUndexCount] = {
        0, 1, 2, 1, 3, 2,
    4, 5, 6, 6, 7, 4,
    8, 10, 9, 8, 11, 10,
    12, 14, 13, 12, 15, 14,
    16, 18, 17, 18, 16, 19,
    20, 22, 21, 22, 20, 23 };

Assigning the data into the buffers:

pVertices->SetData((uint8_t*)fVertices, nVertexCount, sizeof(float));
pTextureCoordinates->SetData((uint8_t*)fUVs, nUVcount, sizeof(float));
pIndices->SetData((uint8_t*)uIndices, nIndexCount, sizeof(uint16_t));

Now the control of these assets will be handed over to the asset manager. The asset manager automatically construct the VRAM counterparts and allows to immediately make use of this data.

In fact, upon registry into the asset manager, subsequent updates will also happen automatically. This means that these three assets can be modified, and in the next frame, the new data will be rendered to the screen without having to touch the hardware assets.

CYIAssetManager *pAM = CYIFramework::GetInstance()->GetAssetManager();


Initializing of the cube mesh:

std::shared_ptr<CYIMesh> pCubeMesh(new CYIMesh);

Since the mesh was just created, the first binding will be zero, and the second one will be one. This is because the buffers increment starting at zero. However, in general usage, mesh configuration may happen long after mesh creation, and it's best to use the return value to ensure that something else didn't jump the queue.

uint32_t vBindPoint = pCubeMesh->AddVertexBuffer(pVertices, CYIMesh::BufferOwnership::Owned);   // The binding point for vertex information
uint32_t tBindPoint = pCubeMesh->AddVertexBuffer(pTextureCoordinates, CYIMesh::BufferOwnership::Owned);  // The binding point for texture information

There can be only one index buffer per mesh, so this has no return value.

pCubeMesh->SetIndexBuffer(pIndices, CYIMesh::BufferOwnership::Owned);

Telling the mesh how many indices it must draw. Note that even if index buffer wasn't used, the mesh would still need to know how many elements need to be drawn. This function call cannot be skipped.


Specifying a bounding box for the cube. This is important for picking.

CYIAABB unitBox;
unitBox.SetCorners(glm::vec3(-0.5, -0.5, -0.5), glm::vec3(0.5, 0.5, 0.5));

The geometry above was designed to use triangles. So the mesh needs to know about it:


Configuring the vertex buffer bindings. This is how the Renderer is told about what the information in the vertex buffers means.


The default You.i Engine shader is used. This location is where it expects the position values to be.

PositionBinding.uAttribute = CYIMesh::YI_POSITION;

This is where the Renderer is told which vertex buffer to use:

PositionBinding.uBufferIndex = vBindPoint;

The entire VBO is dedicated to position information, so it doesn't need to have an offset by any number of bytes. Had it has been interleaving position information with other information, this is where it would indicate how many bytes into the stride the position information begins.

PositionBinding.uByteOffset = 0;

There are three floats per position, X, Y, Z.

PositionBinding.uNumElements = 3;

Each vertex chunk is three floats long, or 12 bytes. Had it been interleaved, this number would be greater and it would have had to specify an offset for the subsequent data.

PositionBinding.uStride = 12;

UVBinding.uAttribute = CYIMesh::YI_TEXCOORD;
UVBinding.uBufferIndex = tBindPoint;
UVBinding.uByteOffset = 0;
UVBinding.uNumElements = 2;
UVBinding.uStride = 8;

The final bindings are set into the mesh, so it can now be renderable:

pCubeMesh->SetBindings({ PositionBinding, UVBinding });


file  YiOpenGL.h


class  IYIBufferFactory
 Factory for the creation of Vertex and Index buffers. More...
class  CYICanvas
 Draws vector graphics to a bitmap. More...
class  CYIGradient
 Contains information on how a gradient will be drawn. More...
class  CYIPaint
 Descriptor for drawing vector graphics. More...
class  CYIPath
 A class that contains information on how a path will be drawn. More...
 A structure that describe a single vertex of a polygon. More...
class  CYIPolygonFill
 A class that contains information on how to fill a polygon. More...
class  CYIPolygonStroke
 Class which draws a stroke representing CYIPolygonData. More...
struct  YI_REGION
class  CYITextureAtlas
 Class for a texture atlas. More...
class  CYIBufferObject
class  CYIBufferObjectFactory
struct  SYI_CAPS
class  CYICapabilities
struct  EffectUniform
struct  EffectUniformVariable
class  CYIEffect
class  CYIFramebufferFactory
class  IYIGPUObject
 An interface for managing GPU-bound objects such as shaders and textures. More...
class  CYIMask
 Adds a masking effect to a scene node. More...
class  CYIMaterial
 CYIMaterial is a place holder for all the drawing parameters required by the renderer to draw a mesh/shape. More...
class  IYIMaterialFactory
 Material Factory interface for the generation of all things texture and shader related. More...
class  CYIMesh
 Class representing an instance of geometry information. More...
class  CYIMeshFactory
 Factory for the creation of meshes. More...
class  CYIOffscreenRenderTarget
 Defines an offscreen target for the rendering results to be sent to. More...
class  CYIRenderable
 This class contains the data required by the renderer in order to render a renderable component. More...
class  IYIRenderer
class  CYIRenderingSurfaceInfo
class  CYIRenderListBuilder
 CYIRenderListBuilder. More...
class  CYIRenderSystem
 CYIRenderSystem is a singleton class used to acquire global instances of a number of classes. More...
class  CYIRenderTarget
 Defines a target for the rendering results to be sent to. More...
class  CYIScreenRenderTarget
class  CYIShaderFactory
class  IYIShaderProgram
 This class provides a common interface for creating and interacting with shader programs. More...
class  SpriteSheet
class  CYITextureFactory
class  CYIUniformBufferId
 The CYIUniformBufferId class is an identification class for Uniform buffers that also reveals the name of the uniform buffer as a string. More...
class  IYIUniformBufferObject
 Common interface for shader uniform buffers. More...
struct  CYIVertexData
class  CYIViewport
class  CYIGeometryBatch
 Allows drawing of simple 2D geometry in batch. More...
class  CYIBitmapUtilitiesPNG
 Utility class used to perform PNG image operations in software. More...
class  CYID3D11AbstractBufferObject
 An abstract class for common Direct3D buffer functionality. More...
class  CYID3D11FramebufferObject
 IYIGPUObject implementation for OpenGL Framebuffers. More...
class  CYID3D11TextureObject
 IYIGPUObject implementation for DirectFB textures. More...
class  CYIGNMAbstractBufferObject
 An abstract class for common Gnm buffer functionality. More...
class  CYIGNMFramebufferObject
class  CYIGNMTextureObject
 IYIGPUObject implementation for GNM textures on PlayStation. More...
class  CYIGLAbstractBufferObject
 An abstract class for common OpenGL buffer functionality. More...
class  CYIGLFramebufferObject
 IYIGPUObject implementation for OpenGL Framebuffers. More...
class  CYIGLTextureObject
 IYIGPUObject implementation for OpenGL textures. More...
class  CYIBitmap
 The core bitmap container class used by You.i Engine. More...
class  CYIBitmapUtilities
 Utility class used to perform image operations in software. Not using GPU / hardware acceleration. More...
struct  YI_RECT
struct  YI_RECT_REL


typedef std::vector< YI_POLYGON_VERTEXCYIPolygonData
 A type representing multiple vertices of a polygon. More...
typedef IDXGISwapChain1 D3D11SwapChain


const unsigned int YI_SHADER_PROGRAM_INVALID = 0
const unsigned int YI_BUFFER_OBJECT_INVALID = 0
const unsigned int YI_TEXTURE_INVALID = 0
static const uint32_t CYIMesh::YI_POSITION = 0
static const uint32_t CYIMesh::YI_TEXCOORD = 1
static const uint32_t CYIMesh::YI_NORMAL = 2
static const uint32_t CYIMesh::YI_COLOR = 3

Typedef Documentation

◆ CYIPolygonData

typedef std::vector<YI_POLYGON_VERTEX> CYIPolygonData

A type representing multiple vertices of a polygon.

See also

◆ D3D11SwapChain

typedef IDXGISwapChain1 D3D11SwapChain

Variable Documentation


const unsigned int YI_BUFFER_OBJECT_INVALID = 0


const uint32_t CYIMesh::YI_COLOR = 3

Vertex color - "YiVertexColor"


const uint32_t CYIMesh::YI_NORMAL = 2

Vertex normals - "YiVertexNormal"


const uint32_t CYIMesh::YI_POSITION = 0

Binding values to assist in configuring vertex data. These attribute bindings will be respected by all You.i Engine shaders. For custom shaders, these bindings must be associated with shader attributes via the IYIShaderProgram::SetAttributeBinding() interface.

There is no restriction to the number of attributes, layout of attributes, or association of attributes to attribute locations. The below are merely the ones that You.i Engine will respect natively, they can be overwritten, expanded, or ignored.

Vertex position - "YiVertexPosition"


const unsigned int YI_SHADER_PROGRAM_INVALID = 0


const uint32_t CYIMesh::YI_TEXCOORD = 1

Vertex texture coordinates - "YiVertexTexCoord"


const unsigned int YI_TEXTURE_INVALID = 0