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 <GL/glew.h>
34 
35 #include <cstddef>
36 
37 namespace KIGFX
38 {
41 {
47 };
48 
50 struct VERTEX
51 {
52  GLfloat x, y, z; // Coordinates
53  GLubyte r, g, b, a; // Color
54  GLfloat shader[4]; // Shader type & params
55 };
56 
57 static constexpr size_t VERTEX_SIZE = sizeof(VERTEX);
58 static constexpr size_t VERTEX_STRIDE = VERTEX_SIZE / sizeof(GLfloat);
59 
60 static constexpr size_t COORD_OFFSET = offsetof(VERTEX, x);
61 static constexpr size_t COORD_SIZE = sizeof(VERTEX::x) + sizeof(VERTEX::y) + sizeof(VERTEX::z);
62 static constexpr size_t COORD_STRIDE = COORD_SIZE / sizeof(GLfloat);
63 
64 static constexpr size_t COLOR_OFFSET = offsetof(VERTEX, r);
65 static constexpr size_t COLOR_SIZE = sizeof(VERTEX::r) + sizeof(VERTEX::g) + sizeof(VERTEX::b) + sizeof(VERTEX::a);
66 static constexpr size_t COLOR_STRIDE = COLOR_SIZE / sizeof(GLubyte);
67 
68 // Shader attributes
69 static constexpr size_t SHADER_OFFSET = offsetof(VERTEX, shader);
70 static constexpr size_t SHADER_SIZE = sizeof(VERTEX::shader);
71 static constexpr size_t SHADER_STRIDE = SHADER_SIZE / sizeof(GLfloat);
72 
73 static constexpr size_t INDEX_SIZE = sizeof(GLuint);
74 
75 } // namespace KIGFX
76 
77 #endif /* VERTEX_COMMON_H_ */
static constexpr size_t COORD_STRIDE
Definition: vertex_common.h:62
GLfloat shader[4]
Definition: vertex_common.h:54
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¶m}
Definition: vertex_common.h:50
static constexpr size_t SHADER_OFFSET
Definition: vertex_common.h:69
static constexpr size_t SHADER_SIZE
Definition: vertex_common.h:70
SHADER_MODE
Possible types of shaders
Definition: vertex_common.h:40
static constexpr size_t COLOR_SIZE
Definition: vertex_common.h:65
static constexpr size_t VERTEX_SIZE
Definition: vertex_common.h:57
static constexpr size_t INDEX_SIZE
Definition: vertex_common.h:73
static constexpr size_t COLOR_OFFSET
Definition: vertex_common.h:64
static constexpr size_t SHADER_STRIDE
Definition: vertex_common.h:71
static constexpr size_t COORD_SIZE
Definition: vertex_common.h:61
static constexpr size_t VERTEX_STRIDE
Definition: vertex_common.h:58
static constexpr size_t COORD_OFFSET
Definition: vertex_common.h:60
static constexpr size_t COLOR_STRIDE
Definition: vertex_common.h:66