aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp176
1 files changed, 176 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp
new file mode 100644
index 0000000..8658105
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CDepthBuffer.cpp
@@ -0,0 +1,176 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#include "IrrCompileConfig.h"
6#include "SoftwareDriver2_compile_config.h"
7#include "CDepthBuffer.h"
8
9#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
10
11namespace irr
12{
13namespace video
14{
15
16
17//! constructor
18CDepthBuffer::CDepthBuffer(const core::dimension2d<u32>& size)
19: Buffer(0), Size(0,0)
20{
21 #ifdef _DEBUG
22 setDebugName("CDepthBuffer");
23 #endif
24
25 setSize(size);
26}
27
28
29
30//! destructor
31CDepthBuffer::~CDepthBuffer()
32{
33 if (Buffer)
34 delete [] Buffer;
35}
36
37
38
39//! clears the zbuffer
40void CDepthBuffer::clear()
41{
42
43#ifdef SOFTWARE_DRIVER_2_USE_WBUFFER
44 f32 zMax = 0.f;
45#else
46 f32 zMax = 1.f;
47#endif
48
49 u32 zMaxValue;
50 zMaxValue = IR(zMax);
51
52 memset32 ( Buffer, zMaxValue, TotalSize );
53}
54
55
56
57//! sets the new size of the zbuffer
58void CDepthBuffer::setSize(const core::dimension2d<u32>& size)
59{
60 if (size == Size)
61 return;
62
63 Size = size;
64
65 if (Buffer)
66 delete [] Buffer;
67
68 Pitch = size.Width * sizeof ( fp24 );
69 TotalSize = Pitch * size.Height;
70 Buffer = new u8[TotalSize];
71 clear ();
72}
73
74
75
76//! returns the size of the zbuffer
77const core::dimension2d<u32>& CDepthBuffer::getSize() const
78{
79 return Size;
80}
81
82// -----------------------------------------------------------------
83
84//! constructor
85CStencilBuffer::CStencilBuffer(const core::dimension2d<u32>& size)
86: Buffer(0), Size(0,0)
87{
88 #ifdef _DEBUG
89 setDebugName("CDepthBuffer");
90 #endif
91
92 setSize(size);
93}
94
95
96
97//! destructor
98CStencilBuffer::~CStencilBuffer()
99{
100 if (Buffer)
101 delete [] Buffer;
102}
103
104
105
106//! clears the zbuffer
107void CStencilBuffer::clear()
108{
109 memset32 ( Buffer, 0, TotalSize );
110}
111
112
113
114//! sets the new size of the zbuffer
115void CStencilBuffer::setSize(const core::dimension2d<u32>& size)
116{
117 if (size == Size)
118 return;
119
120 Size = size;
121
122 if (Buffer)
123 delete [] Buffer;
124
125 Pitch = size.Width * sizeof ( u32 );
126 TotalSize = Pitch * size.Height;
127 Buffer = new u8[TotalSize];
128 clear ();
129}
130
131
132
133//! returns the size of the zbuffer
134const core::dimension2d<u32>& CStencilBuffer::getSize() const
135{
136 return Size;
137}
138
139
140
141} // end namespace video
142} // end namespace irr
143
144#endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
145
146namespace irr
147{
148namespace video
149{
150
151//! creates a ZBuffer
152IDepthBuffer* createDepthBuffer(const core::dimension2d<u32>& size)
153{
154 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
155 return new CDepthBuffer(size);
156 #else
157 return 0;
158 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
159}
160
161
162//! creates a ZBuffer
163IStencilBuffer* createStencilBuffer(const core::dimension2d<u32>& size)
164{
165 #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
166 return new CStencilBuffer(size);
167 #else
168 return 0;
169 #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_
170}
171
172} // end namespace video
173} // end namespace irr
174
175
176