本文整理汇总了C++中VertexArray::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexArray::Clear方法的具体用法?C++ VertexArray::Clear怎么用?C++ VertexArray::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexArray
的用法示例。
在下文中一共展示了VertexArray::Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderText
float TextDraw::RenderText(
const Font & font, const std::string & text,
float x, float y, float scalex, float scaley,
VertexArray & output_array)
{
output_array.Clear();
float cursorx = x;
float cursory = y + scaley / 4;
for (unsigned int i = 0; i < text.size(); ++i)
{
if (text[i] == '\n')
{
cursorx = x;
cursory += scaley;
}
else
{
cursorx += RenderCharacter(font, text[i], cursorx, cursory, scalex, scaley, output_array);
}
}
return cursorx;
}
示例2: Fill
void Starfield::Fill(unsigned long seed)
{
VertexArray *va = m_model->GetSurface(0)->GetVertices();
va->Clear(); // clear if previously filled
// Slight colour variation to stars based on seed
MTRand rand(seed);
//fill the array
for (int i=0; i<BG_STAR_MAX; i++) {
float col = float(rand.Double(0.2,0.7));
// this is proper random distribution on a sphere's surface
const float theta = float(rand.Double(0.0, 2.0*M_PI));
const float u = float(rand.Double(-1.0, 1.0));
va->Add(vector3f(
1000.0f * sqrt(1.0f - u*u) * cos(theta),
1000.0f * u,
1000.0f * sqrt(1.0f - u*u) * sin(theta)
), Color(col, col, col, 1.f)
);
}
}
示例3: DrawSpike
void Camera::DrawSpike(double rad, const vector3d &viewCoords, const matrix4x4d &viewTransform)
{
// draw twinkly star-thing on faraway objects
// XXX this seems like a good case for drawing in 2D - use projected position, then the
// "face the camera dammit" bits can be skipped
if (!m_renderer) return;
const double newdist = m_zNear + 0.5f * (m_zFar - m_zNear);
const double scale = newdist / viewCoords.Length();
matrix4x4d trans = matrix4x4d::Identity();
trans.Translate(scale*viewCoords.x, scale*viewCoords.y, scale*viewCoords.z);
// face the camera dammit
vector3d zaxis = viewCoords.Normalized();
vector3d xaxis = vector3d(0,1,0).Cross(zaxis).Normalized();
vector3d yaxis = zaxis.Cross(xaxis);
matrix4x4d rot = matrix4x4d::MakeInvRotMatrix(xaxis, yaxis, zaxis);
trans = trans * rot;
m_renderer->SetDepthTest(false);
m_renderer->SetBlendMode(BLEND_ALPHA_ONE);
// XXX this is supposed to pick a correct light colour for the object twinkle.
// Not quite correct, since it always uses the first light
GLfloat col[4];
glGetLightfv(GL_LIGHT0, GL_DIFFUSE, col);
col[3] = 1.f;
static VertexArray va(ATTRIB_POSITION | ATTRIB_DIFFUSE);
va.Clear();
const Color center(col[0], col[1], col[2], col[2]);
const Color edges(col[0], col[1], col[2], 0.f);
//center
va.Add(vector3f(0.f), center);
const float spikerad = float(scale*rad);
// bezier with (0,0,0) control points
{
const vector3f p0(0,spikerad,0), p1(spikerad,0,0);
float t=0.1f; for (int i=1; i<10; i++, t+= 0.1f) {
const vector3f p = (1-t)*(1-t)*p0 + t*t*p1;
va.Add(p, edges);
}
}
{
const vector3f p0(spikerad,0,0), p1(0,-spikerad,0);
float t=0.1f; for (int i=1; i<10; i++, t+= 0.1f) {
const vector3f p = (1-t)*(1-t)*p0 + t*t*p1;
va.Add(p, edges);
}
}
{
const vector3f p0(0,-spikerad,0), p1(-spikerad,0,0);
float t=0.1f; for (int i=1; i<10; i++, t+= 0.1f) {
const vector3f p = (1-t)*(1-t)*p0 + t*t*p1;
va.Add(p, edges);
}
}
{
const vector3f p0(-spikerad,0,0), p1(0,spikerad,0);
float t=0.1f; for (int i=1; i<10; i++, t+= 0.1f) {
const vector3f p = (1-t)*(1-t)*p0 + t*t*p1;
va.Add(p, edges);
}
}
glPushMatrix();
m_renderer->SetTransform(trans);
m_renderer->DrawTriangles(&va, Graphics::vtxColorMaterial, TRIANGLE_FAN);
m_renderer->SetBlendMode(BLEND_SOLID);
m_renderer->SetDepthTest(true);
glPopMatrix();
}