Archived

This topic is now archived and is closed to further replies.

Teknofreek

CreateVertexBuffer question

Recommended Posts

Let's say I have something like this:
    
struct MyVertex
{
    float x, y, z;
    D3DXCOLOR diffuse;
    float u, v;
}

// Init D3D and all that jazz


nVerts       = 1000;
MyVertex*  pMyModel;
pMyModel   = new MyVertex[ nVerts ];

// Assign something to pMyModel


    
Can I then create my vertex buffer by saying something like this: pD3DDevice->CreateVertexBuffer( sizeof(pMyModel), ... ); All of the books, tutorials, etc seem to define the size of the buffer more like this: pD3DDevice->CreateVertexBuffer( sizeof(MyVertex) * nVerts, ... ); Is that just to spell out what you need to give it, or is there some potential difference in the two? -John [edited by - Teknofreek on August 18, 2002 4:16:18 PM]

Share this post


Link to post
Share on other sites
sizeof(pMyModel) will return 4, so your vertex buffer will be a total of 4 bytes long. you need to do it the other way.

fragmo

Share this post


Link to post
Share on other sites