Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
DVDGeometryBuffer.h
Go to the documentation of this file.
1/***********************************************************************
2 created: Wed, 8th Feb 2012
3 author: Lukas E Meindl (based on code by Paul D Turner)
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2013 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27#pragma once
28#ifndef DVD_CEGUIDVDGeometryBuffer_h_
29#define DVD_CEGUIDVDGeometryBuffer_h_
30
31#include "CEGUI/GeometryBuffer.h"
32#include "CEGUI/Rect.h"
33#include "CEGUI/Quaternion.h"
34
35#include <glm/mat4x4.hpp>
37
38namespace Divide
39{
40 class Texture;
41 FWD_DECLARE_MANAGED_CLASS(GenericVertexData);
42}
43
44namespace CEGUI
45{
46
47class DVDTexture;
48class CEGUIRenderer;
49class DVDGeometryBuffer final : public GeometryBuffer
50{
51public:
52 struct DVDVertex
53 {
54 float tex[2];
55 float colour[4];
56 float position[3];
57 };
58
59private:
61 struct BatchInfo
62 {
63 Divide::Handle<Divide::Texture> texture{ Divide::INVALID_HANDLE<Divide::Texture> };
64 uint vertexCount{0u};
65 bool clip{false};
66 };
67
72
73public:
75
76 [[nodiscard]] const glm::mat4& getMatrix() const;
77
78 void updateBuffers();
79
80#pragma region GeometryBuffer Interface
81 void draw() const override;
82 void reset() override;
83
84 void setTranslation( const Vector3f& t ) override;
85 void setRotation( const Quaternion& r ) override;
86 void setPivot( const Vector3f& p ) override;
87 void setClippingRegion( const Rectf& region ) override;
88 void appendVertex( const Vertex& vertex ) override;
89 void appendGeometry( const Vertex* vbuff, uint vertex_count ) override;
90 void setActiveTexture( Texture* texture ) override;
91 void setRenderEffect( RenderEffect* effect ) override;
92 void setClippingActive( bool active ) override;
93
94 [[nodiscard]] Texture* getActiveTexture() const override;
95 [[nodiscard]] uint getVertexCount() const override;
96 [[nodiscard]] uint getBatchCount() const override;
97 [[nodiscard]] RenderEffect* getRenderEffect() override;
98 [[nodiscard]] bool isClippingActive() const override;
99#pragma endregion
100
101protected:
105 void updateMatrix() const;
107 void recreateBuffer(Divide::Byte* initialData, size_t intialDataSize);
108
109protected:
119 Rectf _clipRect{0, 0, 0, 0};
121 bool _clippingActive{true};
123 Vector3f _translation{0.f, 0.f, 0.f};
125 Quaternion _rotation{Quaternion::IDENTITY};
127 Vector3f _pivot{0.f, 0.f, 0.f};
129 RenderEffect* _effect{nullptr};
131 uint _bufferSize{0u};
135 Divide::GenericVertexData_ptr _gvd;
137 mutable glm::mat4 _matrix;
139 mutable bool _matrixValid{false};
140};
141
142}
143
144#endif //DVD_CEGUIDVDGeometryBuffer_h_
145
146#include "DVDGeometryBuffer.inl"
#define FWD_DECLARE_MANAGED_CLASS(T)
void draw() const override
BatchList _batches
list of texture batches added to the geometry buffer
Rectf _clipRect
rectangular clip region
bool isClippingActive() const override
void setTranslation(const Vector3f &t) override
Texture * getActiveTexture() const override
Vector3f _pivot
pivot point for rotation
RenderEffect * _effect
RenderEffect that will be used by the GeometryBuffer.
void setPivot(const Vector3f &p) override
Vector3f _translation
translation vector
uint getVertexCount() const override
VertexList _vertices
container where added geometry is stored.
void setRenderEffect(RenderEffect *effect) override
bool _clippingActive
whether clipping will be active for the current batch
uint _bufferSize
Size of the buffer that is currently in use.
DVDTexture * _activeTexture
last texture that was set as active
Divide::vector< DVDVertex > VertexList
type of container used to queue the geometry
void recreateBuffer(Divide::Byte *initialData, size_t intialDataSize)
recreates the Divide specific geometry buffer. Usually called if "initialDataSize" is larger than the...
bool _matrixValid
true when d_matrix is valid and up to date
void updateMatrix() const
update cached matrix
void appendGeometry(const Vertex *vbuff, uint vertex_count) override
CEGUIRenderer * _owner
CEGUIRenderer that owns the GeometryBuffer.
void setClippingActive(bool active) override
void performBatchManagement()
perform batch management operations prior to adding new geometry.
uint getBatchCount() const override
Divide::GenericVertexData_ptr _gvd
Divide specific geometry buffer.
Divide::vector< BatchInfo > BatchList
type of container that tracks BatchInfos.
const glm::mat4 & getMatrix() const
void appendVertex(const Vertex &vertex) override
RenderEffect * getRenderEffect() override
Quaternion _rotation
rotation quaternion
void setActiveTexture(Texture *texture) override
void setClippingRegion(const Rectf &region) override
glm::mat4 _matrix
model matrix cache - we use double because gluUnproject takes double
void setRotation(const Quaternion &r) override
Divide::SamplerDescriptor _sampler
Sampler hash to use if the current batch needs a texture bound.
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::byte Byte
eastl::vector< Type > vector
Definition: Vector.h:42
type to track info for per-texture sub batches of geometry
Divide::Handle< Divide::Texture > texture