Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
VertexFormat.h
1// Copyright 2022 ShenMian
2// License(Apache-2.0)
3
4#pragma once
5
6#include "Format.h"
7#include <initializer_list>
8#include <string_view>
9#include <vector>
10
15{
16public:
17 struct Attribute
18 {
19 Attribute(std::string_view name, Format fmt, uint32_t offset = -1, bool normalized = false)
20 : name(name), format(fmt), offset(offset), normalized(normalized)
21 {
22 }
23
24 Attribute(uint32_t location, std::string_view name, Format fmt, bool normalized = false)
25 : location(location), name(name), format(fmt), normalized(normalized)
26 {
27 }
28
29 uint32_t get_size() const;
30
31 uint32_t location = -1;
32 std::string_view name;
33 Format format;
34 bool normalized = false;
35 uint32_t offset = -1;
36 };
37
38 VertexFormat() = default;
39 VertexFormat(const std::initializer_list<Attribute>& list);
40
41 void add_attribute(Attribute attr);
42
43 const std::vector<Attribute> get_attributes() const;
44
45 void set_stride(uint32_t stride);
46 uint32_t get_stride() const;
47
48private:
49 std::vector<Attribute> attribs_;
50 uint32_t stride_ = 0;
51};
顶点格式布局.
Definition: VertexFormat.h:15
Definition: VertexFormat.h:18