本文整理汇总了C++中QOpenGLFunctions::glVertexAttribPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFunctions::glVertexAttribPointer方法的具体用法?C++ QOpenGLFunctions::glVertexAttribPointer怎么用?C++ QOpenGLFunctions::glVertexAttribPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFunctions
的用法示例。
在下文中一共展示了QOpenGLFunctions::glVertexAttribPointer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupVertexAttribs
void GLWidget::setupVertexAttribs()
{
m_vertexBuffer.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glVertexAttribPointer(
0, //index
3, //size
GL_FLOAT, //type
GL_FALSE, //normalized?
0, //stride
0 ); //array buffer offset
m_vertexBuffer.release();
m_normalBuffer.bind();
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(
1, //index
3, //size
GL_FLOAT, //type
GL_FALSE, //normalized?
0, //stride
0 ); //array buffer offset
m_normalBuffer.release();
}
示例2: create
void Mesh::create()
{
if(isCreated()) { return; }
m_vao.create();
m_vao.bind();
m_vbo.create();
m_vbo.bind();
m_vbo.allocate(m_data.constData(), m_data.size() * sizeof(MeshVertex));
m_vbo.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
f->glEnableVertexAttribArray(2);
f->glEnableVertexAttribArray(3);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), 0);
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
f->glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), reinterpret_cast<void *>(6 * sizeof(GLfloat)));
f->glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, sizeof(MeshVertex), reinterpret_cast<void *>(8 * sizeof(GLfloat)));
m_vbo.release();
m_vao.release();
m_isCreated = true;
}
示例3: initGL
void GlCube::initGL()
{
m_vao_constraints.create();
m_vbo_constraints.create();
m_ibo_constraints.create();
m_vao_constraints.bind(); CE();
m_vbo_constraints.bind(); CE();
m_vbo_constraints.setUsagePattern(QOpenGLBuffer::UsagePattern::StaticDraw); CE();
m_ibo_constraints.bind(); CE();
m_ibo_constraints.setUsagePattern(QOpenGLBuffer::UsagePattern::StaticDraw); CE();
QOpenGLFunctions * f = QOpenGLContext::currentContext()->functions();
GLsizei stride = sizeof(GLfloat) * 7;
f->glEnableVertexAttribArray(0); CE();
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, stride, (void*)(0)); CE();
f->glEnableVertexAttribArray(1); CE();
f->glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, stride, (void*)(sizeof(GLfloat) * 3)); CE();
m_vao_constraints.release(); CE();
m_vbo_constraints.release(); CE();
m_ibo_constraints.release(); CE();
fillBuffers();
}
示例4: create
//clockwise 4 vertex uv TL TR BL BR
void CubeFace::create(float x1,float y1, float x2,float y2,float x3,float y3,float x4,float y4)
{
QOpenGLFunctions f = QOpenGLFunctions(QOpenGLContext::currentContext());
//creat the vertexes
float CubeFaceVertices[] =
{
// Positions // Texture Coords
1,-1, 0, x3, y3,
1, 1, 0, x2, y2,
-1, 1, 0, x1, y1,
-1, 1, 0, x1, y1,
-1,-1, 0, x4, y4,
1,-1, 0, x3, y3,
};
m_buffer->bind();
m_buffer->allocate(CubeFaceVertices, sizeof(CubeFaceVertices));
m_vao->bind();
f.glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
f.glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
f.glEnableVertexAttribArray(0);
f.glEnableVertexAttribArray(1);
m_vao->release();
m_buffer->release();
}
示例5: setupVertexAttribs
void CompasWidget::setupVertexAttribs(){
m_logoVbo.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0);
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
m_logoVbo.release();
}
示例6: sizeof
void CompasWidget::setupVertexAttribs2(){
m_vbo2->bind();
m_program2->enableAttributeArray(0);
m_program2->enableAttributeArray(1);
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (const void *)(36 * 3 * sizeof(GLfloat)));
m_vbo2->release();
}
示例7: setupVertexAttribs
void GLRasterTexture::setupVertexAttribs()
{
m_vbo.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, DATA_DIMENSIONS * sizeof(GLfloat),
0);
f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, DATA_DIMENSIONS * sizeof(GLfloat),
reinterpret_cast<void *>(3 * sizeof(GLfloat)));
m_vbo.release();
}
示例8: setupVertexAttribs
void CGLWidget::setupVertexAttribs()
{
m_vbo.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
m_vbo.release();
m_uvBuff.bind();
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
m_uvBuff.release();
}
示例9: SetupVertexAttributes
void ViewportWidget::SetupVertexAttributes(QOpenGLBuffer* vbo)
{
if (!vbo)
return;
vbo->bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), 0);
f->glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), reinterpret_cast<void *>(3 * sizeof(GLfloat)));
vbo->release();
}
示例10: initGL
void DrawableTerrain::initGL()
{
m_vao_constraints.create(); CE();
m_vbo_constraints.create(); CE();
m_ibo_constraints.create(); CE();
m_vao_constraints.bind(); CE();
m_vbo_constraints.bind(); CE();
m_vbo_constraints.setUsagePattern(QOpenGLBuffer::UsagePattern::StaticDraw); CE();
m_ibo_constraints.bind(); CE();
m_ibo_constraints.setUsagePattern(QOpenGLBuffer::UsagePattern::StaticDraw); CE();
QOpenGLFunctions * f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0); CE();
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)(0)); CE();
// Texture coordinate
// f->glEnableVertexAttribArray(1); CE();
// const int sz = 3*sizeof(GLfloat);
// f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5*sizeof(GLfloat), (void*)(sz)); CE();
m_vao_constraints.release(); CE();
m_vbo_constraints.release(); CE();
m_ibo_constraints.release(); CE();
fillBuffers();
}
示例11: draw
void ScreenAlignedQuad::draw(QOpenGLFunctions &gl)
{
m_vertices->bind();
gl.glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 0, nullptr);
gl.glEnableVertexAttribArray(0);
gl.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
示例12: draw
void GLShaderTextured::draw(unsigned int mode, const QMatrix4x4& transformMatrix, GLfloat *textureCoords, GLfloat *vertices, int nbVertices)
{
if (!m_texture) {
qDebug("GLShaderTextured::draw: no texture defined. Doing nothing");
return;
}
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
m_program->bind();
m_program->setUniformValue(m_matrixLoc, transformMatrix);
m_texture->bind();
m_program->setUniformValue(m_textureLoc, 0); // Use texture unit 0 which magically contains our texture
f->glEnableVertexAttribArray(0); // vertex
f->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
f->glEnableVertexAttribArray(1); // texture coordinates
f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, textureCoords);
f->glDrawArrays(mode, 0, nbVertices);
f->glDisableVertexAttribArray(0);
m_program->release();
}
示例13: initVertexArray
void Grid::initVertexArray()
{
vao.create();
vao.bind();
vbo.bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
vbo.release();
vao.release();
}
示例14: render
void OpenGLVideo::render(const QRectF &target, const QRectF& roi, const QMatrix4x4& transform)
{
DPTR_D(OpenGLVideo);
Q_ASSERT(d.manager);
VideoShader *shader = d.manager->prepareMaterial(d.material);
shader->update(d.material);
shader->program()->setUniformValue(shader->matrixLocation(), transform*d.matrix);
// uniform end. attribute begin
if (target.isValid())
d.geometry.setRect(target, d.material->normalizedROI(roi));
else
d.geometry.setRect(d.rect, d.material->normalizedROI(roi));
// normalize?
#if 1
shader->program()->setAttributeArray(0, GL_FLOAT, d.geometry.data(0), 2, d.geometry.stride());
shader->program()->setAttributeArray(1, GL_FLOAT, d.geometry.data(1), 2, d.geometry.stride());
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
static QGLFunctions *glf = new QGLFunctions();
glf->initializeGLFunctions();
#else
QOpenGLFunctions *glf = QOpenGLContext::currentContext()->functions();
#endif
glf->glVertexAttribPointer(0, 2, GL_FLOAT, GL_TRUE, d.geometry.stride(), d.geometry.data(0));
glf->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, d.geometry.stride(), d.geometry.data(1));
#endif
char const *const *attr = shader->attributeNames();
for (int i = 0; attr[i]; ++i) {
shader->program()->enableAttributeArray(i); //TODO: in setActiveShader
}
glDrawArrays(d.geometry.mode(), 0, d.geometry.vertexCount());
// d.shader->program()->release(); //glUseProgram(0)
for (int i = 0; attr[i]; ++i) {
shader->program()->disableAttributeArray(i); //TODO: in setActiveShader
}
d.material->unbind();
}
示例15: buildQuadTextured
QOpenGLBuffer* GLImageProcessor::buildQuadTextured() const
{
QOpenGLBuffer* lpvbo = new QOpenGLBuffer();
typedef struct
{
float xyz[3];
float uv[2];
} VertexUV;
VertexUV Vertices[] =
{
{ { -1.0f, -1.0f, 0.0f }, { 0.0f, 0.0f } },
{ { -1.0f, 1.0f, 0.0f }, { 0.0f, 1.0f } },
{ { 1.0f, 1.0f, 0.0f }, { 1.0f, 1.0f } },
{ { 1.0f, -1.0f, 0.0f }, { 1.0f, 0.0f } }
};
const size_t BufferSize = sizeof(Vertices);
const size_t VertexSize = sizeof(Vertices[0]);
const size_t UVOffset = sizeof(Vertices[0].xyz);
// Setup our vertex buffer object.
lpvbo->create();
lpvbo->bind();
lpvbo->allocate(Vertices, BufferSize);
lpvbo->bind();
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glEnableVertexAttribArray(0);
f->glEnableVertexAttribArray(1);
f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, VertexSize, 0);
f->glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, VertexSize, reinterpret_cast<void *>(UVOffset));
lpvbo->release();
return lpvbo;
}