Beispiel #1
0
const MeshVertex* D3D9Mesh::Vertices() const
{
    if(_Vertices == NULL)
    {
        LockVB();
    }
    return _Vertices;
}
Beispiel #2
0
bool JRenderServer::CacheVB( int vbID, BYTE* pData, int size, int stride, int& iteration, int& firstByte )
{
    if (vbID < 0 || vbID >= m_VBuffers.size()) return -1;
    VBInstance& vb = m_VBuffers[vbID];
    if (vb.m_CurIteration == iteration) return true;

    //  data is not in buffer - try to add it there
    if (vb.m_Size < vb.m_CurLastByte + size + stride)
    {
        // no place in buffer - discard it
        ClearVB( vbID );
        vb.m_CurLastByte = 0;
        vb.m_CurIteration++;
    }

    if (vb.m_Size < size) 
    {
        rlog.err( "Could not cache %d bytes in vertex buffer %s", size, vb.m_Name.c_str() );
        return false;
    }
    
    firstByte = vb.m_CurLastByte;

    //  align firstByte to stride
    if (firstByte%stride != 0)
    {
        firstByte += stride - firstByte%stride;
    }

    iteration = vb.m_CurIteration;

    BYTE* pBuf = LockVB( vbID, firstByte, size );
    if (!pBuf)
    {
        rlog.err( "Could not lock vertex buffer, id:%d", vbID );
        return false;
    }
    memcpy( pBuf, pData, size );
    UnlockVB( vbID );

    return true;
} // JRenderServer::CacheVB
Beispiel #3
0
void D3D9Mesh::Lock() const
{
    LockVB();
    LockIB();
}