Creating a vertex buffer within a class

This topic is 3033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Is causing me problems. I've never had it complain when writing it within a .cpp file before like this:

<<<<crappy source references removed to save face>>>>

The compiler complains saying no matching function call. Now I've checked the CreateVertexBuffer function and it appears to be a weird function. It has the word PURE after it. In fact it's defined as a method I believe within a declaration, not like any old function. I do however want a seperate vertex buffer for each model loaded, so I don't know what to do! Can anyone help? Cheers ;o)

[Edited by - adder_noir on August 26, 2010 11:50:15 AM]

Share on other sites
for (i = 0; i < sref->vertices.size(); i++){    newVertices = sref->vertices;}

For every vertex in sref->vertices, you load the entire vector?
Quote:
 The compiler complains saying no matching function call.

Which line? And what's the exact error?

Also, what is v_buffer?

Share on other sites
shouldn't matter where you call it from

what's the exact compiler error?

usually you implement class functions like this

.h
class myClass{   LPDIRECT3DVERTEXBUFFER9 vBuffer;public:   void create();};

.cpp

void myClass::create(){   d3ddev->CreateVertexBuffer(....);}

and what's this supposed to do?
for (i = 0; i < sref->vertices.size(); i++){   newVertices = sref->vertices;}

:)

also Buckeye beat me to it.

Share on other sites
Apologies sir, it was a typo was part way through editing it should read thus:

for (i = 0; i < sref->vertices.size(); i++)        {            newVertices = sref->vertices;        }

v_buffer is a pointer to a vertex buffer of type LPDIRECT3DVERTEXBUFFER9. I'll post the class definition if that's helpful. I'll try and make sure I document it properly too. I want to use your idea buck of one vertex buffer per model:

class instance_soldier{    //////////////////////////////////////////////////////////////    ///DATA MEMBERS    private:    LPDIRECT3DINDEXBUFFER9 v_buffer;    //////////////////////////////////////////////////////////////    public:    std::vector<CUSTOMVERTEX> newVertices; // used to make a copy of the verts    //////////////////////////////////////////////////////////////    ///FUNCTIONS    instance_soldier(void)    {        return;    }    ~instance_soldier(void)    {        v_buffer->Release(); // some doubts exist about using destructor to clear up the buffer        return;    }    virtual void load_buffer(LPDIRECT3DDEVICE9 d3ddev, load_soldier* sref)    {        unsigned int i = 0;        for (i = 0; i < sref->vertices.size(); i++)        {            newVertices = sref->vertices;        }        // create a vertex buffer interface called v_buffer        d3ddev->CreateVertexBuffer(sref->vertices.size() * sizeof(CUSTOMVERTEX),                               0,                               CUSTOMFVF,                               D3DPOOL_MANAGED,                               &v_buffer,                               NULL);        ///////////////////////////////////////////////////////////////////////////        ..... unnecessary information....        return;    }}; // end class

- dd3dev is as shown a LPDIRECT3DDEVICE9
- load_soldier* sref is a pointer to a class which holds the original vertices.

I only want the original vertices made once. All instances of the model will get their own copy. The idea being they are then loaded into one seperate vertex buffer per model. I hope that makes sense I'm more than happy to explain better if needs be.

Please don't feel obliged to respond either, afterall I'm not paying you for this! Although I have signed up to help pay for the forum ;oD

**Edit** I'm about to die of embarassment. I've tried to load a point to an INDEXBUFFER!!!! into a CreateVertexBuffer function call.

Is there any chance we could just maybe say no more about this and pretend it never happened? I'll vote you lads up anyway for helping me out cheers.

It's times like these I realise why my psychiatrist refers to me as being mentally ill. I guess I'm just in denial.

Share on other sites
i was just going to say that, but yeah, never happened :)

Sshhh!! :oD

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633731
• Total Posts
3013582
×