Jump to content
  • Advertisement
Sign in to follow this  

Cleaner and shorter ask for help on rendering 2 VBs.

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I rewrote this topic because it was a big mess. Now I've condensed the bug into the following problem. This code bugs up: http://www.rafb.net/paste/results/5gUIgO31.html
void Renderer::AppendLayers(const vector<LAYERDATA>& layerData)  
    VOID *pData;
    VOID *pData2;       
    m_VLayersToRender.push_back(RENDERLAYER());                     // Append a layer
    m_pDirect3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, BGCOLOUR, 1.0f, 0);  
ERRCON("AppendLayers() - Adding a VB for a moving coloured quad");
    m_VLayersToRender.back().v_PaintingData.back().texturePtr   = NULL;
    m_VLayersToRender.back().v_PaintingData.back().fvf          = D3DFVF_MOVINGCOLOUREDVERTEX;
    m_VLayersToRender.back().v_PaintingData.back().size         = sizeof(MYMOVINGCOLOUREDVERTEX);
    m_pDirect3DDevice->CreateVertexBuffer(layerData[0].v_MovingColVerts.size() * sizeof(MYMOVINGCOLOUREDVERTEX),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_MOVINGCOLOUREDVERTEX,D3DPOOL_DEFAULT, &(m_VLayersToRender.back().v_PaintingData.back().vb),NULL);
    memcpy(pData,&(layerData[0].v_MovingColVerts.front()), sizeof(MYMOVINGCOLOUREDVERTEX) * layerData[0].v_MovingColVerts.size());                  
ERRCON("AppendLayers() - Added a VB for a non-moving coloured quad");
    m_VLayersToRender.back().v_PaintingData.back().texturePtr   = NULL;
    m_VLayersToRender.back().v_PaintingData.back().fvf          = D3DFVF_FIXEDCOLOUREDVERTEX;
    m_VLayersToRender.back().v_PaintingData.back().size         = sizeof(MYFIXEDCOLOUREDVERTEX);
    m_pDirect3DDevice->CreateVertexBuffer(layerData[0].v_FixedColVerts.size() * sizeof(MYFIXEDCOLOUREDVERTEX),D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY,D3DFVF_FIXEDCOLOUREDVERTEX,D3DPOOL_DEFAULT, &(m_VLayersToRender.back().v_PaintingData.back().vb),NULL);

    memcpy(pData2,&(layerData[0].v_FixedColVerts.front()), sizeof(MYFIXEDCOLOUREDVERTEX) * layerData[0].v_FixedColVerts.size());                    
// Render the moving quad
    m_pDirect3DDevice->SetStreamSource(0, m_VLayersToRender[0].v_PaintingData[0].vb, 0, m_VLayersToRender[0].v_PaintingData[0].size);   
    m_pDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0,     2); // 2 triangles for now.
// Render the fixed quad
    m_pDirect3DDevice->SetStreamSource(0, m_VLayersToRender[0].v_PaintingData[1].vb, 0, m_VLayersToRender[0].v_PaintingData[1].size);   
    m_pDirect3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0,     2); // A variable is usually used.
    m_pDirect3DDevice->Present(NULL,NULL,NULL,NULL);                // Lump it all on screen
} // ------------ AppendLayers() end -------------- //

However, if I cut the 3 lines under "// Render the moving quad" and paste them at "// HERE", it displays both quads properly. Compiled as it is above, only the 2nd quad appears as expected.. the first quad is a garbled mess, and the wrong colour. Why? [Edited by - Defend on January 1, 2006 2:01:05 PM]

Share this post

Link to post
Share on other sites
Ah sorry heh, I just thought I'd leave the CreateVertexBuffer() calls like that to kind of keep it neater to the eye.

#Gamedev have suggested that its probably my old VC++ 6.0. I'm installing VC EE 2005 now.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!