#ifndef __C_VIDEO_SOFTWARE_H_INCLUDED__
#define __C_VIDEO_SOFTWARE_H_INCLUDED__
#include "ITriangleRenderer.h"
#include "CNullDriver.h"
#include "SViewFrustum.h"
#include "CImage.h"
namespace irr
{
namespace video
{
class CSoftwareDriver : public CNullDriver
{
public:
CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter);
virtual ~CSoftwareDriver();
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const;
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
virtual void setMaterial(const SMaterial& material);
virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
bool clearZBuffer, SColor color);
virtual void setViewPort(const core::rect<s32>& area);
virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
SColor color=SColor(255,0,0,0),
const SExposedVideoData& videoData=SExposedVideoData(),
core::rect<s32>* sourceRect=0);
virtual bool endScene();
virtual void OnResize(const core::dimension2d<u32>& size);
virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const;
void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
const void* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
virtual void draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color = SColor(255,255,255,255));
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
const core::rect<s32>* clip = 0);
virtual void draw2DRectangle(const core::rect<s32>& pos,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
const core::rect<s32>* clip = 0);
virtual void draw2DLine(const core::position2d<s32>& start,
const core::position2d<s32>& end,
SColor color=SColor(255,255,255,255));
virtual void drawPixel(u32 x, u32 y, const SColor & color);
virtual const wchar_t* getName() const;
virtual E_DRIVER_TYPE getDriverType() const;
virtual ECOLOR_FORMAT getColorFormat() const;
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0);
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN);
virtual void clearZBuffer();
virtual IImage* createScreenShot();
virtual u32 getMaximalPrimitiveCount() const;
protected:
void setRenderTarget(video::CImage* image);
bool setActiveTexture(u32 stage, video::ITexture* texture);
void switchToTriangleRenderer(ETriangleRenderer renderer);
void selectRightTriangleRenderer();
void clipTriangle(f32* transformedPos);
void drawVertexPrimitiveList16(const void* vertices, u32 vertexCount,
const u16* indexList, u32 primitiveCount,
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
template<class VERTEXTYPE>
void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices,
s32 vertexCount, const u16* indexList, s32 triangleCount);
video::CImage* BackBuffer;
video::IImagePresenter* Presenter;
void* WindowId;
core::rect<s32>* SceneSourceRect;
core::array<S2DVertex> TransformedPoints;
video::ITexture* RenderTargetTexture;
video::CImage* RenderTargetSurface;
core::position2d<s32> Render2DTranslation;
core::dimension2d<u32> RenderTargetSize;
core::dimension2d<u32> ViewPortSize;
core::matrix4 TransformationMatrix[ETS_COUNT];
ITriangleRenderer* CurrentTriangleRenderer;
ITriangleRenderer* TriangleRenderers[ETR_COUNT];
ETriangleRenderer CurrentRenderer;
IZBuffer* ZBuffer;
video::ITexture* Texture;
SMaterial Material;
};
}
}
#endif