MCPcopy Create free account
hub / github.com/Illation/ETEngine / Init

Method Init

Engine/source/EtRendering/PlanetTech/Patch.cpp:18–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18void Patch::Init(int16 const levels)
19{
20 m_Levels = levels;
21
22 I_GraphicsApiContext* const api = Viewport::GetCurrentApiContext();
23
24 //Shader Init
25 //***********
26 m_pPatchShader = core::ResourceManager::Instance()->GetAssetData<ShaderData>(core::HashString("PlanetPatch.glsl"));
27
28 //Buffer Initialisation
29 //*********************
30 //Generate buffers and arrays
31 m_VAO = api->CreateVertexArray();
32 m_VBO = api->CreateBuffer();
33 m_EBO = api->CreateBuffer();
34 m_VBOInstance = api->CreateBuffer();
35 //bind
36 api->BindVertexArray(m_VAO);
37 api->BindBuffer(E_BufferType::Vertex, m_VBO);
38 //input layout
39 //************
40 //geometry
41 api->SetVertexAttributeArrayEnabled(0, true);
42 api->SetVertexAttributeArrayEnabled(1, true);
43 api->DefineVertexAttributePointer(0, 2, E_DataType::Float, false, sizeof(PatchVertex), offsetof(PatchVertex, pos));
44 api->DefineVertexAttributePointer(1, 2, E_DataType::Float, false, sizeof(PatchVertex), offsetof(PatchVertex, morph));
45 //instances
46 //bind
47 api->BindBuffer(E_BufferType::Vertex, m_VBOInstance);
48 api->SetVertexAttributeArrayEnabled(2, true);
49 api->SetVertexAttributeArrayEnabled(3, true);
50 api->SetVertexAttributeArrayEnabled(4, true);
51 api->SetVertexAttributeArrayEnabled(5, true);
52 api->DefineVertexAttribIPointer(2, 1, E_DataType::Int, sizeof(PatchInstance), offsetof(PatchInstance, level));
53 api->DefineVertexAttributePointer(3, 3, E_DataType::Float, false, sizeof(PatchInstance), offsetof(PatchInstance, a));
54 api->DefineVertexAttributePointer(4, 3, E_DataType::Float, false, sizeof(PatchInstance), offsetof(PatchInstance, r));
55 api->DefineVertexAttributePointer(5, 3, E_DataType::Float, false, sizeof(PatchInstance), offsetof(PatchInstance, s));
56 api->DefineVertexAttribDivisor(2, 1);
57 api->DefineVertexAttribDivisor(3, 1);
58 api->DefineVertexAttribDivisor(4, 1);
59 api->DefineVertexAttribDivisor(5, 1);
60 //Indices
61 api->BindBuffer(E_BufferType::Index, m_EBO);
62 //unbind
63 api->BindBuffer(E_BufferType::Vertex, 0);
64 api->BindVertexArray(0);
65
66 GenerateGeometry(m_Levels);
67}
68
69void Patch::GenerateGeometry(int16 levels)
70{

Callers

nothing calls this directly

Calls 9

HashStringClass · 0.85
CreateVertexArrayMethod · 0.80
CreateBufferMethod · 0.80
BindVertexArrayMethod · 0.80
BindBufferMethod · 0.80

Tested by

no test coverage detected