本文整理汇总了C++中ShaderProgram::drawElements方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::drawElements方法的具体用法?C++ ShaderProgram::drawElements怎么用?C++ ShaderProgram::drawElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::drawElements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nativeRender
void nativeRender(int camtex, float *mat) {
if (!running) return;
ShaderEngine::Engine->reset();
ShaderBuffer *oldfbo = ShaderEngine::Engine->setFramebuffer(rdrTgt);
ShaderEngine::Engine->setViewport(0, 0, tex->width, tex->height);
Matrix4 projection = ShaderEngine::Engine->setOrthoFrustum(0,
tex->baseWidth, 0, tex->baseHeight, -1, 1);
ShaderEngine::Engine->setProjection(projection);
Matrix4 model;
ShaderEngine::Engine->setModel(model);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, camtex);
shader->setConstant(shader->getConstantByName("tMatrix"),
ShaderProgram::CMATRIX, 1, mat);
shader->setData(ShaderProgram::DataVertex, ShaderProgram::DFLOAT, 2,
&vertices[0], vertices.size(), vertices.modified,
&vertices.bufferCache);
shader->setData(ShaderProgram::DataTexture, ShaderProgram::DFLOAT, 2,
&texcoords[0], texcoords.size(), texcoords.modified,
&texcoords.bufferCache);
shader->drawElements(ShaderProgram::TriangleStrip, indices.size(),
ShaderProgram::DUSHORT, &indices[0], indices.modified,
&indices.bufferCache);
vertices.modified = false;
texcoords.modified = false;
indices.modified = false;
ShaderEngine::Engine->setFramebuffer(oldfbo);
}
示例2: render
void VideoFrameSurface::render() {
if (!g_frame.isValid()) return;
GLCALL_INIT;
if(g_frame.map(QAbstractVideoBuffer::ReadOnly))
{
GLuint tid=*((GLuint *)camtex->getNative());
GLCALL glBindTexture(GL_TEXTURE_2D, tid);
//qDebug() << "Render:" << g_frame.width()<< g_frame.height() << tid;
GLCALL glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cw, ch,0, GL_RGBA, GL_UNSIGNED_BYTE, g_frame.bits());
ShaderEngine *engine=gtexture_get_engine();
engine->reset();
ShaderBuffer *oldfbo = engine->setFramebuffer(rdrTgt);
engine->setViewport(0, 0, gtex->width, gtex->height);
Matrix4 projection = engine->setOrthoFrustum(0,
gtex->baseWidth, 0, gtex->baseHeight, -1, 1);
engine->setProjection(projection);
Matrix4 model;
engine->setModel(model);
engine->bindTexture(0,camtex);
shader->setData(ShaderProgram::DataVertex, ShaderProgram::DFLOAT, 2,
&vertices[0], vertices.size(), vertices.modified,
&vertices.bufferCache);
shader->setData(ShaderProgram::DataTexture, ShaderProgram::DFLOAT, 2,
&texcoords[0], texcoords.size(), texcoords.modified,
&texcoords.bufferCache);
shader->drawElements(ShaderProgram::TriangleStrip, indices.size(),
ShaderProgram::DUSHORT, &indices[0], indices.modified,
&indices.bufferCache);
vertices.modified = false;
texcoords.modified = false;
indices.modified = false;
engine->setFramebuffer(oldfbo);
g_frame.unmap();
}
}