Farbige Polygone mit Indexbuffer, Ergebnis: Schwarze Polygone - supa



  • Hallo,
    ich verstehe nicht, wieso mir folgender Code nur schwarze Polygone ausspuckt, funktionieren farbige nur mit DrawPrimitive? Hier mal der Code:

    #define D3DFVF_COLORVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
    
    struct SELVERTEX{
    	float x, y, z;
    	D3DCOLOR dwColor;
    };
    
    WORD* wIndex = new WORD[3];
    SELVERTEX* v = new SELVERTEX[3];
    v[0].x = 0.0f;
    v[0].y = 0.0f;
    v[0].z = 0.0f; 
    v[1].x = 50.0f;
    v[1].y = 100.0f;
    v[1].z = 0.0f; 
    v[2].x = 100.0f;
    v[2].y = 0.0f;
    v[2].z = 0.0f; 
    v[0].dwColor = D3DCOLOR_XRGB(255, 100, 0);
    v[1].dwColor = D3DCOLOR_XRGB(255, 100, 0);
    v[2].dwColor = D3DCOLOR_XRGB(255, 100, 0);
    
    lpD3DDevice->CreateVertexBuffer( 3*sizeof(SELVERTEX),
    			0, D3DFVF_COLORVERTEX,
    			D3DPOOL_DEFAULT, &D3D_VertexBuffer, 0);
    
    D3D_VertexBuffer->Lock( 0, 3*sizeof(SELVERTEX), (void**)&pVertex, 0 );
    
    memcpy( pVertex, v, 3*sizeof(SELVERTEX) );
    D3D_VertexBuffer->Unlock();
    
    lpD3DDevice->CreateIndexBuffer(3*sizeof(WORD), 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &D3D_IndexBuffer, 0);
    
    D3D_IndexBuffer->Lock(0, 3*sizeof(WORD), (void**)&pIndex, 0);
    
    memcpy(pIndex, dwIndicies, 3*sizeof(WORD));
    D3D_IndexBuffer->Unlock();
    
    //RENDERCODE:
    lpD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    lpD3DDevice->SetFVF( D3DFVF_COLORVERTEX );
    lpD3DDevice->SetStreamSource( 0, D3D_VertexBuffer, 0, sizeof(SELVERTEX));
    lpD3DDevice->SetIndices(D3D_IndexBuffer);
    lpD3DDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 3, 0,
    			1);
    

    Wäre nett, wenn jemand weiter wüsste
    Gruß,
    Compiler



  • Am IndexBuffer liegst nicht, soviel kann ich dir verraten ...

    Hast du das Licht ausgemacht?



  • jo hab ich



  • Nachts sind alle Katzen grau. Und Polygone schwarz.

    Bye, TGGC (Just think about it)



  • Mit Licht gehts genau so wenig 🙂



  • Nochmal zur Klarstellung. Du sollst die Lichtberechnung ausschalten, also:

    Device->SetRenderState(D3DRS_LIGHTING, false);
    

    Dann sollten deine Polys eigentlich richtig angezeigt werden.



  • ändert nix


  • Mod

    siehst du schwarze polygone oder siehst du einfach nur nen schwarzen screen?

    ich seh keine stelle an der du matrizen setzt.

    rapso->greets();



  • ich seh die schwarzen polygone


Anmelden zum Antworten