TDME2
1.9.121
src
tdme
engine
subsystems
rendering
BatchRendererTriangles.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <array>
4
#include <vector>
5
6
#include <
tdme/tdme.h
>
7
#include <
tdme/engine/model/fwd-tdme.h
>
8
#include <
tdme/engine/model/Color4.h
>
9
#include <
tdme/engine/model/TextureCoordinate.h
>
10
#include <
tdme/engine/subsystems/renderer/fwd-tdme.h
>
11
#include <
tdme/engine/subsystems/renderer/Renderer.h
>
12
#include <
tdme/engine/subsystems/rendering/fwd-tdme.h
>
13
#include <
tdme/math/fwd-tdme.h
>
14
#include <
tdme/math/Matrix4x4.h
>
15
#include <
tdme/math/Vector2.h
>
16
#include <
tdme/math/Vector3.h
>
17
#include <
tdme/utilities/fwd-tdme.h
>
18
#include <
tdme/utilities/FloatBuffer.h
>
19
20
using
std::array;
21
using
std::vector;
22
23
using
tdme::engine::model::Color4
;
24
using
tdme::engine::model::TextureCoordinate
;
25
using
tdme::engine::subsystems::renderer::Renderer
;
26
using
tdme::math::Matrix4x4
;
27
using
tdme::math::Vector2
;
28
using
tdme::math::Vector3
;
29
using
tdme::utilities::ByteBuffer
;
30
using
tdme::utilities::FloatBuffer
;
31
32
/**
33
* Batch renderer for transparent triangles
34
* @author andreas.drewke
35
* @version $Id$
36
*/
37
class
tdme::engine::subsystems::rendering::BatchRendererTriangles
final
38
{
39
friend
class
TransparentRenderFacesGroup
;
40
41
private
:
42
static
constexpr
int32_t
TRIANGLE_COUNT
{ 1024 };
43
static
constexpr
int32_t
VERTEX_COUNT
{
TRIANGLE_COUNT
* 3 };
44
Renderer
*
renderer
{
nullptr
};
45
vector<int32_t>*
vboIds
{
nullptr
};
46
int32_t
id
;
47
bool
acquired
;
48
int32_t
vertices
;
49
ByteBuffer
*
fbModelMatricesByteBuffer
{
nullptr
};
50
FloatBuffer
fbModelMatrices
;
51
ByteBuffer
*
fbEffectColorMulsByteBuffer
{
nullptr
};
52
FloatBuffer
fbEffectColorMuls
;
53
ByteBuffer
*
fbEffectColorAddsByteBuffer
{
nullptr
};
54
FloatBuffer
fbEffectColorAdds
;
55
ByteBuffer
*
fbVerticesByteBuffer
{
nullptr
};
56
FloatBuffer
fbVertices
;
57
ByteBuffer
*
fbNormalsByteBuffer
{
nullptr
};
58
FloatBuffer
fbNormals
;
59
ByteBuffer
*
fbTextureCoordinatesByteBuffer
{
nullptr
};
60
FloatBuffer
fbTextureCoordinates
;
61
62
/**
63
* Clears this batch vbo renderer
64
*/
65
void
clear
();
66
67
/**
68
* Render
69
*/
70
void
render
();
71
72
/**
73
* Adds a vertex to this transparent render faces group
74
* @param vertex vertex
75
* @param normal normal
76
* @param textureCoordinate texture coordinate
77
* @return success
78
*/
79
inline
bool
addVertex
(
const
Vector3
& vertex,
const
Vector3
& normal,
const
Vector2
& textureCoordinate) {
80
// check if full
81
if
(
vertices
==
VERTEX_COUNT
)
return
false
;
82
83
// otherwise
84
fbVertices
.
put
(vertex.
getArray
());
85
fbNormals
.
put
(normal.
getArray
());
86
fbTextureCoordinates
.
put
(textureCoordinate.
getArray
());
87
88
//
89
vertices
++;
90
return
true
;
91
}
92
93
public
:
94
/**
95
* Public constructor
96
* @param renderer renderer
97
* @param id id
98
*/
99
BatchRendererTriangles
(
Renderer
*
renderer
, int32_t
id
);
100
101
/**
102
* Destructor
103
*/
104
~BatchRendererTriangles
();
105
106
/**
107
* @return acquired
108
*/
109
bool
isAcquired
();
110
111
/**
112
* Acquire
113
*/
114
bool
acquire
();
115
116
/**
117
* Release
118
*/
119
void
release
();
120
121
/**
122
* Init
123
*/
124
void
initialize
();
125
126
/**
127
* Dispose
128
*/
129
void
dispose
();
130
131
};
Color4.h
FloatBuffer.h
Matrix4x4.h
Renderer.h
TextureCoordinate.h
Vector2.h
Vector3.h
tdme::engine::model::Color4
Color 4 definition.
Definition:
Color4.h:20
tdme::engine::model::TextureCoordinate
Class representing texture UV coordinates data.
Definition:
TextureCoordinate.h:19
tdme::engine::subsystems::renderer::Renderer
Renderer interface.
Definition:
Renderer.h:45
tdme::engine::subsystems::rendering::BatchRendererTriangles
Batch renderer for transparent triangles.
Definition:
BatchRendererTriangles.h:38
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbModelMatricesByteBuffer
ByteBuffer * fbModelMatricesByteBuffer
Definition:
BatchRendererTriangles.h:49
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbEffectColorMulsByteBuffer
ByteBuffer * fbEffectColorMulsByteBuffer
Definition:
BatchRendererTriangles.h:51
tdme::engine::subsystems::rendering::BatchRendererTriangles::~BatchRendererTriangles
~BatchRendererTriangles()
Destructor.
Definition:
BatchRendererTriangles.cpp:49
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbEffectColorAddsByteBuffer
ByteBuffer * fbEffectColorAddsByteBuffer
Definition:
BatchRendererTriangles.h:53
tdme::engine::subsystems::rendering::BatchRendererTriangles::release
void release()
Release.
Definition:
BatchRendererTriangles.cpp:73
tdme::engine::subsystems::rendering::BatchRendererTriangles::initialize
void initialize()
Init.
Definition:
BatchRendererTriangles.cpp:78
tdme::engine::subsystems::rendering::BatchRendererTriangles::id
int32_t id
Definition:
BatchRendererTriangles.h:46
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbVerticesByteBuffer
ByteBuffer * fbVerticesByteBuffer
Definition:
BatchRendererTriangles.h:55
tdme::engine::subsystems::rendering::BatchRendererTriangles::addVertex
bool addVertex(const Vector3 &vertex, const Vector3 &normal, const Vector2 &textureCoordinate)
Adds a vertex to this transparent render faces group.
Definition:
BatchRendererTriangles.h:79
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbEffectColorAdds
FloatBuffer fbEffectColorAdds
Definition:
BatchRendererTriangles.h:54
tdme::engine::subsystems::rendering::BatchRendererTriangles::vertices
int32_t vertices
Definition:
BatchRendererTriangles.h:48
tdme::engine::subsystems::rendering::BatchRendererTriangles::acquired
bool acquired
Definition:
BatchRendererTriangles.h:47
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbNormals
FloatBuffer fbNormals
Definition:
BatchRendererTriangles.h:58
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbVertices
FloatBuffer fbVertices
Definition:
BatchRendererTriangles.h:56
tdme::engine::subsystems::rendering::BatchRendererTriangles::BatchRendererTriangles
BatchRendererTriangles(Renderer *renderer, int32_t id)
Public constructor.
Definition:
BatchRendererTriangles.cpp:32
tdme::engine::subsystems::rendering::BatchRendererTriangles::render
void render()
Render.
Definition:
BatchRendererTriangles.cpp:88
tdme::engine::subsystems::rendering::BatchRendererTriangles::TRIANGLE_COUNT
static constexpr int32_t TRIANGLE_COUNT
Definition:
BatchRendererTriangles.h:42
tdme::engine::subsystems::rendering::BatchRendererTriangles::VERTEX_COUNT
static constexpr int32_t VERTEX_COUNT
Definition:
BatchRendererTriangles.h:43
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbNormalsByteBuffer
ByteBuffer * fbNormalsByteBuffer
Definition:
BatchRendererTriangles.h:57
tdme::engine::subsystems::rendering::BatchRendererTriangles::vboIds
vector< int32_t > * vboIds
Definition:
BatchRendererTriangles.h:45
tdme::engine::subsystems::rendering::BatchRendererTriangles::acquire
bool acquire()
Acquire.
Definition:
BatchRendererTriangles.cpp:64
tdme::engine::subsystems::rendering::BatchRendererTriangles::dispose
void dispose()
Dispose.
Definition:
BatchRendererTriangles.cpp:130
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbTextureCoordinates
FloatBuffer fbTextureCoordinates
Definition:
BatchRendererTriangles.h:60
tdme::engine::subsystems::rendering::BatchRendererTriangles::clear
void clear()
Clears this batch vbo renderer.
Definition:
BatchRendererTriangles.cpp:138
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbTextureCoordinatesByteBuffer
ByteBuffer * fbTextureCoordinatesByteBuffer
Definition:
BatchRendererTriangles.h:59
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbEffectColorMuls
FloatBuffer fbEffectColorMuls
Definition:
BatchRendererTriangles.h:52
tdme::engine::subsystems::rendering::BatchRendererTriangles::fbModelMatrices
FloatBuffer fbModelMatrices
Definition:
BatchRendererTriangles.h:50
tdme::engine::subsystems::rendering::BatchRendererTriangles::renderer
Renderer * renderer
Definition:
BatchRendererTriangles.h:44
tdme::engine::subsystems::rendering::BatchRendererTriangles::isAcquired
bool isAcquired()
Definition:
BatchRendererTriangles.cpp:59
tdme::engine::subsystems::rendering::TransparentRenderFacesGroup
Transparent render faces group.
Definition:
TransparentRenderFacesGroup.h:42
tdme::math::Matrix4x4
4x4 3D Matrix class
Definition:
Matrix4x4.h:24
tdme::math::Vector2
2D vector 2 class
Definition:
Vector2.h:19
tdme::math::Vector2::getArray
array< float, 2 > & getArray() const
Definition:
Vector2.h:330
tdme::math::Vector3
3D vector 3 class
Definition:
Vector3.h:22
tdme::math::Vector3::getArray
array< float, 3 > & getArray() const
Definition:
Vector3.h:171
tdme::utilities::ByteBuffer
Byte buffer class.
Definition:
ByteBuffer.h:24
tdme::utilities::FloatBuffer
Float buffer class.
Definition:
FloatBuffer.h:18
tdme::utilities::FloatBuffer::put
FloatBuffer * put(float value)
Put a float value into float buffer.
Definition:
FloatBuffer.h:52
fwd-tdme.h
fwd-tdme.h
fwd-tdme.h
fwd-tdme.h
tdme.h
fwd-tdme.h
Generated by
1.9.3