MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / StaticMesh

Method StaticMesh

src/StaticMesh.cpp:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30
31
32StaticMesh::StaticMesh() : RenderableComponent() {
33 // Vertex format
34 LLGL::VertexFormat vertexFormat;
35
36 // Append 2D float vector for position attribute
37 vertexFormat.AppendAttribute({ "position", LLGL::Format::RGB32Float });
38
39 // Append 3D unsigned byte vector for color
40 vertexFormat.AppendAttribute({ "color", LLGL::Format::RGB32Float });
41
42 // Update stride in case our vertex structure is not 4-byte aligned
43 vertexFormat.SetStride(sizeof(Vertex));
44
45 // Create vertex buffer
46 LLGL::BufferDescriptor vertexBufferDesc;
47
48 vertexBufferDesc.size = sizeof(vertices); // Size (in bytes) of the vertex buffer
49 vertexBufferDesc.bindFlags = LLGL::BindFlags::VertexBuffer; // Enables the buffer to be bound to a vertex buffer slot
50 vertexBufferDesc.vertexAttribs = vertexFormat.attributes; // Vertex format layout
51
52 vertexBuffer = RenderEngine::GetRenderSystem()->CreateBuffer(vertexBufferDesc, vertices);
53
54 LLGL::BufferDescriptor indexBufferDesc;
55 indexBufferDesc.size = sizeof(indices);
56 indexBufferDesc.bindFlags = LLGL::BindFlags::IndexBuffer;
57 indexBufferDesc.format = LLGL::Format::R32UInt;
58 indexBuffer = RenderEngine::GetRenderSystem()->CreateBuffer(indexBufferDesc, indices);
59
60 RegisterAllAlternateTypes();
61}
62
63RavEngine::StaticMesh::~StaticMesh()
64{

Callers

nothing calls this directly

Calls 3

AppendAttributeMethod · 0.80
SetStrideMethod · 0.80
CreateBufferMethod · 0.45

Tested by

no test coverage detected