video::EIT_16BIT or video::EIT_32BIT

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

video::EIT_16BIT or video::EIT_32BIT

Post by FreeFrags »

im creating a meshbuffer now i noticed that you can choose between a 16 bit and a 32 bit index type. i currently have a count of the vertices i want to load into a buffer, but i would like to eliminate this step. This is how i determine which type to use now:

Code: Select all

if (m_nVertices <= 65536)
        m_pMeshBuffer = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_16BIT);
    else
        m_pMeshBuffer = new irr::scene::CDynamicMeshBuffer(irr::video::EVT_STANDARD, irr::video::EIT_32BIT);
 
Is there a way to change the index type from 16 to 32 bit when needed? Or is there a better way of doing this?
FreeFrags
Posts: 16
Joined: Thu Mar 25, 2010 2:04 pm

Re: video::EIT_16BIT or video::EIT_32BIT

Post by FreeFrags »

Investigated this and it seems that this would be the best way of doing it as the values of the lists are either 16 or 32 bit.

CIndexBuffer.h

Code: Select all

virtual void setType(video::E_INDEX_TYPE IndexType)
        {
            IIndexList *NewIndices=0;
 
            switch (IndexType)
            {
                case video::EIT_16BIT:
                {
                    NewIndices=new CSpecificIndexList<u16>;
                    break;
                }
                case video::EIT_32BIT:
                {
                    NewIndices=new CSpecificIndexList<u32>;
                    break;
                }
            }
So either you count the vertices you want to add and create the type you need OR you create the 32 bit by default. which could lead to using more memory than is absolutely needed.

(thanks to mk1 for thinking with me on this one)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: video::EIT_16BIT or video::EIT_32BIT

Post by hybrid »

Yes, you have to copy the mesh to the new type if you want to change from 16 to 32 bits. Though we might have a function for this already implemented.
Post Reply