| 292 | |
| 293 | template <typename T> |
| 294 | bool CreateIndexBuffer( T count, Tr2SuballocatedBuffer::Allocation& buffer ) |
| 295 | { |
| 296 | USE_MAIN_THREAD_RENDER_CONTEXT(); |
| 297 | // Re-create the index buffer with the correct type |
| 298 | |
| 299 | std::vector<T> indices( count * 6 ); |
| 300 | T* pInds = indices.data(); |
| 301 | for( T i = 0; i < count; ++i ) |
| 302 | { |
| 303 | pInds[0] = 0 + 4 * i; |
| 304 | pInds[1] = 2 + 4 * i; |
| 305 | pInds[2] = 1 + 4 * i; |
| 306 | pInds[3] = 0 + 4 * i; |
| 307 | pInds[4] = 3 + 4 * i; |
| 308 | pInds[5] = 2 + 4 * i; |
| 309 | pInds += 6; |
| 310 | } |
| 311 | if( buffer.IsValid() ) |
| 312 | { |
| 313 | g_sharedBuffer.Free( buffer ); |
| 314 | } |
| 315 | auto hr = g_sharedBuffer.Allocate( sizeof( T ), count * 6, indices.data(), renderContext, buffer ); |
| 316 | |
| 317 | if( FAILED( hr ) ) |
| 318 | { |
| 319 | CCP_LOGERR( "CreateIndexBuffer failed to create an index buffer for %d quads with HRESULT=0x(%X)", count, hr.GetResult() ); |
| 320 | return false; |
| 321 | } |
| 322 | return true; |
| 323 | } |
| 324 | |
| 325 | } |
| 326 |
no test coverage detected