Example #1
0
void GridGLMesh::resize(const Dim &dim)
{
    if ( m_dim != dim )
    {
        m_dim = dim;
        m_vertices.bind(GL_ARRAY_BUFFER, GL_STREAM_DRAW, 
                        dim.size()*sizeof(ud::Vec3f));
        m_colors.bind(GL_ARRAY_BUFFER, GL_STREAM_DRAW, 
                      dim.size()*sizeof(ud::Vec3f));
        m_indices.bind(GL_ELEMENT_ARRAY_BUFFER, GL_STREAM_DRAW, 
                       (dim.height()*2*(dim.width() - 1))*sizeof(GLuint));
        
        GLuint *indices = m_indices.map<GLuint>();
        GLuint count = 0;
        for (size_t c=0; c<dim.width() - 1; c++)
        {
            for (size_t r=0; r<dim.height(); r++)
            {
                indices[count++] = r*dim.width() + c;
                indices[count++] = r*dim.width() + c + 1;
            }
        }
        m_indices.unmap();
    }
}
Example #2
0
void TestDim::scalar() {
	Dim d;
	CPPUNIT_ASSERT(d.nb_rows()==1);
	CPPUNIT_ASSERT(d.nb_cols()==1);
	CPPUNIT_ASSERT(d.size()==1);
	CPPUNIT_ASSERT(d==Dim::scalar());
	CPPUNIT_ASSERT(d.is_scalar());
	CPPUNIT_ASSERT(!d.is_vector());
	CPPUNIT_ASSERT(!d.is_matrix());
	CPPUNIT_ASSERT(d.type()==Dim::SCALAR);
	CPPUNIT_ASSERT(Dim(d)==d);
	CPPUNIT_ASSERT((Dim::scalar()=d)==d);

}