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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef VERTEX_COMMON_H_
31 #define VERTEX_COMMON_H_
32 
33 #include <math/vector2d.h>
34 #include <GL/glew.h>
35 
36 #include <cstddef>
37 
38 namespace KIGFX
39 {
42 {
53 };
54 
56 struct VERTEX
57 {
58  GLfloat x, y, z; // Coordinates
59  GLubyte r, g, b, a; // Color
60  GLfloat shader[4]; // Shader type & params
61 };
62 
63 static constexpr size_t VERTEX_SIZE = sizeof(VERTEX);
64 static constexpr size_t VERTEX_STRIDE = VERTEX_SIZE / sizeof(GLfloat);
65 
66 static constexpr size_t COORD_OFFSET = offsetof(VERTEX, x);
67 static constexpr size_t COORD_SIZE = sizeof(VERTEX::x) + sizeof(VERTEX::y) + sizeof(VERTEX::z);
68 static constexpr size_t COORD_STRIDE = COORD_SIZE / sizeof(GLfloat);
69 
70 static constexpr size_t COLOR_OFFSET = offsetof(VERTEX, r);
71 static constexpr size_t COLOR_SIZE = sizeof(VERTEX::r) + sizeof(VERTEX::g) + sizeof(VERTEX::b) + sizeof(VERTEX::a);
72 static constexpr size_t COLOR_STRIDE = COLOR_SIZE / sizeof(GLubyte);
73 
74 // Shader attributes
75 static constexpr size_t SHADER_OFFSET = offsetof(VERTEX, shader);
76 static constexpr size_t SHADER_SIZE = sizeof(VERTEX::shader);
77 static constexpr size_t SHADER_STRIDE = SHADER_SIZE / sizeof(GLfloat);
78 
79 static constexpr size_t INDEX_SIZE = sizeof(GLuint);
80 
81 } // namespace KIGFX
82 
83 #endif /* VERTEX_COMMON_H_ */
static constexpr size_t COORD_STRIDE
Definition: vertex_common.h:68
GLfloat shader[4]
Definition: vertex_common.h:60
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Data structure for vertices {X,Y,Z,R,G,B,A,shader&param}
Definition: vertex_common.h:56
static constexpr size_t SHADER_OFFSET
Definition: vertex_common.h:75
static constexpr size_t SHADER_SIZE
Definition: vertex_common.h:76
SHADER_MODE
Possible types of shaders (keep consistent with the actual shader source in gl_builtin_shaders.cpp)
Definition: vertex_common.h:41
static constexpr size_t COLOR_SIZE
Definition: vertex_common.h:71
static constexpr size_t VERTEX_SIZE
Definition: vertex_common.h:63
static constexpr size_t INDEX_SIZE
Definition: vertex_common.h:79
static constexpr size_t COLOR_OFFSET
Definition: vertex_common.h:70
static constexpr size_t SHADER_STRIDE
Definition: vertex_common.h:77
static constexpr size_t COORD_SIZE
Definition: vertex_common.h:67
static constexpr size_t VERTEX_STRIDE
Definition: vertex_common.h:64
static constexpr size_t COORD_OFFSET
Definition: vertex_common.h:66
static constexpr size_t COLOR_STRIDE
Definition: vertex_common.h:72