Gamp v0.0.7-36-g24b1eb6
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
GLArrayHandler.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright Gothel Software e.K.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * This Source Code Form is subject to the terms of the MIT License
8 * If a copy of the MIT was not distributed with this file,
9 * you can obtain one at https://opensource.org/license/mit/.
10 */
11
12#ifndef GAMP_GLARRAYHANDLER_HPP_
13#define GAMP_GLARRAYHANDLER_HPP_
14
15#include <memory>
16
19
20namespace gamp::render::gl::data {
21 template<typename Value_type>
23
24 template<typename Value_type>
25 using GLArrayDataClientRef = std::shared_ptr<GLArrayDataClient<Value_type>>;
26}
27
29 using namespace gamp::render::gl;
30 using namespace gamp::render::gl::data;
31
32 /** @defgroup Gamp_GLImpl Gamp GL Implementation Details
33 * Non public OpenGL implementation specifics, do not use directly.
34 *
35 * @{
36 */
37
38 /**
39 * Handles consistency of buffer data and array state.<br/>
40 * Implementations shall consider buffer types (VBO, ..), interleaved, etc.<br/>
41 * They also need to consider array state types, i.e. fixed function or GLSL.<br/>
42 */
43 template <typename Value_type>
45 protected:
47
48 public:
49 GLArrayHandler() noexcept = default;
50 virtual ~GLArrayHandler() noexcept = default;
51
52 void set(const GLArrayDataClientRef<Value_type>& ad) noexcept { m_ad = ad; }
53
54 /**
55 * if <code>bind</code> is true and the data uses VBO,
56 * the latter will be bound and data written to the GPU if required.
57 * <p>
58 * If <code>bind</code> is false and the data uses VBO,
59 * the latter will be unbound.
60 * </p>
61 *
62 * @param gl current GL object
63 * @param bind true if VBO shall be bound and data written,
64 * otherwise clear VBO binding.
65 * @return true if data uses VBO and action was performed, otherwise false
66 */
67 bool bindBuffer(GL& gl, bool bind);
68
69 /**
70 * Implementation shall enable or disable the array state.
71 * <p>
72 * Before enabling the array state,
73 * implementation shall synchronize the data with the GPU
74 * and associate the data with the array.
75 * </p>
76 *
77 * @param gl current GL object
78 * @param enable true if array shall be enabled, otherwise false.
79 * @param ext extension object allowing passing of an implementation detail
80 */
81 virtual void enableState(GL& gl, bool enable, ShaderState* st) = 0;
82
83 /**
84 * Supporting interleaved arrays, where sub handlers may handle
85 * the array state and the <i>master</i> handler the buffer consistency.
86 *
87 * @param handler the sub handler
88 * @throws UnsupportedOperationException if this array handler does not support interleaved arrays
89 */
90 virtual void addSubHandler(GLSLSubArrayHandler&& handler) = 0;
91
92 virtual void setSubArrayVBOName(GLuint vboName) = 0;
93 };
94 template<typename Value_type>
95 using GLArrayHandlerPtr = std::unique_ptr<GLArrayHandler<Value_type>>;
96
97 /**@}*/
98
99}
100
101#endif /* GAMP_GLARRAYHANDLER_HPP_ */
Client data buffer for non VBO GLArrayData usage of given template-type Value_type.
virtual void addSubHandler(GLSLSubArrayHandler &&handler)=0
Supporting interleaved arrays, where sub handlers may handle the array state and the master handler t...
void set(const GLArrayDataClientRef< Value_type > &ad) noexcept
bool bindBuffer(GL &gl, bool bind)
if bind is true and the data uses VBO, the latter will be bound and data written to the GPU if requir...
virtual void enableState(GL &gl, bool enable, ShaderState *st)=0
Implementation shall enable or disable the array state.
virtual void setSubArrayVBOName(GLuint vboName)=0
GLArrayDataClientRef< Value_type > m_ad
ShaderState allows to sharing data between shader programs, while updating the attribute and uniform ...
std::shared_ptr< GLArrayDataClient< Value_type > > GLArrayDataClientRef
std::unique_ptr< GLArrayHandler< Value_type > > GLArrayHandlerPtr
uint8_t Value_type