diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CZBuffer.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CZBuffer.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CZBuffer.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CZBuffer.cpp new file mode 100644 index 0000000..23b515b --- /dev/null +++ b/libraries/irrlicht-1.8/source/Irrlicht/CZBuffer.cpp | |||
@@ -0,0 +1,109 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | ||
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 "CZBuffer.h" | ||
7 | #include "irrString.h" | ||
8 | |||
9 | #ifdef _IRR_COMPILE_WITH_SOFTWARE_ | ||
10 | |||
11 | namespace irr | ||
12 | { | ||
13 | namespace video | ||
14 | { | ||
15 | |||
16 | |||
17 | //! constructor | ||
18 | CZBuffer::CZBuffer(const core::dimension2d<u32>& size) | ||
19 | : Buffer(0), BufferEnd(0), Size(0,0), TotalSize(0) | ||
20 | { | ||
21 | #ifdef _DEBUG | ||
22 | setDebugName("CZBuffer"); | ||
23 | #endif | ||
24 | |||
25 | setSize(size); | ||
26 | } | ||
27 | |||
28 | |||
29 | |||
30 | //! destructor | ||
31 | CZBuffer::~CZBuffer() | ||
32 | { | ||
33 | delete [] Buffer; | ||
34 | } | ||
35 | |||
36 | |||
37 | |||
38 | //! clears the zbuffer | ||
39 | void CZBuffer::clear() | ||
40 | { | ||
41 | memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType)); | ||
42 | } | ||
43 | |||
44 | |||
45 | |||
46 | //! sets the new size of the zbuffer | ||
47 | void CZBuffer::setSize(const core::dimension2d<u32>& size) | ||
48 | { | ||
49 | if (size == Size) | ||
50 | return; | ||
51 | |||
52 | Size = size; | ||
53 | |||
54 | delete [] Buffer; | ||
55 | |||
56 | TotalSize = size.Width * size.Height; | ||
57 | Buffer = new TZBufferType[TotalSize]; | ||
58 | BufferEnd = Buffer + TotalSize; | ||
59 | } | ||
60 | |||
61 | |||
62 | |||
63 | //! returns the size of the zbuffer | ||
64 | const core::dimension2d<u32>& CZBuffer::getSize() const | ||
65 | { | ||
66 | return Size; | ||
67 | } | ||
68 | |||
69 | |||
70 | |||
71 | //! locks the zbuffer | ||
72 | TZBufferType* CZBuffer::lock() | ||
73 | { | ||
74 | return Buffer; | ||
75 | } | ||
76 | |||
77 | |||
78 | |||
79 | //! unlocks the zbuffer | ||
80 | void CZBuffer::unlock() | ||
81 | { | ||
82 | } | ||
83 | |||
84 | } // end namespace video | ||
85 | } // end namespace irr | ||
86 | |||
87 | #endif // _IRR_COMPILE_WITH_SOFTWARE_ | ||
88 | |||
89 | namespace irr | ||
90 | { | ||
91 | namespace video | ||
92 | { | ||
93 | |||
94 | //! creates a ZBuffer | ||
95 | IZBuffer* createZBuffer(const core::dimension2d<u32>& size) | ||
96 | { | ||
97 | #ifdef _IRR_COMPILE_WITH_SOFTWARE_ | ||
98 | return new CZBuffer(size); | ||
99 | #else | ||
100 | return 0; | ||
101 | #endif // _IRR_COMPILE_WITH_SOFTWARE_ | ||
102 | } | ||
103 | |||
104 | |||
105 | } // end namespace video | ||
106 | } // end namespace irr | ||
107 | |||
108 | |||
109 | |||