diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h | 360 |
1 files changed, 180 insertions, 180 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h b/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h index 60b14c8..c248c5f 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CSoftwareDriver.h | |||
@@ -1,180 +1,180 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
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 | #ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__ | 5 | #ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__ |
6 | #define __C_VIDEO_SOFTWARE_H_INCLUDED__ | 6 | #define __C_VIDEO_SOFTWARE_H_INCLUDED__ |
7 | 7 | ||
8 | #include "ITriangleRenderer.h" | 8 | #include "ITriangleRenderer.h" |
9 | #include "CNullDriver.h" | 9 | #include "CNullDriver.h" |
10 | #include "SViewFrustum.h" | 10 | #include "SViewFrustum.h" |
11 | #include "CImage.h" | 11 | #include "CImage.h" |
12 | 12 | ||
13 | namespace irr | 13 | namespace irr |
14 | { | 14 | { |
15 | namespace video | 15 | namespace video |
16 | { | 16 | { |
17 | class CSoftwareDriver : public CNullDriver | 17 | class CSoftwareDriver : public CNullDriver |
18 | { | 18 | { |
19 | public: | 19 | public: |
20 | 20 | ||
21 | //! constructor | 21 | //! constructor |
22 | CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); | 22 | CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter); |
23 | 23 | ||
24 | //! destructor | 24 | //! destructor |
25 | virtual ~CSoftwareDriver(); | 25 | virtual ~CSoftwareDriver(); |
26 | 26 | ||
27 | //! queries the features of the driver, returns true if feature is available | 27 | //! queries the features of the driver, returns true if feature is available |
28 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; | 28 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; |
29 | 29 | ||
30 | //! sets transformation | 30 | //! sets transformation |
31 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); | 31 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); |
32 | 32 | ||
33 | //! sets a material | 33 | //! sets a material |
34 | virtual void setMaterial(const SMaterial& material); | 34 | virtual void setMaterial(const SMaterial& material); |
35 | 35 | ||
36 | virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, | 36 | virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, |
37 | bool clearZBuffer, SColor color); | 37 | bool clearZBuffer, SColor color); |
38 | 38 | ||
39 | //! sets a viewport | 39 | //! sets a viewport |
40 | virtual void setViewPort(const core::rect<s32>& area); | 40 | virtual void setViewPort(const core::rect<s32>& area); |
41 | 41 | ||
42 | //! clears the zbuffer | 42 | //! clears the zbuffer |
43 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, | 43 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, |
44 | SColor color=SColor(255,0,0,0), | 44 | SColor color=SColor(255,0,0,0), |
45 | const SExposedVideoData& videoData=SExposedVideoData(), | 45 | const SExposedVideoData& videoData=SExposedVideoData(), |
46 | core::rect<s32>* sourceRect=0); | 46 | core::rect<s32>* sourceRect=0); |
47 | 47 | ||
48 | //! presents the rendered scene on the screen, returns false if failed | 48 | //! presents the rendered scene on the screen, returns false if failed |
49 | virtual bool endScene(); | 49 | virtual bool endScene(); |
50 | 50 | ||
51 | //! Only used by the internal engine. Used to notify the driver that | 51 | //! Only used by the internal engine. Used to notify the driver that |
52 | //! the window was resized. | 52 | //! the window was resized. |
53 | virtual void OnResize(const core::dimension2d<u32>& size); | 53 | virtual void OnResize(const core::dimension2d<u32>& size); |
54 | 54 | ||
55 | //! returns size of the current render target | 55 | //! returns size of the current render target |
56 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; | 56 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; |
57 | 57 | ||
58 | //! draws a vertex primitive list | 58 | //! draws a vertex primitive list |
59 | void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, | 59 | void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, |
60 | const void* indexList, u32 primitiveCount, | 60 | const void* indexList, u32 primitiveCount, |
61 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); | 61 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); |
62 | 62 | ||
63 | //! Draws a 3d line. | 63 | //! Draws a 3d line. |
64 | virtual void draw3DLine(const core::vector3df& start, | 64 | virtual void draw3DLine(const core::vector3df& start, |
65 | const core::vector3df& end, SColor color = SColor(255,255,255,255)); | 65 | const core::vector3df& end, SColor color = SColor(255,255,255,255)); |
66 | 66 | ||
67 | //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. | 67 | //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. |
68 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, | 68 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, |
69 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, | 69 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, |
70 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); | 70 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); |
71 | 71 | ||
72 | //! draw an 2d rectangle | 72 | //! draw an 2d rectangle |
73 | virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, | 73 | virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, |
74 | const core::rect<s32>* clip = 0); | 74 | const core::rect<s32>* clip = 0); |
75 | 75 | ||
76 | //!Draws an 2d rectangle with a gradient. | 76 | //!Draws an 2d rectangle with a gradient. |
77 | virtual void draw2DRectangle(const core::rect<s32>& pos, | 77 | virtual void draw2DRectangle(const core::rect<s32>& pos, |
78 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, | 78 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, |
79 | const core::rect<s32>* clip = 0); | 79 | const core::rect<s32>* clip = 0); |
80 | 80 | ||
81 | //! Draws a 2d line. | 81 | //! Draws a 2d line. |
82 | virtual void draw2DLine(const core::position2d<s32>& start, | 82 | virtual void draw2DLine(const core::position2d<s32>& start, |
83 | const core::position2d<s32>& end, | 83 | const core::position2d<s32>& end, |
84 | SColor color=SColor(255,255,255,255)); | 84 | SColor color=SColor(255,255,255,255)); |
85 | 85 | ||
86 | //! Draws a single pixel | 86 | //! Draws a single pixel |
87 | virtual void drawPixel(u32 x, u32 y, const SColor & color); | 87 | virtual void drawPixel(u32 x, u32 y, const SColor & color); |
88 | 88 | ||
89 | //! \return Returns the name of the video driver. Example: In case of the Direct3D8 | 89 | //! \return Returns the name of the video driver. Example: In case of the Direct3D8 |
90 | //! driver, it would return "Direct3D8.1". | 90 | //! driver, it would return "Direct3D8.1". |
91 | virtual const wchar_t* getName() const; | 91 | virtual const wchar_t* getName() const; |
92 | 92 | ||
93 | //! Returns type of video driver | 93 | //! Returns type of video driver |
94 | virtual E_DRIVER_TYPE getDriverType() const; | 94 | virtual E_DRIVER_TYPE getDriverType() const; |
95 | 95 | ||
96 | //! get color format of the current color buffer | 96 | //! get color format of the current color buffer |
97 | virtual ECOLOR_FORMAT getColorFormat() const; | 97 | virtual ECOLOR_FORMAT getColorFormat() const; |
98 | 98 | ||
99 | //! Returns the transformation set by setTransform | 99 | //! Returns the transformation set by setTransform |
100 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; | 100 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; |
101 | 101 | ||
102 | //! returns a device dependent texture from a software surface (IImage) | 102 | //! returns a device dependent texture from a software surface (IImage) |
103 | //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES | 103 | //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES |
104 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0); | 104 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0); |
105 | 105 | ||
106 | //! Creates a render target texture. | 106 | //! Creates a render target texture. |
107 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, | 107 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, |
108 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); | 108 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); |
109 | 109 | ||
110 | //! Clears the ZBuffer. | 110 | //! Clears the ZBuffer. |
111 | virtual void clearZBuffer(); | 111 | virtual void clearZBuffer(); |
112 | 112 | ||
113 | //! Returns an image created from the last rendered frame. | 113 | //! Returns an image created from the last rendered frame. |
114 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); | 114 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); |
115 | 115 | ||
116 | //! Returns the maximum amount of primitives (mostly vertices) which | 116 | //! Returns the maximum amount of primitives (mostly vertices) which |
117 | //! the device is able to render with one drawIndexedTriangleList | 117 | //! the device is able to render with one drawIndexedTriangleList |
118 | //! call. | 118 | //! call. |
119 | virtual u32 getMaximalPrimitiveCount() const; | 119 | virtual u32 getMaximalPrimitiveCount() const; |
120 | 120 | ||
121 | protected: | 121 | protected: |
122 | 122 | ||
123 | //! sets a render target | 123 | //! sets a render target |
124 | void setRenderTarget(video::CImage* image); | 124 | void setRenderTarget(video::CImage* image); |
125 | 125 | ||
126 | //! sets the current Texture | 126 | //! sets the current Texture |
127 | bool setActiveTexture(u32 stage, video::ITexture* texture); | 127 | bool setActiveTexture(u32 stage, video::ITexture* texture); |
128 | 128 | ||
129 | //! switches to a triangle renderer | 129 | //! switches to a triangle renderer |
130 | void switchToTriangleRenderer(ETriangleRenderer renderer); | 130 | void switchToTriangleRenderer(ETriangleRenderer renderer); |
131 | 131 | ||
132 | //! void selects the right triangle renderer based on the render states. | 132 | //! void selects the right triangle renderer based on the render states. |
133 | void selectRightTriangleRenderer(); | 133 | void selectRightTriangleRenderer(); |
134 | 134 | ||
135 | //! clips a triangle agains the viewing frustum | 135 | //! clips a triangle agains the viewing frustum |
136 | void clipTriangle(f32* transformedPos); | 136 | void clipTriangle(f32* transformedPos); |
137 | 137 | ||
138 | 138 | ||
139 | //! draws a vertex primitive list | 139 | //! draws a vertex primitive list |
140 | void drawVertexPrimitiveList16(const void* vertices, u32 vertexCount, | 140 | void drawVertexPrimitiveList16(const void* vertices, u32 vertexCount, |
141 | const u16* indexList, u32 primitiveCount, | 141 | const u16* indexList, u32 primitiveCount, |
142 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); | 142 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); |
143 | 143 | ||
144 | 144 | ||
145 | template<class VERTEXTYPE> | 145 | template<class VERTEXTYPE> |
146 | void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, | 146 | void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices, |
147 | s32 vertexCount, const u16* indexList, s32 triangleCount); | 147 | s32 vertexCount, const u16* indexList, s32 triangleCount); |
148 | 148 | ||
149 | video::CImage* BackBuffer; | 149 | video::CImage* BackBuffer; |
150 | video::IImagePresenter* Presenter; | 150 | video::IImagePresenter* Presenter; |
151 | void* WindowId; | 151 | void* WindowId; |
152 | core::rect<s32>* SceneSourceRect; | 152 | core::rect<s32>* SceneSourceRect; |
153 | 153 | ||
154 | core::array<S2DVertex> TransformedPoints; | 154 | core::array<S2DVertex> TransformedPoints; |
155 | 155 | ||
156 | video::ITexture* RenderTargetTexture; | 156 | video::ITexture* RenderTargetTexture; |
157 | video::CImage* RenderTargetSurface; | 157 | video::CImage* RenderTargetSurface; |
158 | core::position2d<s32> Render2DTranslation; | 158 | core::position2d<s32> Render2DTranslation; |
159 | core::dimension2d<u32> RenderTargetSize; | 159 | core::dimension2d<u32> RenderTargetSize; |
160 | core::dimension2d<u32> ViewPortSize; | 160 | core::dimension2d<u32> ViewPortSize; |
161 | 161 | ||
162 | core::matrix4 TransformationMatrix[ETS_COUNT]; | 162 | core::matrix4 TransformationMatrix[ETS_COUNT]; |
163 | 163 | ||
164 | ITriangleRenderer* CurrentTriangleRenderer; | 164 | ITriangleRenderer* CurrentTriangleRenderer; |
165 | ITriangleRenderer* TriangleRenderers[ETR_COUNT]; | 165 | ITriangleRenderer* TriangleRenderers[ETR_COUNT]; |
166 | ETriangleRenderer CurrentRenderer; | 166 | ETriangleRenderer CurrentRenderer; |
167 | 167 | ||
168 | IZBuffer* ZBuffer; | 168 | IZBuffer* ZBuffer; |
169 | 169 | ||
170 | video::ITexture* Texture; | 170 | video::ITexture* Texture; |
171 | 171 | ||
172 | SMaterial Material; | 172 | SMaterial Material; |
173 | }; | 173 | }; |
174 | 174 | ||
175 | } // end namespace video | 175 | } // end namespace video |
176 | } // end namespace irr | 176 | } // end namespace irr |
177 | 177 | ||
178 | 178 | ||
179 | #endif | 179 | #endif |
180 | 180 | ||