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