本文整理汇总了C++中Vertices::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertices::data方法的具体用法?C++ Vertices::data怎么用?C++ Vertices::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices::data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTexCoords
void Model::setTexCoords(const Vertices& texCoords)
{
m_texCoords.resize(texCoords.size());
std::memcpy(m_texCoords.data(), texCoords.data(), texCoords.size() * 2 * sizeof(float));
if (m_texCoordsVBO)
{
m_texCoordsVBO.bind();
m_texCoordsVBO.write(texCoords);
m_texCoordsVBO.release();
}
}
示例2: meshGDALDataset
bool MDAL::LoaderGdal::initVertices( Vertices &vertices )
{
Vertex *VertexsPtr = vertices.data();
unsigned int mXSize = meshGDALDataset()->mXSize;
unsigned int mYSize = meshGDALDataset()->mYSize;
const double *mGT = meshGDALDataset()->mGT;
for ( unsigned int y = 0; y < mYSize; ++y )
{
for ( unsigned int x = 0; x < mXSize; ++x, ++VertexsPtr )
{
// VertexsPtr->setId(x + mXSize*y);
VertexsPtr->x = mGT[0] + ( x + 0.5 ) * mGT[1] + ( y + 0.5 ) * mGT[2];
VertexsPtr->y = mGT[3] + ( x + 0.5 ) * mGT[4] + ( y + 0.5 ) * mGT[5];
VertexsPtr->z = 0.0;
}
}
BBox extent = computeExtent( vertices );
// we want to detect situation when there is whole earth represented in dataset
bool is_longitude_shifted = ( extent.minX >= 0.0 ) &&
( fabs( extent.minX + extent.maxX - 360.0 ) < 1.0 ) &&
( extent.minY >= -90.0 ) &&
( extent.maxX <= 360.0 ) &&
( extent.maxX > 180.0 ) &&
( extent.maxY <= 90.0 );
if ( is_longitude_shifted )
{
for ( Vertices::size_type n = 0; n < vertices.size(); ++n )
{
if ( vertices[n].x > 180.0 )
{
vertices[n].x -= 360.0;
}
}
}
return is_longitude_shifted;
}
示例3: createVAO
int ParticleSystem::createVAO(Shader newShader, Vertices vtx, Indices ind)
{
int rc = 0;
GLint location; // location of the attributes in the shader;
shader = newShader;
//create vertex array object
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
//create vertex buffer object
glGenBuffers(1, &vtxVBO);
glBindBuffer(GL_ARRAY_BUFFER, vtxVBO);
glBufferData(GL_ARRAY_BUFFER, vtx.size() * sizeof(Vertex), vtx.data(), GL_STATIC_DRAW);
//copy the vertex position
location = glGetAttribLocation(shader.getProgId(), "vtxPos");
if (location == -1) {
rc = -1;
goto err;
}
glEnableVertexAttribArray(location);
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, pos));
//copy the vertex color
location = glGetAttribLocation(shader.getProgId(), "vtxCol");
// if (location == -1) {
// rc = -2;
//goto err;
//}
glEnableVertexAttribArray(location);
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, col));
//copy the vertex normal
location = glGetAttribLocation(shader.getProgId(), "vtxNorm");
// if (location == -1) {
// rc = -2;
//goto err;
//}
glEnableVertexAttribArray(location);
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, norm));
// copy the texture coords
location = glGetAttribLocation(shader.getProgId(), "texCoord");
// if (location == -1) {
// rc = -2;
//goto err;
//}
glEnableVertexAttribArray(location);
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, texCoord));
//create index buffer
glGenBuffers(1, &indVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indVBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ind.size() * sizeof(GLuint), ind.data(), GL_STATIC_DRAW);
// store the number of indices
numIndices = vtx.size();
//numIndices = ind.size();
//end creation
glBindVertexArray(0);
err:
return(rc);
}