-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplane.cpp
More file actions
43 lines (34 loc) · 1.53 KB
/
plane.cpp
File metadata and controls
43 lines (34 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "graphics/plane.h"
#include "core/type_traits/objectdefinition.h"
#include "graphics/rendersystem.h"
#include "graphics/vertexbuffer.h"
namespace CodeHero {
Plane::Plane(const std::shared_ptr<EngineContext>& iContext) : Mesh(iContext) {
// clang-format off
float vertices[] = {// Positions // Normals // Texture Coords
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
0.5f, -0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f,
0.5f, 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
0.5f, 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f};
// clang-format on
std::shared_ptr<VertexBuffer> buffer(
iContext->GetSubsystem<RenderSystem>()->CreateVertexBuffer());
buffer->SetData(
vertices, 6,
VertexBuffer::MASK_Position | VertexBuffer::MASK_Normal | VertexBuffer::MASK_TexCoord);
buffer->Unuse();
AddVertexBuffer(buffer);
}
Plane::~Plane() {}
void Plane::RegisterObject(const std::shared_ptr<EngineContext>& iContext) {
CH_REGISTER_OBJECT(Plane);
}
std::shared_ptr<Plane> Plane::Create(const std::shared_ptr<EngineContext>& iContext) {
return std::make_shared<Plane>(iContext);
}
} // namespace CodeHero