    

 ## On this page

  

 

 # Test005

 Last update: 16.07.2025 

 /// &lt;script src="./ansys251/nexus/viewer-loader.js"&gt;&lt;/script&gt; /// ///

Textured 2D Quad.

This example shows how to create a simple 2D textured quad.

/\*

 \* Copyright 2018-2021 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.

 \* 

 \* Restricted Rights Legend

 \*

 \* Use, duplication, or disclosure of this

 \* software and its documentation by the

 \* Government is subject to restrictions as

 \* set forth in subdivision \[(b)(3)(ii)\] of

 \* the Rights in Technical Data and Computer

 \* Software clause at 52.227-7013.

 \*/

\#include &lt;vector&gt;

 

\#include "GLTFWriter.h"

\#include "test.h"

 

using namespace ANSYS::AVZ;

 

// Simple creation of Textured Quad

TESTFUNC(Textured2DQuad)

{

 if (type != GLTFWriter::GLTF::OT_AVZ &amp;&amp; type != GLTFWriter::GLTF::OT_GLTF)

 return;

 

 <a id="_a0" name="_a0"></a>[GLTFWriter::GLTF](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml) *gltf = GLTFWriter::GLTF::Create("MyApp", "1.0", functionName.c_str(), type);

 if (!gltf)

 throw std::runtime_error("Can't create GLTF");

 

 // SCENE

 <a id="_a1" name="_a1"></a>[GLTFWriter::Scene](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml) *scene = GLTFWriter::Scene::Create(gltf, "TestScene", "m", 1.0, GLTFWriter::Scene::BT_SOLID, 0.5, 0.5, 0.5);

 if (!scene) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create scene");

 }

 

 // LIGHTS

 {

 // LIGHT NODE

 <a id="_a2" name="_a2"></a>[GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *lightNode = GLTFWriter::Node::CreateLight(gltf);

 if (!lightNode || !scene-&gt;<a id="a3" name="a3"></a>[SetLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ac92acb916999693ccaaefe8a81962c67)(lightNode)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create light");

 }

 

 // LIGHTS

 <a id="_a4" name="_a4"></a>[GLTFWriter::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml) *light1 = GLTFWriter::Light::CreateAmbient(gltf);

 lightNode-&gt;<a id="a5" name="a5"></a>[AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)(light1);

 

 [GLTFWriter::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml) *light2 = GLTFWriter::Light::CreateDirectional(gltf);

 lightNode-&gt;[AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)(light2);

 }

 

 // 3D MESH NODE

 {

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "3D Box");

 if (!node || !scene-&gt;<a id="a6" name="a6"></a>[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 <a id="_a7" name="_a7"></a>[GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !node-&gt;<a id="a8" name="a8"></a>[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TECHNIQUE

 <a id="_a9" name="_a9"></a>[GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml) *technique = GLTFWriter::Technique::Create(gltf);

 if (!technique ||

 // TECHNIQUE STATES

 !technique-&gt;<a id="a10" name="a10"></a>[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_DEPTHTESTENABLE, 1)) ||

 !technique-&gt;[AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)(GLTFWriter::State::Create(gltf, GLTFWriter::State::ST_BLENDENABLE, 1))) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create technique");

 }

 

 // MATERIAL

 <a id="_a11" name="_a11"></a>[GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml) *material = GLTFWriter::Material::Create(gltf, technique);

 

 // VERTICES

 std::vector&lt;float&gt; vertices;

 const float width = 1;

 const float height = 1;

 const float depth = 1;

 const float shiftX = 0;

 const float shiftY = 0;

 const float shiftZ = 0;

 vertices.push_back(-width / 2 + shiftX); vertices.push_back(-height / 2 + shiftY); vertices.push_back(-depth / 2 + shiftZ);

 vertices.push_back( width / 2 + shiftX); vertices.push_back(-height / 2 + shiftY); vertices.push_back(-depth / 2 + shiftZ);

 vertices.push_back( width / 2 + shiftX); vertices.push_back( height / 2 + shiftY); vertices.push_back(-depth / 2 + shiftZ);

 vertices.push_back(-width / 2 + shiftX); vertices.push_back( height / 2 + shiftY); vertices.push_back(-depth / 2 + shiftZ);

 vertices.push_back(-width / 2 + shiftX); vertices.push_back(-height / 2 + shiftY); vertices.push_back( depth / 2 + shiftZ);

 vertices.push_back( width / 2 + shiftX); vertices.push_back(-height / 2 + shiftY); vertices.push_back( depth / 2 + shiftZ);

 vertices.push_back( width / 2 + shiftX); vertices.push_back( height / 2 + shiftY); vertices.push_back( depth / 2 + shiftZ);

 vertices.push_back(-width / 2 + shiftX); vertices.push_back( height / 2 + shiftY); vertices.push_back( depth / 2 + shiftZ);

 // POSITION ATTRIBUTE

 <a id="_a12" name="_a12"></a>[GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *vertex = GLTFWriter::Attribute::CreatePosition(gltf, (unsigned int)vertices.size() / 3, &amp;vertices[0]);

 

 // COLORS

 std::vector&lt;float&gt; colors;

 colors.push_back(0); colors.push_back(0); colors.push_back(0); colors.push_back(1);

 colors.push_back(0); colors.push_back(0); colors.push_back(1); colors.push_back(0.75);

 colors.push_back(0); colors.push_back(1); colors.push_back(0); colors.push_back(0.5);

 colors.push_back(0); colors.push_back(1); colors.push_back(1); colors.push_back(0.25);

 colors.push_back(1); colors.push_back(0); colors.push_back(1); colors.push_back(0.5);

 colors.push_back(1); colors.push_back(0); colors.push_back(0); colors.push_back(0.25);

 colors.push_back(1); colors.push_back(1); colors.push_back(1); colors.push_back(1);

 colors.push_back(1); colors.push_back(1); colors.push_back(0); colors.push_back(0.75);

 // COLOR ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *color = GLTFWriter::Attribute::CreateColor(gltf, GLTFWriter::Attribute::AT_FLOAT_VEC4, (unsigned int)colors.size() / 4, &amp;colors[0]);

 

 // INDICES

 std::vector&lt;unsigned short&gt; indices;

 indices.push_back(0); indices.push_back(2); indices.push_back(1);

 indices.push_back(0); indices.push_back(3); indices.push_back(2);

 indices.push_back(0); indices.push_back(4); indices.push_back(7);

 indices.push_back(0); indices.push_back(7); indices.push_back(3);

 indices.push_back(4); indices.push_back(5); indices.push_back(6);

 indices.push_back(4); indices.push_back(6); indices.push_back(7);

 indices.push_back(5); indices.push_back(1); indices.push_back(2);

 indices.push_back(5); indices.push_back(2); indices.push_back(6);

 indices.push_back(0); indices.push_back(1); indices.push_back(5);

 indices.push_back(0); indices.push_back(5); indices.push_back(4);

 indices.push_back(2); indices.push_back(3); indices.push_back(7);

 indices.push_back(2); indices.push_back(7); indices.push_back(6);

 // INDICES

 <a id="_a13" name="_a13"></a>[GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml) *index = GLTFWriter::Index::Create(gltf, (unsigned int)indices.size(), &amp;indices[0]);

 

 // NORMALS

 std::vector&lt;float&gt; normals(vertices.size());

 GLTFWriter::Utils::ComputeVertexNormals3((unsigned int)vertices.size() / 3, &amp;vertices[0], (unsigned int)indices.size() / 3, 3, &amp;indices[0], &amp;normals[0]);

 // NORMAL ATTRIBUTE

 [GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml) *normal = GLTFWriter::Attribute::CreateNormal(gltf, (unsigned int)vertices.size() / 3, &amp;normals[0]);

 

 // PRIMITIVE

 <a id="_a14" name="_a14"></a>[GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create(gltf, GLTFWriter::Primitive::PT_TRIANGLES, material, index);

 if (!primitive ||

 !mesh-&gt;<a id="a15" name="a15"></a>[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive) ||

 !primitive-&gt;<a id="a16" name="a16"></a>[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(vertex) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(normal) ||

 !primitive-&gt;[AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)(color)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create primitive");

 }

 }

 

 // 2D MESH NODE

 {

 // NODE

 [GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml) *node = GLTFWriter::Node::CreateMesh(gltf, "2D Textured Quad");

 if (!node || !scene-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)(node)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh node");

 }

 

 // MESH

 [GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml) *mesh = GLTFWriter::Mesh::Create(gltf);

 if (!mesh || !node-&gt;[AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)(mesh)) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Can't create mesh");

 }

 

 // TEXTURE

 {

 std::vector&lt;unsigned char&gt; imageData;

 const unsigned width = 150;

 const unsigned height = 250;

 imageData.resize(width * height * 4, 0);

 

\# define SETRGB(data, width, x, y, r, g, b, a) { \\

 data\[4 \* ((x) + (y) \* (width)) + 0\] = r; \\

 data\[4 \* ((x) + (y) \* (width)) + 1\] = g; \\

 data\[4 \* ((x) + (y) \* (width)) + 2\] = b; \\

 data\[4 \* ((x) + (y) \* (width)) + 3\] = a; \\

 }

 

 // fill in top left corner

 for (unsigned int i = 0; i &lt; 10; ++i)

 for (unsigned int j = 0; j &lt; 10; ++j)

 SETRGB(imageData, width, i + 2, j + 2, 255, 255, 255, 255);

 

 // PRIMITIVE

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 255, 0, 0, 255);

 SETRGB(imageData, width, i, 1, 255, 0, 0, 255);

 SETRGB(imageData, width, i, height - 1, 255, 0, 0, 255);

 SETRGB(imageData, width, i, height - 2, 255, 0, 0, 255);

 }

 for (unsigned int i = 0; i &lt; height; ++i) {

 SETRGB(imageData, width, 0, i, 255, 0, 0, 255);

 SETRGB(imageData, width, 1, i, 255, 0, 0, 255);

 SETRGB(imageData, width, width - 1, i, 255, 0, 0, 255);

 SETRGB(imageData, width, width - 2, i, 255, 0, 0, 255);

 }

 <a id="_a17" name="_a17"></a>[GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml) *texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 [GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml) *primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_LEFT, GLTFWriter::Primitive::PYA_TOP);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 0, 255, 0, 255);

 SETRGB(imageData, width, i, 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 2, 0, 255, 0, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_LEFT, GLTFWriter::Primitive::PYA_CENTER);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 0, 0, 255, 255);

 SETRGB(imageData, width, i, 1, 0, 0, 255, 255);

 SETRGB(imageData, width, i, height - 1, 0, 0, 255, 255);

 SETRGB(imageData, width, i, height - 2, 0, 0, 255, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_LEFT, GLTFWriter::Primitive::PYA_BOTTOM);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 

 for (unsigned int i = 0; i &lt; height; ++i) {

 SETRGB(imageData, width, 0, i, 0, 255, 0, 255);

 SETRGB(imageData, width, 1, i, 0, 255, 0, 255);

 SETRGB(imageData, width, width - 1, i, 0, 255, 0, 255);

 SETRGB(imageData, width, width - 2, i, 0, 255, 0, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_CENTER, GLTFWriter::Primitive::PYA_BOTTOM);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 0, 255, 0, 255);

 SETRGB(imageData, width, i, 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 2, 0, 255, 0, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_CENTER, GLTFWriter::Primitive::PYA_CENTER);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 255, 0, 0, 255);

 SETRGB(imageData, width, i, 1, 255, 0, 0, 255);

 SETRGB(imageData, width, i, height - 1, 255, 0, 0, 255);

 SETRGB(imageData, width, i, height - 2, 255, 0, 0, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_CENTER, GLTFWriter::Primitive::PYA_TOP);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 

 for (unsigned int i = 0; i &lt; height; ++i) {

 SETRGB(imageData, width, 0, i, 0, 0, 255, 255);

 SETRGB(imageData, width, 1, i, 0, 0, 255, 255);

 SETRGB(imageData, width, width - 1, i, 0, 0, 255, 255);

 SETRGB(imageData, width, width - 2, i, 0, 0, 255, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_RIGHT, GLTFWriter::Primitive::PYA_TOP);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 0, 255, 0, 255);

 SETRGB(imageData, width, i, 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 1, 0, 255, 0, 255);

 SETRGB(imageData, width, i, height - 2, 0, 255, 0, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_RIGHT, GLTFWriter::Primitive::PYA_CENTER);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 0, 0, 255, 255);

 SETRGB(imageData, width, i, 1, 0, 0, 255, 255);

 SETRGB(imageData, width, i, height - 1, 0, 0, 255, 255);

 SETRGB(imageData, width, i, height - 2, 0, 0, 255, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, GLTFWriter::Primitive::PXA_RIGHT, GLTFWriter::Primitive::PYA_BOTTOM);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 

 

 for (unsigned int i = 0; i &lt; width; ++i) {

 SETRGB(imageData, width, i, 0, 255, 255, 255, 255);

 SETRGB(imageData, width, i, 1, 255, 255, 255, 255);

 SETRGB(imageData, width, i, height - 1, 255, 255, 255, 255);

 SETRGB(imageData, width, i, height - 2, 255, 255, 255, 255);

 }

 for (unsigned int i = 0; i &lt; height; ++i) {

 SETRGB(imageData, width, 0, i, 255, 255, 255, 255);

 SETRGB(imageData, width, 1, i, 255, 255, 255, 255);

 SETRGB(imageData, width, width - 1, i, 255, 255, 255, 255);

 SETRGB(imageData, width, width - 2, i, 255, 255, 255, 255);

 }

 texture = GLTFWriter::Texture::Create(gltf, GLTFWriter::Texture::TF_RGBA, width, height, &amp;imageData[0]);

 primitive = GLTFWriter::Primitive::Create2DTexture(gltf, texture, 0.15F, 0.25F, 0.2F, 0.4F);

 mesh-&gt;[AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)(primitive);

 }

 }

 

 if (!gltf-&gt;<a id="a18" name="a18"></a>[Write](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a0bf3a4ec615dc8810776dd82a65eba91)()) {

 GLTFWriter::GLTF::Destroy(gltf);

 throw std::runtime_error("Error creating file");

 }

 

 [GLTFWriter::GLTF::GLTFError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a5b8141dc8536bc10d1a72996ad6f98b4) error = gltf-&gt;<a id="a19" name="a19"></a>[GetError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a63295f8f31619517e94cf27d3a8b9ea8)();

 

 GLTFWriter::GLTF::Destroy(gltf);

 

 if (error != GLTFWriter::GLTF::GLTF_ERROR_NONE)

 throw std::runtime_error("Error creating file");

}

