KiCad PCB EDA Suite
Loading...
Searching...
No Matches
rhi_vertex.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef RHI_VERTEX_H
21#define RHI_VERTEX_H
22
23#include <rhi/rhi_pipeline.h>
24
25#include <cmath>
26#include <cstdint>
27#include <cstring>
28
29#include <glm/gtc/packing.hpp>
30
31
37{
38 float x = 0.0f;
39 float y = 0.0f;
40 uint8_t r = 255;
41 uint8_t g = 255;
42 uint8_t b = 255;
43 uint8_t a = 255;
44 uint16_t u = 0;
45 uint16_t v = 0;
46
47 void SetPosition( float aX, float aY ) { x = aX; y = aY; }
48 void SetColor( uint8_t aR, uint8_t aG, uint8_t aB, uint8_t aA = 255 )
49 {
50 r = aR; g = aG; b = aB; a = aA;
51 }
52 void SetUV( float aU, float aV ) { u = glm::packHalf1x16( aU ); v = glm::packHalf1x16( aV ); }
53};
54
55static_assert( sizeof( RHI_VERTEX ) == 16, "RHI_VERTEX must be exactly 16 bytes" );
56static_assert( alignof( RHI_VERTEX ) <= 4, "RHI_VERTEX must not require more than 4-byte alignment" );
57
58
74
75
76#endif // RHI_VERTEX_H
RHI_VERTEX_BUFFER_LAYOUT_DESC RhiStandardVertexLayout()
Shaders read position at location 0, color at 1 and texture coordinates at 2.
Definition rhi_vertex.h:62
RHI_VERTEX_STEP_MODE stepMode
std::vector< RHI_VERTEX_ATTRIBUTE_DESC > attributes
Position is in world coordinates, color is premultiplied alpha and u, v hold half floats.
Definition rhi_vertex.h:37
uint16_t u
Definition rhi_vertex.h:44
uint8_t a
Definition rhi_vertex.h:43
void SetPosition(float aX, float aY)
Definition rhi_vertex.h:47
uint16_t v
Definition rhi_vertex.h:45
void SetColor(uint8_t aR, uint8_t aG, uint8_t aB, uint8_t aA=255)
Definition rhi_vertex.h:48
void SetUV(float aU, float aV)
Definition rhi_vertex.h:52
uint8_t b
Definition rhi_vertex.h:42
uint8_t r
Definition rhi_vertex.h:40
uint8_t g
Definition rhi_vertex.h:41