KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
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
41namespace KIGFX
42{
46{
56 SHADER_LINE_F = 10
57};
58
60struct VERTEX
61{
62 GLfloat x, y, z; // Coordinates
63 GLubyte r, g, b, a; // Color
64 GLfloat shader[4]; // Shader type & params
65};
66
67static constexpr size_t VERTEX_SIZE = sizeof(VERTEX);
68static constexpr size_t VERTEX_STRIDE = VERTEX_SIZE / sizeof(GLfloat);
69
70static constexpr size_t COORD_OFFSET = offsetof(VERTEX, x);
71static constexpr size_t COORD_SIZE = sizeof(VERTEX::x) + sizeof(VERTEX::y) + sizeof(VERTEX::z);
72static constexpr size_t COORD_STRIDE = COORD_SIZE / sizeof(GLfloat);
73
74static constexpr size_t COLOR_OFFSET = offsetof(VERTEX, r);
75static constexpr size_t COLOR_SIZE = sizeof(VERTEX::r) + sizeof(VERTEX::g) + sizeof(VERTEX::b) + sizeof(VERTEX::a);
76static constexpr size_t COLOR_STRIDE = COLOR_SIZE / sizeof(GLubyte);
77
78// Shader attributes
79static constexpr size_t SHADER_OFFSET = offsetof(VERTEX, shader);
80static constexpr size_t SHADER_SIZE = sizeof(VERTEX::shader);
81static constexpr size_t SHADER_STRIDE = SHADER_SIZE / sizeof(GLfloat);
82
83static constexpr size_t INDEX_SIZE = sizeof(GLuint);
84
85} // namespace KIGFX
86
87#endif /* VERTEX_COMMON_H_ */
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
static constexpr size_t COLOR_OFFSET
Definition: vertex_common.h:74
static constexpr size_t COORD_OFFSET
Definition: vertex_common.h:70
static constexpr size_t VERTEX_SIZE
Definition: vertex_common.h:67
SHADER_MODE
< Possible types of shaders (keep consistent with the actual shader source in kicad_vert....
Definition: vertex_common.h:46
@ SHADER_NONE
Definition: vertex_common.h:47
@ SHADER_LINE_C
Definition: vertex_common.h:53
@ SHADER_LINE_B
Definition: vertex_common.h:52
@ SHADER_FONT
Definition: vertex_common.h:50
@ SHADER_LINE_F
Definition: vertex_common.h:56
@ SHADER_LINE_E
Definition: vertex_common.h:55
@ SHADER_STROKED_CIRCLE
Definition: vertex_common.h:49
@ SHADER_LINE_A
Definition: vertex_common.h:51
@ SHADER_LINE_D
Definition: vertex_common.h:54
@ SHADER_FILLED_CIRCLE
Definition: vertex_common.h:48
static constexpr size_t SHADER_OFFSET
Definition: vertex_common.h:79
static constexpr size_t COLOR_STRIDE
Definition: vertex_common.h:76
static constexpr size_t SHADER_SIZE
Definition: vertex_common.h:80
static constexpr size_t VERTEX_STRIDE
Definition: vertex_common.h:68
static constexpr size_t COORD_SIZE
Definition: vertex_common.h:71
static constexpr size_t INDEX_SIZE
Definition: vertex_common.h:83
static constexpr size_t SHADER_STRIDE
Definition: vertex_common.h:81
static constexpr size_t COORD_STRIDE
Definition: vertex_common.h:72
static constexpr size_t COLOR_SIZE
Definition: vertex_common.h:75
GLfloat shader[4]
Definition: vertex_common.h:64