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