Exemple #1
0
int Attribute::appendElement( void *mem )
{
	int pos = m_data.size();
	m_data.resize( pos + numComponents()*elementComponentSize() );
	msys_memcpy( &m_data.m_data[pos], mem, numComponents()*elementComponentSize() );
	return m_numElements++;
}
Exemple #2
0
Attribute *Attribute::copy()
{
	Attribute *nattr = new Attribute( numComponents(), elementComponentSize() );
	nattr->m_data.resize( numElements() * numComponents()*elementComponentSize() );
	msys_memcpy( nattr->m_data.m_data, m_data.m_data, numElements() * numComponents()*elementComponentSize() );
	nattr->m_numElements = numElements();
	return nattr;
}
Exemple #3
0
void Attribute::bindAsAttribute( int index )
{
	// activate and specify pointer to vertex array
	// should be done only when attribute has been updated
	oglBindBuffer(GL_ARRAY_BUFFER, m_bufferId);
	oglBufferData(GL_ARRAY_BUFFER, numComponents()*elementComponentSize()*numElements(), getRawPointer(), GL_STATIC_DRAW);

	oglBindBuffer(GL_ARRAY_BUFFER, m_bufferId);
	oglEnableVertexAttribArray(index);
	oglVertexAttribPointer(index, numComponents(), elementComponentType(), false, 0, 0);

}
Exemple #4
0
	void Attribute::bindAsAttribute( int index )
	{
		if(m_isDirty && m_numElements)
		{
			// activate and specify pointer to vertex array
			// should be done only when attribute has been updated
			glBindBuffer(GL_ARRAY_BUFFER, m_bufferId);
			glBufferData(GL_ARRAY_BUFFER, numComponents()*elementComponentSize()*numElements(), getRawPointer(), GL_STATIC_DRAW);
			m_isDirty = false;
		}

		glBindBuffer(GL_ARRAY_BUFFER, m_bufferId);
		glEnableVertexAttribArray(index);
		if( m_internalComponentType == GL_FLOAT )
			glVertexAttribPointer(index, numComponents(), m_internalComponentType, false, 0, 0);
		else
			glVertexAttribIPointer(index, numComponents(), m_internalComponentType, 0, 0);

	}
Exemple #5
0
void Attribute::getElement( int vertexIndex, void *mem )
{
	if(vertexIndex<numElements())
		msys_memcpy( mem, &m_data.m_data[vertexIndex * numComponents()*elementComponentSize()], numComponents()*elementComponentSize() );
}
Exemple #6
0
void Attribute::removeElement( int vertexIndex )
{
	m_data.erase( vertexIndex*numComponents()*elementComponentSize(), numComponents()*elementComponentSize() );
	--m_numElements;
}
Exemple #7
0
int Attribute::appendElements( int num )
{
	m_data.resize( m_data.size() + num*numComponents()*elementComponentSize() );
	m_numElements += num;
	return m_numElements;
}