IDirect3DVertexBuffer::Lock( ) Help

closed account (zb0S216C)
I'm not understanding the IDirec3DVertexVertexBuffer9::Lock( ) method. Firstly, here's my method:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
template < typename T >
HOLOBYTE T_VERTEXBUFFER_HANDLER::AddVertice( DWORD Offset, T &Vertex )
{
    if( this->IsEmpty( ) )
        return( LOBYTE_CALL_FAILED | HOBYTE_INTERNAL_ERROR );

    if( ( Offset >= 0 ) && ( Offset <= ( this->Get_VertexCount( ) - 1 ) ) )
    {
        T *Data( nullptr );
        HRESULT Result( S_OK );

        Result = this->VertexBuffer->Lock( ( Offset * sizeof( T ) ), sizeof( T ), 
            ( void ** )&Data, 0 );

        if( FAILED( Result ) )
            return( LOBYTE_CALL_FAILED | HOBYTE_INTERNAL_ERROR );

        Data[Offset] = Vertex;
        this->VertexBuffer->Unlock( );
        Data = nullptr;
        return( LOBYTE_CALL_OK );
    }

    return( LOBYTE_CALL_FAILED | LOBYTE_INVALID_ARG );
}

Your primary focus is on the Lock( ) method. Instead of locking the entire buffer, I wanted to lock a section of the buffer where the vertex is to be added. So, I tried to lock the buffer. However, I not sure if the call is valid.

Simply put, I was trying to to was lock n-bytes of data at the specified offset. Have I done this correctly?

Wazzak
Last edited on
Topic archived. No new replies allowed.