Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
CUSTOMVERTEX Vertices2[] = { { -1.0f, -1.0f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color { 1.0f, -1.0f, 1.0f, 0xff00ff00, }, { -1.0f, 1.0f, 1.0f, 0xff00ffff, }, { 1.0f, -1.0f, 1.0f, 0xff00ffff,}, { 2.0f, -1.0f, 1.0f, 0xff00ff00,}, { 2.0f, 1.0f, 1.0f, 0xff00ffff,}, }; // Create the vertex buffer. Here we are allocating enough memory // (from the default pool) to hold all our 3 custom Vertices2. We also // specify the FVF, so the vertex buffer knows what data it contains. if( FAILED( Focus->g_pd3dDevice->CreateVertexBuffer( 6*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX3D, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) { return E_FAIL; } // Now we fill the vertex buffer. To do this, we need to Lock() the VB to // gain access to the Vertices2. This mechanism is required becuase vertex // buffers may be in device memory. VOID* pVertices2; if( FAILED( g_pVB->Lock( 0, sizeof(Vertices2), (void**)&pVertices2, 0 ) ) ) return E_FAIL; memcpy( pVertices2, Vertices2, sizeof(Vertices2) ); g_pVB->Unlock(); Focus->g_pd3dDevice->CreateIndexBuffer(7 * 2,0,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&g_pIB,NULL); unsigned short* pusIndices; g_pIB->Lock(0,0,(void**)(&pusIndices),D3DLOCK_NOSYSLOCK); int aIndex[7] = {0,1,2,2,3,4,5}; for(int iIndex = 0; iIndex < 7; iIndex++) pusIndices[iIndex] = aIndex[iIndex]; g_pIB->Unlock(); |
C-/C++-Quelltext |
|
1 2 3 4 |
Focus->g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) ); Focus->g_pd3dDevice->SetIndices(g_pIB); Focus->g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX3D ); Focus->g_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLESTRIP, 0, 6,0,2 ); |
Zitat
or(int iIndex = 0; iIndex < 7; iIndex++)
pusIndices[iIndex] = aIndex[iIndex];
dafür nimmst erstmal nen memcpy.
C-/C++-Quelltext |
|
1 |
int aIndex[7] = {0,1,2,2,3,4,5}; |
Anonymous
unregistriert
Zitat von »"Nox"«
memcpy ist schneller.
Es kann auch sein das der Vertex im Buffer 2mal auftauchen muss. Die doku gibt dazu leider nicht viel her.
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
for(DWORD dwButton = 0; dwButton < m_dwNumButtons; dwButton++) { if( pfOut[dwButton] >= 0.2f) { if(dwButton == TB_KEY_LSHIFT) continue; return dwButton; } } |
Werbeanzeige