[ANSYS::AVZ::GLTFWriter::Attribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_attribute.xhtml)

Attributes define the per element index values for elements defined by Index.

**Definition** [GLTFAttribute.h:32](_g_l_t_f_attribute_8h_source.xhtml#l00031)



[ANSYS::AVZ::GLTFWriter::GLTF](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml)

This is the main class of the GLTFWriter.

**Definition** [GLTFGLTF.h:32](_g_l_t_f_g_l_t_f_8h_source.xhtml#l00031)



[ANSYS::AVZ::GLTFWriter::GLTF::Write](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a0bf3a4ec615dc8810776dd82a65eba91)

virtual bool Write(bool formatJSON=false)=0



[ANSYS::AVZ::GLTFWriter::GLTF::GLTFError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a5b8141dc8536bc10d1a72996ad6f98b4)

GLTFError

**Definition** [GLTFGLTF.h:35](_g_l_t_f_g_l_t_f_8h_source.xhtml#l00035)



[ANSYS::AVZ::GLTFWriter::GLTF::GetError](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_g_l_t_f.xhtml#a63295f8f31619517e94cf27d3a8b9ea8)

virtual GLTFError GetError()=0



[ANSYS::AVZ::GLTFWriter::Index](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_index.xhtml)

Indexes define elements within primitives.

**Definition** [GLTFIndex.h:29](_g_l_t_f_index_8h_source.xhtml#l00028)



[ANSYS::AVZ::GLTFWriter::Light](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_light.xhtml)

Lights define the light objects that can be added to a light node.

**Definition** [GLTFLight.h:31](_g_l_t_f_light_8h_source.xhtml#l00030)



[ANSYS::AVZ::GLTFWriter::Material](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_material.xhtml)

Materials describe how primitives are rendered.

**Definition** [GLTFMaterial.h:30](_g_l_t_f_material_8h_source.xhtml#l00029)



[ANSYS::AVZ::GLTFWriter::Mesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml)

Meshes define the renderable objects that can be added to a node.

**Definition** [GLTFMesh.h:104](_g_l_t_f_mesh_8h_source.xhtml#l00103)



[ANSYS::AVZ::GLTFWriter::Mesh::AppendPrimitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_mesh.xhtml#afb99ec25e2eebb4390c17f8770e4c23b)

virtual bool AppendPrimitive(Primitive *primitive)=0



[ANSYS::AVZ::GLTFWriter::Node](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml)

Nodes are the GLTFWriter class that contain the data that is defined in the GLTF file.

**Definition** [GLTFNode.h:31](_g_l_t_f_node_8h_source.xhtml#l00030)



[ANSYS::AVZ::GLTFWriter::Node::AppendLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a576db36280a02127b5eb662f0566543b)

virtual bool AppendLight(Light *light)=0



[ANSYS::AVZ::GLTFWriter::Node::AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_node.xhtml#a68c9eec5fe03405e52b3558a62f8faec)

virtual bool AppendMesh(Mesh *mesh)=0



[ANSYS::AVZ::GLTFWriter::Primitive](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml)

Primitives are the renderable parts of meshes.

**Definition** [GLTFMesh.h:30](_g_l_t_f_mesh_8h_source.xhtml#l00029)



[ANSYS::AVZ::GLTFWriter::Primitive::AppendAttribute](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_primitive.xhtml#ac4144b4cc35eec9c11b07cc7352d209e)

virtual bool AppendAttribute(Attribute *attribute)=0



[ANSYS::AVZ::GLTFWriter::Scene](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml)

Scenes are the GLTFWriter class that create the view of the data that is defined in the GLTF file.

**Definition** [GLTFScene.h:29](_g_l_t_f_scene_8h_source.xhtml#l00028)



[ANSYS::AVZ::GLTFWriter::Scene::AppendMesh](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#a76e34d4c05fe34dde0fcc4913ad63981)

virtual bool AppendMesh(Node *mesh)=0



[ANSYS::AVZ::GLTFWriter::Scene::SetLight](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_scene.xhtml#ac92acb916999693ccaaefe8a81962c67)

virtual bool SetLight(Node *light)=0



[ANSYS::AVZ::GLTFWriter::Technique](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml)

Techniques performs the rendering of primitives.

**Definition** [GLTFTechnique.h:240](_g_l_t_f_technique_8h_source.xhtml#l00239)



[ANSYS::AVZ::GLTFWriter::Technique::AppendState](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_technique.xhtml#a8b2b0766157324d5a2093a3fca36379f)

virtual bool AppendState(State *state)=0



[ANSYS::AVZ::GLTFWriter::Texture](class_a_n_s_y_s_1_1_a_v_z_1_1_g_l_t_f_writer_1_1_texture.xhtml)

Textures are images that can be used to color a primitive.

**Definition** [GLTFTexture.h:28](_g_l_t_f_texture_8h_source.xhtml#l00027)