#ifndef __C_VIDEO_2_SOFTWARE_H_INCLUDED__
#define __C_VIDEO_2_SOFTWARE_H_INCLUDED__
#include "SoftwareDriver2_compile_config.h"
#include "IBurningShader.h"
#include "CNullDriver.h"
#include "CImage.h"
#include "os.h"
#include "irrString.h"
#include "SIrrCreationParameters.h"
namespace irr
{
namespace video
{
class CBurningVideoDriver : public CNullDriver
{
public:
CBurningVideoDriver(const irr::SIrrlichtCreationParameters& params, io::IFileSystem* io, video::IImagePresenter* presenter);
virtual ~CBurningVideoDriver();
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;
virtual void deleteAllDynamicLights();
virtual s32 addDynamicLight(const SLight& light);
virtual void turnLightOn(s32 lightIndex, bool turnOn);
virtual u32 getMaximalDynamicLightAmount() const;
virtual void setAmbientLight(const SColorf& color);
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 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 draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color = SColor(255,255,255,255));
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 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;
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
virtual void drawStencilShadow(bool clearStencilBuffer=false,
video::SColor leftUpEdge = video::SColor(0,0,0,0),
video::SColor rightUpEdge = video::SColor(0,0,0,0),
video::SColor leftDownEdge = video::SColor(0,0,0,0),
video::SColor rightDownEdge = video::SColor(0,0,0,0));
virtual core::stringc getVendorInfo();
virtual core::dimension2du getMaxTextureSize() const;
virtual IDepthBuffer * getDepthBuffer () { return DepthBuffer; }
virtual IStencilBuffer * getStencilBuffer () { return StencilBuffer; }
protected:
void setRenderTarget(video::CImage* image);
virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0);
video::CImage* BackBuffer;
video::IImagePresenter* Presenter;
void* WindowId;
core::rect<s32>* SceneSourceRect;
video::ITexture* RenderTargetTexture;
video::IImage* RenderTargetSurface;
core::dimension2d<u32> RenderTargetSize;
void setCurrentShader();
IBurningShader* CurrentShader;
IBurningShader* BurningShader[ETR2_COUNT];
IDepthBuffer* DepthBuffer;
IStencilBuffer* StencilBuffer;
enum E_TRANSFORMATION_STATE_BURNING_VIDEO
{
ETS_VIEW_PROJECTION = ETS_COUNT,
ETS_CURRENT,
ETS_CLIPSCALE,
ETS_VIEW_INVERSE,
ETS_WORLD_INVERSE,
ETS_COUNT_BURNING
};
enum E_TRANSFORMATION_FLAG
{
ETF_IDENTITY = 1,
ETF_TEXGEN_CAMERA_NORMAL = 2,
ETF_TEXGEN_CAMERA_REFLECTION = 4,
};
u32 TransformationFlag[ETS_COUNT_BURNING];
core::matrix4 Transformation[ETS_COUNT_BURNING];
void getCameraPosWorldSpace ();
void getLightPosObjectSpace ();
static const SVSize vSize[];
SVertexCache VertexCache;
void VertexCache_reset (const void* vertices, u32 vertexCount,
const void* indices, u32 indexCount,
E_VERTEX_TYPE vType,scene::E_PRIMITIVE_TYPE pType,
E_INDEX_TYPE iType);
void VertexCache_get ( s4DVertex ** face );
void VertexCache_getbypass ( s4DVertex ** face );
void VertexCache_fill ( const u32 sourceIndex,const u32 destIndex );
s4DVertex * VertexCache_getVertex ( const u32 sourceIndex );
u32 clipToHyperPlane ( s4DVertex * dest, const s4DVertex * source, u32 inCount, const sVec4 &plane );
u32 clipToFrustumTest ( const s4DVertex * v ) const;
u32 clipToFrustum ( s4DVertex *source, s4DVertex * temp, const u32 vIn );
#ifdef SOFTWARE_DRIVER_2_LIGHTING
void lightVertex ( s4DVertex *dest, u32 vertexargb );
virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start,
f32 end, f32 density, bool pixelFog, bool rangeFog);
#endif
SAlignedVertex CurrentOut;
SAlignedVertex Temp;
void ndc_2_dc_and_project ( s4DVertex *dest,s4DVertex *source, u32 vIn ) const;
f32 screenarea ( const s4DVertex *v0 ) const;
void select_polygon_mipmap ( s4DVertex *source, u32 vIn, u32 tex, const core::dimension2du& texSize ) const;
f32 texelarea ( const s4DVertex *v0, int tex ) const;
void ndc_2_dc_and_project2 ( const s4DVertex **v, const u32 size ) const;
f32 screenarea2 ( const s4DVertex **v ) const;
f32 texelarea2 ( const s4DVertex **v, int tex ) const;
void select_polygon_mipmap2 ( s4DVertex **source, u32 tex, const core::dimension2du& texSize ) const;
SBurningShaderLightSpace LightSpace;
SBurningShaderMaterial Material;
static const sVec4 NDCPlane[6];
};
}
}
#endif