Vertex.cpp
1// Copyright 2019 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#include "smk/Vertex.hpp"
6
7#include <smk/OpenGL.hpp>
8
9namespace smk {
10
11// static
12void Vertex2D::Bind() {
13 glEnableVertexAttribArray(0);
14 glVertexAttribPointer(0, sizeof(Vertex::space_position) / sizeof(GL_FLOAT),
15 GL_FLOAT, false, sizeof(Vertex),
16 (void*)offsetof(Vertex, space_position)); // NOLINT
17 glEnableVertexAttribArray(1);
18 glVertexAttribPointer(1, sizeof(Vertex::texture_position) / sizeof(GL_FLOAT),
19 GL_FLOAT, false, sizeof(Vertex),
20 (void*)offsetof(Vertex, texture_position)); // NOLINT
21}
22
23// static
24void Vertex3D::Bind() {
25 glVertexAttribPointer(0, sizeof(Vertex3D::space_position) / sizeof(GL_FLOAT),
26 GL_FLOAT, false, sizeof(Vertex3D),
27 (void*)offsetof(Vertex3D, space_position)); // NOLINT
28 glEnableVertexAttribArray(1);
29 glVertexAttribPointer(1, sizeof(Vertex3D::normal) / sizeof(GL_FLOAT),
30 GL_FLOAT, false, sizeof(Vertex3D),
31 (void*)offsetof(Vertex3D, normal)); // NOLINT
32 glEnableVertexAttribArray(2);
33 glVertexAttribPointer(
34 2, sizeof(Vertex3D::texture_position) / sizeof(GL_FLOAT), GL_FLOAT, false,
35 sizeof(Vertex3D), (void*)offsetof(Vertex3D, texture_position)); // NOLINT
36}
37
38} // namespace smk.