KiCad PCB EDA Suite
vertex_common.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 CERN
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
32 #ifndef VERTEX_COMMON_H_
33 #define VERTEX_COMMON_H_
34 
35 #include <gal/opengl/kiglew.h> // Must be included first
36 
37 #include <math/vector2d.h>
38 
39 #include <cstddef>
40 
41 namespace KIGFX
42 {
46 {
57 };
58 
60 struct VERTEX
61 {
62  GLfloat x, y, z; // Coordinates
63  GLubyte r, g, b, a; // Color
64  GLfloat shader[4]; // Shader type & params
65 };
66 
67 static constexpr size_t VERTEX_SIZE = sizeof(VERTEX);
68 static constexpr size_t VERTEX_STRIDE = VERTEX_SIZE / sizeof(GLfloat);
69 
70 static constexpr size_t COORD_OFFSET = offsetof(VERTEX, x);
71 static constexpr size_t COORD_SIZE = sizeof(VERTEX::x) + sizeof(VERTEX::y) + sizeof(VERTEX::z);
72 static constexpr size_t COORD_STRIDE = COORD_SIZE / sizeof(GLfloat);
73 
74 static constexpr size_t COLOR_OFFSET = offsetof(VERTEX, r);
75 static constexpr size_t COLOR_SIZE = sizeof(VERTEX::r) + sizeof(VERTEX::g) + sizeof(VERTEX::b) + sizeof(VERTEX::a);
76 static constexpr size_t COLOR_STRIDE = COLOR_SIZE / sizeof(GLubyte);
77 
78 // Shader attributes
79 static constexpr size_t SHADER_OFFSET = offsetof(VERTEX, shader);
80 static constexpr size_t SHADER_SIZE = sizeof(VERTEX::shader);
81 static constexpr size_t SHADER_STRIDE = SHADER_SIZE / sizeof(GLfloat);
82 
83 static constexpr size_t INDEX_SIZE = sizeof(GLuint);
84 
85 } // namespace KIGFX
86 
87 #endif /* VERTEX_COMMON_H_ */
static constexpr size_t COORD_STRIDE
Definition: vertex_common.h:72
GLfloat shader[4]
Definition: vertex_common.h:64
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:191
static constexpr size_t SHADER_OFFSET
Definition: vertex_common.h:79
static constexpr size_t SHADER_SIZE
Definition: vertex_common.h:80
SHADER_MODE
< Possible types of shaders (keep consistent with the actual shader source in gl_builtin_shaders....
Definition: vertex_common.h:45
static constexpr size_t COLOR_SIZE
Definition: vertex_common.h:75
static constexpr size_t VERTEX_SIZE
Definition: vertex_common.h:67
static constexpr size_t INDEX_SIZE
Definition: vertex_common.h:83
static constexpr size_t COLOR_OFFSET
Definition: vertex_common.h:74
static constexpr size_t SHADER_STRIDE
Definition: vertex_common.h:81
static constexpr size_t COORD_SIZE
Definition: vertex_common.h:71
static constexpr size_t VERTEX_STRIDE
Definition: vertex_common.h:68
static constexpr size_t COORD_OFFSET
Definition: vertex_common.h:70
static constexpr size_t COLOR_STRIDE
Definition: vertex_common.h:76