drawVertexPrimitiveList

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
FreeFrags
Posts: 16
Joined: Thu Mar 25, 2010 2:04 pm

drawVertexPrimitiveList

Post by FreeFrags »

Hi,

I cant seem to figure out how to use drawVertexPrimitiveList

I tried the following:

A for loop creating the data to be drawn

Code: Select all

//This is a irr::scene::CVertexBuffer
vertexBuffer->push_back(pointVertex);

//This is a irr::scene::CIndexBuffer*
//Filled with values from 0 - number of vertices
indexBuffer->push_back(pointCounter);


A function which should draw the data

Code: Select all

m_driver->beginScene(true, true, irr::video::SColor(255,200,200,200));
m_driver->setMaterial(Material);

m_smgr->getVideoDriver()->drawVertexPrimitiveList(pVertexBuffer, pVertexBuffer->size(), pIndexBuffer, pIndexBuffer->size(),irr::video::E_VERTEX_TYPE::EVT_STANDARD, irr::scene::E_PRIMITIVE_TYPE::EPT_POINTS, irr::video::E_INDEX_TYPE::EIT_32BIT);

m_smgr->drawAll(); 
m_driver->endScene();
hope you can tell me where i went wrong, i get an exception so i think i did something wrong with the index buffer i used?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It looks like you are not using drawVertexPrimitiveList() correctly. The first and third parameters are pointers to vertex data and index data respectively. You are passing pointers to the vertex buffer and index buffer instead.

Another thing that you can do to improve the safety of your code is to ask the vertex buffer and index buffer for the type of the data contained within. In other words...

Code: Select all

// assuming that these are initialized correctly
scene::IVertexBuffer* pVertexBuffer = // ... your vertex buffer
scene::IIndexBuffer* pIndexBuffer = // ... your index buffer

driver->drawVertexPrimitiveList(
  pVertexBuffer->pointer(), pVertexBuffer->size(),
  pIndexBuffer->pointer(), pIndexBuffer->size(), 
  pVertexBuffer->getType(),
  video::EPT_POINTS,
  pIndexBuffer->getType());
Also, don't forget to set the world transform before calling drawVertexPrimitiveList().

Travis
Post Reply