MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Particles/Particles.cpp:51–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50public:
51 bool Init()
52 {
53 if (Platform::AtomicRead(&Ready))
54 return false;
55 ScopeLock lock(RenderContext::GPULocker);
56 if (Platform::AtomicRead(&Ready))
57 return false;
58 VB = GPUDevice::Instance->CreateBuffer(TEXT("SpriteParticleRenderer.VB"));
59 IB = GPUDevice::Instance->CreateBuffer(TEXT("SpriteParticleRenderer.IB"));
60 SpriteParticleVertex vertexBuffer[] =
61 {
62 { -0.5f, -0.5f, 0.0f, 0.0f },
63 { +0.5f, -0.5f, 1.0f, 0.0f },
64 { +0.5f, +0.5f, 1.0f, 1.0f },
65 { -0.5f, +0.5f, 0.0f, 1.0f },
66 };
67 uint16 indexBuffer[] = { 0, 1, 2, 0, 2, 3, };
68 auto layout = GPUVertexLayout::Get({
69 { VertexElement::Types::Position, 0, 0, 0, PixelFormat::R32G32_Float },
70 { VertexElement::Types::TexCoord, 0, 0, 0, PixelFormat::R32G32_Float },
71 });
72 bool result = VB->Init(GPUBufferDescription::Vertex(layout, sizeof(SpriteParticleVertex), VertexCount, vertexBuffer)) ||
73 IB->Init(GPUBufferDescription::Index(sizeof(uint16), IndexCount, indexBuffer));
74 Platform::AtomicStore(&Ready, 1);
75 return result;
76 }
77
78 void Dispose()
79 {

Callers

nothing calls this directly

Calls 7

AtomicReadFunction · 0.50
GetFunction · 0.50
VertexClass · 0.50
IndexFunction · 0.50
AtomicStoreFunction · 0.50
CreateBufferMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected