本文整理汇总了C++中Context::DrawElements方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::DrawElements方法的具体用法?C++ Context::DrawElements怎么用?C++ Context::DrawElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::DrawElements方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()(const Particles& particles)
{
gl.Enable(Capability::Blend);
gl.Bind(vao);
gl.Use(prog);
gl.DrawElements(PrimitiveType::Points, particles.Count(), (GLuint*)0);
gl.Disable(Capability::Blend);
}
示例2: Render
void Render(ExampleClock& clock)
{
positions.clear();
ages.clear();
// update the emitters and get the particle data
for(auto i=emitters.begin(), e=emitters.end(); i!=e; ++i)
{
i->Update(clock);
i->Upload(positions, ages);
}
assert(positions.size() == ages.size());
// make a camera matrix
auto cameraMatrix = CamMatrixf::Orbiting(
Vec3f(),
38.0 - SineWave(clock.Now().Seconds() / 6.0) * 17.0,
FullCircles(clock.Now().Seconds() * 0.1),
Degrees(SineWave(clock.Now().Seconds() / 20.0) * 60)
);
std::vector<float> depths(positions.size());
std::vector<GLuint> indices(positions.size());
// calculate the depths of the particles
for(GLuint i=0, n=positions.size(); i!=n; ++i)
{
depths[i] = (cameraMatrix * Vec4f(positions[i], 1.0)).z();
indices[i] = i;
}
// sort the indices by the depths
std::sort(
indices.begin(),
indices.end(),
[&depths](GLuint i, GLuint j)
{
return depths[i] < depths[j];
}
);
// upload the particle positions
pos_buf.Bind(Buffer::Target::Array);
Buffer::Data(Buffer::Target::Array, positions, BufferUsage::DynamicDraw);
// upload the particle ages
age_buf.Bind(Buffer::Target::Array);
Buffer::Data(Buffer::Target::Array, ages, BufferUsage::DynamicDraw);
gl.Clear().ColorBuffer().DepthBuffer();
camera_matrix.Set(cameraMatrix);
// use the indices to draw the particles
gl.DrawElements(
PrimitiveType::Points,
indices.size(),
indices.data()
);
}
示例3: Render
void Render(double time)
{
auto camera = CamMatrixf::Orbiting(
Vec3f(),
3.0,
FullCircles(time / 13.0),
Degrees(-SineWave(time / 19.0) * 85)
);
camera_matrix.Set(camera);
gl.Clear().ColorBuffer().DepthBuffer();
gl.DrawElements(PrimitiveType::TriangleStrip, 6*5, DataType::UnsignedInt);
}
示例4: Render
void Render(double time)
{
gl.Clear().ColorBuffer().DepthBuffer();
//
// set the matrix for camera orbiting the origin
camera_matrix.Set(
CamMatrixf::LookingAt(
cam_path.Position(time / 9.0),
tgt_path.Position(time / 7.0)
)
);
// draw the points
gl.DrawArrays(PrimitiveType::Points, 0, node_count * 3);
// draw the edges
gl.DrawElements(
PrimitiveType::Lines,
edge_count,
DataType::UnsignedInt
);
}