MCPcopy Create free account
hub / github.com/carbonengine/trinity / CreateIndexBuffer

Function CreateIndexBuffer

trinity/Tr2Renderer.cpp:294–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292
293template <typename T>
294bool 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

Callers 1

UpdateSyncronousMethod · 0.85

Calls 4

IsValidMethod · 0.45
FreeMethod · 0.45
AllocateMethod · 0.45
GetResultMethod · 0.45

Tested by

no test coverage detected