diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp b/libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp index b4856b8..c945a84 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/IBurningShader.cpp | |||
@@ -1,120 +1,120 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt / Thomas Alten |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "IrrCompileConfig.h" | 5 | #include "IrrCompileConfig.h" |
6 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 6 | #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ |
7 | 7 | ||
8 | #include "SoftwareDriver2_compile_config.h" | 8 | #include "SoftwareDriver2_compile_config.h" |
9 | #include "IBurningShader.h" | 9 | #include "IBurningShader.h" |
10 | #include "CSoftwareDriver2.h" | 10 | #include "CSoftwareDriver2.h" |
11 | 11 | ||
12 | namespace irr | 12 | namespace irr |
13 | { | 13 | { |
14 | namespace video | 14 | namespace video |
15 | { | 15 | { |
16 | 16 | ||
17 | const tFixPointu IBurningShader::dithermask[] = | 17 | const tFixPointu IBurningShader::dithermask[] = |
18 | { | 18 | { |
19 | 0x00,0x80,0x20,0xa0, | 19 | 0x00,0x80,0x20,0xa0, |
20 | 0xc0,0x40,0xe0,0x60, | 20 | 0xc0,0x40,0xe0,0x60, |
21 | 0x30,0xb0,0x10,0x90, | 21 | 0x30,0xb0,0x10,0x90, |
22 | 0xf0,0x70,0xd0,0x50 | 22 | 0xf0,0x70,0xd0,0x50 |
23 | }; | 23 | }; |
24 | 24 | ||
25 | IBurningShader::IBurningShader(CBurningVideoDriver* driver) | 25 | IBurningShader::IBurningShader(CBurningVideoDriver* driver) |
26 | { | 26 | { |
27 | #ifdef _DEBUG | 27 | #ifdef _DEBUG |
28 | setDebugName("IBurningShader"); | 28 | setDebugName("IBurningShader"); |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) | 31 | for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) |
32 | { | 32 | { |
33 | IT[i].Texture = 0; | 33 | IT[i].Texture = 0; |
34 | } | 34 | } |
35 | 35 | ||
36 | Driver = driver; | 36 | Driver = driver; |
37 | RenderTarget = 0; | 37 | RenderTarget = 0; |
38 | ColorMask = COLOR_BRIGHT_WHITE; | 38 | ColorMask = COLOR_BRIGHT_WHITE; |
39 | DepthBuffer = (CDepthBuffer*) driver->getDepthBuffer (); | 39 | DepthBuffer = (CDepthBuffer*) driver->getDepthBuffer (); |
40 | if ( DepthBuffer ) | 40 | if ( DepthBuffer ) |
41 | DepthBuffer->grab(); | 41 | DepthBuffer->grab(); |
42 | 42 | ||
43 | Stencil = (CStencilBuffer*) driver->getStencilBuffer (); | 43 | Stencil = (CStencilBuffer*) driver->getStencilBuffer (); |
44 | if ( Stencil ) | 44 | if ( Stencil ) |
45 | Stencil->grab(); | 45 | Stencil->grab(); |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | 49 | ||
50 | //! destructor | 50 | //! destructor |
51 | IBurningShader::~IBurningShader() | 51 | IBurningShader::~IBurningShader() |
52 | { | 52 | { |
53 | if (RenderTarget) | 53 | if (RenderTarget) |
54 | RenderTarget->drop(); | 54 | RenderTarget->drop(); |
55 | 55 | ||
56 | if (DepthBuffer) | 56 | if (DepthBuffer) |
57 | DepthBuffer->drop(); | 57 | DepthBuffer->drop(); |
58 | 58 | ||
59 | if (Stencil) | 59 | if (Stencil) |
60 | Stencil->drop(); | 60 | Stencil->drop(); |
61 | 61 | ||
62 | for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) | 62 | for ( u32 i = 0; i != BURNING_MATERIAL_MAX_TEXTURES; ++i ) |
63 | { | 63 | { |
64 | if ( IT[i].Texture ) | 64 | if ( IT[i].Texture ) |
65 | IT[i].Texture->drop(); | 65 | IT[i].Texture->drop(); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | //! sets a render target | 69 | //! sets a render target |
70 | void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) | 70 | void IBurningShader::setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) |
71 | { | 71 | { |
72 | if (RenderTarget) | 72 | if (RenderTarget) |
73 | RenderTarget->drop(); | 73 | RenderTarget->drop(); |
74 | 74 | ||
75 | RenderTarget = (video::CImage* ) surface; | 75 | RenderTarget = (video::CImage* ) surface; |
76 | 76 | ||
77 | if (RenderTarget) | 77 | if (RenderTarget) |
78 | { | 78 | { |
79 | RenderTarget->grab(); | 79 | RenderTarget->grab(); |
80 | 80 | ||
81 | //(tVideoSample*)RenderTarget->lock() = (tVideoSample*)RenderTarget->lock(); | 81 | //(tVideoSample*)RenderTarget->lock() = (tVideoSample*)RenderTarget->lock(); |
82 | //(fp24*) DepthBuffer->lock() = DepthBuffer->lock(); | 82 | //(fp24*) DepthBuffer->lock() = DepthBuffer->lock(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | //! sets the Texture | 87 | //! sets the Texture |
88 | void IBurningShader::setTextureParam( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel) | 88 | void IBurningShader::setTextureParam( u32 stage, video::CSoftwareTexture2* texture, s32 lodLevel) |
89 | { | 89 | { |
90 | sInternalTexture *it = &IT[stage]; | 90 | sInternalTexture *it = &IT[stage]; |
91 | 91 | ||
92 | if ( it->Texture) | 92 | if ( it->Texture) |
93 | it->Texture->drop(); | 93 | it->Texture->drop(); |
94 | 94 | ||
95 | it->Texture = texture; | 95 | it->Texture = texture; |
96 | 96 | ||
97 | if ( it->Texture) | 97 | if ( it->Texture) |
98 | { | 98 | { |
99 | it->Texture->grab(); | 99 | it->Texture->grab(); |
100 | 100 | ||
101 | // select mignify and magnify ( lodLevel ) | 101 | // select mignify and magnify ( lodLevel ) |
102 | //SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS | 102 | //SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS |
103 | it->lodLevel = lodLevel; | 103 | it->lodLevel = lodLevel; |
104 | it->data = (tVideoSample*) it->Texture->lock(ETLM_READ_ONLY, | 104 | it->data = (tVideoSample*) it->Texture->lock(ETLM_READ_ONLY, |
105 | core::s32_clamp ( lodLevel + SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS, 0, SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1 )); | 105 | core::s32_clamp ( lodLevel + SOFTWARE_DRIVER_2_MIPMAPPING_LOD_BIAS, 0, SOFTWARE_DRIVER_2_MIPMAPPING_MAX - 1 )); |
106 | 106 | ||
107 | // prepare for optimal fixpoint | 107 | // prepare for optimal fixpoint |
108 | it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); | 108 | it->pitchlog2 = s32_log2_s32 ( it->Texture->getPitch() ); |
109 | 109 | ||
110 | const core::dimension2d<u32> &dim = it->Texture->getSize(); | 110 | const core::dimension2d<u32> &dim = it->Texture->getSize(); |
111 | it->textureXMask = s32_to_fixPoint ( dim.Width - 1 ) & FIX_POINT_UNSIGNED_MASK; | 111 | it->textureXMask = s32_to_fixPoint ( dim.Width - 1 ) & FIX_POINT_UNSIGNED_MASK; |
112 | it->textureYMask = s32_to_fixPoint ( dim.Height - 1 ) & FIX_POINT_UNSIGNED_MASK; | 112 | it->textureYMask = s32_to_fixPoint ( dim.Height - 1 ) & FIX_POINT_UNSIGNED_MASK; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | } // end namespace video | 117 | } // end namespace video |
118 | } // end namespace irr | 118 | } // end namespace irr |
119 | 119 | ||
120 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ | 120 | #endif // _IRR_COMPILE_WITH_BURNINGSVIDEO_ |