neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_vertex_buffer.hpp
Go to the documentation of this file.
1// i_vertex_buffer.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
24
25namespace neogfx
26{
27 class i_rendering_context;
28 class i_shader_program;
29
30 // todo
31 enum class vertex_buffer_type : uint32_t
32 {
33 Invalid = 0x00000000,
34 Vertices = 0x00000001,
35 UV = 0x00000002,
36 Color = 0x00000004,
37 Function0 = 0x00000008,
38 Function1 = 0x00000010,
39 Function2 = 0x00000020,
40 Function3 = 0x00000040,
41 Function4 = 0x00000080,
42 // todo
43 Custom1 = 0x00010000,
44 Custom2 = 0x00020000,
45 Custom3 = 0x00040000,
46 Custom4 = 0x00080000,
47 Persist = 0x10000000,
50 };
51
52 inline std::string const& standard_vertex_attribute_name(vertex_buffer_type aType)
53 {
54 switch (aType)
55 {
57 {
58 static const std::string sName = "VertexPosition";
59 return sName;
60 }
62 {
63 static const std::string sName = "VertexColor";
64 return sName;
65 }
67 {
68 static const std::string sName = "VertexTextureCoord";
69 return sName;
70 }
72 {
73 static const std::string sName = "VertexFunction0";
74 return sName;
75 }
77 {
78 static const std::string sName = "VertexFunction1";
79 return sName;
80 }
82 {
83 static const std::string sName = "VertexFunction2";
84 return sName;
85 }
87 {
88 static const std::string sName = "VertexFunction3";
89 return sName;
90 }
92 {
93 static const std::string sName = "VertexFunction4";
94 return sName;
95 }
96 default:
97 throw std::logic_error("neogfx::standard_vertex_attribute_name");
98 }
99 }
100
102 {
103 return static_cast<vertex_buffer_type>(static_cast<uint32_t>(aLhs) | static_cast<uint32_t>(aRhs));
104 }
105
107 {
108 return static_cast<vertex_buffer_type>(static_cast<uint32_t>(aLhs) & static_cast<uint32_t>(aRhs));
109 }
110
111 // todo
113 {
114 public:
115 struct shader_not_attached : std::logic_error { shader_not_attached() : std::logic_error{ "neogfx::i_vertex_buffer::shader_not_attached" } {} };
116 public:
117 virtual ~i_vertex_buffer() = default;
118 public:
119 virtual i_vertex_provider& vertex_provider() const = 0;
120 virtual vertex_buffer_type buffer_type() const = 0;
121 public:
122 virtual i_shader_program& attached_shader() const = 0;
123 virtual void attach_shader(i_rendering_context& aContext, i_shader_program& aShaderProgram) = 0;
124 virtual void detach_shader() = 0;
125 public:
126 virtual void reclaim(std::size_t aStartIndex, std::size_t aEndIndex) = 0;
127 };
128}
virtual void detach_shader()=0
virtual ~i_vertex_buffer()=default
virtual void reclaim(std::size_t aStartIndex, std::size_t aEndIndex)=0
virtual i_vertex_provider & vertex_provider() const =0
virtual vertex_buffer_type buffer_type() const =0
virtual i_shader_program & attached_shader() const =0
virtual void attach_shader(i_rendering_context &aContext, i_shader_program &aShaderProgram)=0
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:60
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:55
std::string const & standard_vertex_attribute_name(vertex_buffer_type aType)