本文整理汇总了C++中Renderable::setAttribBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Renderable::setAttribBuffer方法的具体用法?C++ Renderable::setAttribBuffer怎么用?C++ Renderable::setAttribBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderable
的用法示例。
在下文中一共展示了Renderable::setAttribBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Lines
Renderable* Renderable::Lines(const std::vector<Vec3f> &verts, Material *material) {
Renderable *renderable;
float *vertexBuffer;
unsigned int *indexBuffer;
unsigned int size;
unsigned int i;
size = (unsigned int)verts.size();
renderable = new Renderable();
vertexBuffer = new float[size * 3];
indexBuffer = new unsigned int[size];
for(i=0; i < size; i++) {
vertexBuffer[3*i ] = verts[i].x;
vertexBuffer[3*i+1] = verts[i].y;
vertexBuffer[3*i+2] = verts[i].z;
indexBuffer[i] = i;
}
renderable->setMaterial(material);
renderable->setAttribBuffer("position", size, GL_FLOAT, 3, &vertexBuffer[0]);
renderable->setIndexBuffer(size, &indexBuffer[0]);
renderable->setDrawMode(GL_LINE_STRIP);
delete vertexBuffer;
delete indexBuffer;
return renderable;
}
示例2: OrthoBox
Renderable* Renderable::OrthoBox(const Vec2f &pos, const Vec2f &dims, bool texCoords, bool normals, Material *material, float z) {
Renderable *renderable = new Renderable();
Vec2f disp = pos + dims;
// Incorrect - the view matrix is set by the scene node anytime the scene node's affine matrix changes
//renderable->setViewMatrix(Matrix4::MakeTranslation(Vec3f(pos.x, pos.y, z)));
renderable->setMaterial(material);
// Determine if the vertex order needs to be flipped to preserve proper winding order
bool flipped = ((dims.x < 0) != (dims.y < 0));
// Set the verts
if(flipped) {
float verts[4 * 3] = {
pos.x, disp.y, z,
disp.x, disp.y, z,
disp.x, pos.y, z,
pos.x, pos.y, z
};
renderable->setAttribBuffer("position", 4, GL_FLOAT, 3, &verts[0]);
} else {
float verts[4 * 3] = {
pos.x, pos.y, z,
disp.x, pos.y, z,
disp.x, disp.y, z,
pos.x, disp.y, z
};
renderable->setAttribBuffer("position", 4, GL_FLOAT, 3, &verts[0]);
}
// Set the texture coordinates
if(texCoords && flipped) {
float texCoords[4 * 2] = {
0, 1,
1, 1,
1, 0,
0, 0
};
renderable->setAttribBuffer("texcoord", 4, GL_FLOAT, 2, &texCoords[0]);
} else if(texCoords) {
float texCoords[4 * 2] = {
0, 0,
1, 0,
1, 1,
0, 1
};
renderable->setAttribBuffer("texcoord", 4, GL_FLOAT, 2, &texCoords[0]);
}
// Set the normals
if(normals) {
float normals[4 * 3] = {
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1
};
renderable->setAttribBuffer("normal", 4, GL_FLOAT, 2, &normals[0]);
}
// Set the indices
unsigned int indices[4] = { 0, 1, 3, 2 };
renderable->setIndexBuffer(4, &indices[0]);
return renderable;
}