//
inf.filename = "nice_texture.png";
// how many vertices do wie have
inf.triangles.vertCount = 4;
// allocating memory for vertices (vertex position on the screen, vertex color Color4B, uv)
inf.triangles.verts = new cocos2d::V3F_C4B_T2F[inf.triangles.vertCount];
// we draw 2 triangles so we need 2x3 = 6 indices
inf.triangles.indexCount = 6;
// allocate some memory for our indices
inf.triangles.indices = new unsigned short[inf.triangles.indexCount];
//Create our uv coordinates
cocos2d::Vec2 tc00 = cocos2d::Vec2(0,0);
cocos2d::Vec2 tc10 = cocos2d::Vec2(1,0);
cocos2d::Vec2 tc01 = cocos2d::Vec2(0,1);
cocos2d::Vec2 tc11 = cocos2d::Vec2(1,1);
inf.triangles.verts[0].vertices = cocos2d::Vec3(-1,-1,0);
inf.triangles.verts[0].texCoords = cocos2d::Tex2F(tc00.x,tc00.y);
inf.triangles.verts[0].colors = cocos2d::Color4B(255, 255, 255, 255);
inf.triangles.verts[1].vertices = cocos2d::Vec3(1,-1,0) ;
inf.triangles.verts[1].texCoords = cocos2d::Tex2F(tc10.x,tc10.y);
inf.triangles.verts[1].colors = cocos2d::Color4B(255, 255, 255, 255);
inf.triangles.verts[2].vertices = cocos2d::Vec3(-0.75,1,0);
inf.triangles.verts[2].texCoords = cocos2d::Tex2F(tc01.x,tc01.y);
inf.triangles.verts[2].colors = cocos2d::Color4B(255, 255, 255, 255);
inf.triangles.verts[3].vertices = cocos2d::Vec3(0.75,1,0) ;
inf.triangles.verts[3].texCoords = cocos2d::Tex2F(tc11.x,tc11.y);
inf.triangles.verts[3].colors = cocos2d::Color4B(255, 255, 255, 255);
// setting the indices
inf.triangles.indices[0] = 0;
inf.triangles.indices[1] = 1;
inf.triangles.indices[2] = 2;
inf.triangles.indices[3] = 2;
inf.triangles.indices[4] = 1;
inf.triangles.indices[5] = 3;
//calculating bounding box
float min_x = HUGE_VALF, min_y = HUGE_VALF, max_x = -HUGE_VALF, max_y = -HUGE_VALF;
for (int i = 0; i < 4; i++)
{
min_x = std::min(min_x, inf.triangles.verts[i].vertices.x);
max_x = std::max(max_x, inf.triangles.verts[i].vertices.x);
min_y = std::min(min_y, inf.triangles.verts[i].vertices.y);
max_y = std::max(max_y, inf.triangles.verts[i].vertices.y);
}
//setting bounding box
inf.rect = cocos2d::Rect(cocos2d::Vec2(min_x, min_y), cocos2d::Size(max_x-min_x,max_y-min_y));
sprite->initWithPolygon(inf);