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 {
39 // Possible types of shaders
41 {
47 };
48 
49 typedef struct
50 {
51  GLfloat x, y, z; // Coordinates
52  GLubyte r, g, b, a; // Color
53  GLfloat shader[4]; // Shader type & params
54 } VERTEX;
55 
57 const size_t VertexSize = sizeof(VERTEX);
58 const size_t VertexStride = VertexSize / sizeof(GLfloat);
59 
60 const size_t CoordSize = sizeof(VERTEX().x) + sizeof(VERTEX().y) + sizeof(VERTEX().z);
61 const size_t CoordStride = CoordSize / sizeof(GLfloat);
62 
63 // Offset of color data from the beginning of each vertex data
64 const size_t ColorOffset = offsetof(VERTEX, r);
65 const size_t ColorSize = sizeof(VERTEX().r) + sizeof(VERTEX().g) +
66  sizeof(VERTEX().b) + sizeof(VERTEX().a);
67 const size_t ColorStride = ColorSize / sizeof(GLubyte);
68 
69 // Shader attributes
70 const size_t ShaderOffset = offsetof(VERTEX, shader);
71 const size_t ShaderSize = sizeof(VERTEX().shader);
72 const size_t ShaderStride = ShaderSize / sizeof(GLfloat);
73 
74 const size_t IndexSize = sizeof(GLuint);
75 } // namespace KIGFX
76 
77 #endif /* VERTEX_COMMON_H_ */
const size_t VertexSize
Definition: vertex_common.h:57
const size_t ShaderSize
Definition: vertex_common.h:71
const size_t CoordStride
Definition: vertex_common.h:61
GLfloat shader[4]
Definition: vertex_common.h:53
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
const size_t VertexStride
Definition: vertex_common.h:58
const size_t ShaderOffset
Definition: vertex_common.h:70
const size_t ColorSize
Definition: vertex_common.h:65
const size_t CoordSize
Definition: vertex_common.h:60
const size_t ShaderStride
Definition: vertex_common.h:72
const size_t ColorStride
Definition: vertex_common.h:67
const size_t IndexSize
Definition: vertex_common.h:74
const size_t ColorOffset
Definition: vertex_common.h:64