Skip to main content
gamedev.net
🔒 Locked

DirectX help

Started by gameplayprogammer 0 replies 700+ views
Original Post
gameplayprogammer
gameplayprogammer
i am working my way through this directx tutorial http://www.chadvernon.com/blog/tutorials/directx9/terrain-generation-with-a-heightmap/ the guy uses a 32bit index buffer whereas my laptop only supports 16bit the guy explains this in a paragraph in the tutorial... "Note: if all you see is the blue background and no terrain, your video card probably doesn’t support 32-bit index buffers, which is the implementation in this tutorial. If that is the case, you’ll have to create_ a 16-bit index buffer, however, the terrain in this tutorial needs 32-bits, so you’ll have to create_ more than one index buffer." now i am lost, i know how to set the buffer flag to 16bit but do you have to evenly divide the indices into the 16bit buffers, and how do you know how many you need? here is the code... m_ib is a index buffer m_vb is a vertex buffer


// Get number of vertices 
heightStream.seekg( 0, std::ios::end ); 
m_numVertices = heightStream.tellg(); 
heightStream.seekg( 0, std::ios::beg ); 

// Allocate memory and read the data 
m_pHeight = new UCHAR[m_numVertices]; 
heightStream.read( (char *)m_pHeight, m_numVertices ); 
heightStream.close(); 

// Generate vertices 
UINT width = (int)sqrt( (float)m_numVertices ); 
cuCustomVertex::PositionTextured* pVertices = NULL; 
CTriangleStripPlane::GeneratePositionTexturedWithHeight( &pVertices, width, width, m_pHeight ); 
m_vb.CreateBuffer( pDevice, m_numVertices, D3DFVF_XYZ | D3DFVF_TEX1, sizeof( cuCustomVertex::PositionTextured ) ); 
m_vb.SetData( m_numVertices, pVertices, 0 ); 

// Generate indices 
int* pIndices = NULL; 
m_numIndices = CTriangleStripPlane::GenerateIndices( &pIndices, width, width ); 
m_ib.CreateBuffer( pDevice, m_numIndices, D3DFMT_INDEX32 ); 
m_ib.SetData( m_numIndices, pIndices, 0 ); 
m_vb.SetIndexBuffer( &m_ib );


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.