2019-12-12 17:32:41 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
2021-08-27 17:55:04 +02:00
|
|
|
#ifndef IRR_C_SOFTWARE_DRIVER_H_INCLUDED
|
|
|
|
#define IRR_C_SOFTWARE_DRIVER_H_INCLUDED
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
#include "ITriangleRenderer.h"
|
|
|
|
#include "CNullDriver.h"
|
|
|
|
#include "SViewFrustum.h"
|
|
|
|
#include "CImage.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace video
|
|
|
|
{
|
|
|
|
class CSoftwareDriver : public CNullDriver
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CSoftwareDriver(const core::dimension2d<u32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CSoftwareDriver();
|
|
|
|
|
|
|
|
//! queries the features of the driver, returns true if feature is available
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Create render target.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IRenderTarget* addRenderTarget() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets transformation
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets a material
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setMaterial(const SMaterial& material) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),
|
2021-08-27 14:55:10 +02:00
|
|
|
f32 clearDepth = 1.f, u8 clearStencil = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! sets a viewport
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void setViewPort(const core::rect<s32>& area) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255,0,0,0), f32 clearDepth = 1.f, u8 clearStencil = 0,
|
2021-08-27 14:55:10 +02:00
|
|
|
const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool endScene() IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Only used by the internal engine. Used to notify the driver that
|
|
|
|
//! the window was resized.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void OnResize(const core::dimension2d<u32>& size) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! returns size of the current render target
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! draws a vertex primitive list
|
|
|
|
virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
|
|
|
|
const void* indexList, u32 primitiveCount,
|
2021-08-27 14:55:10 +02:00
|
|
|
E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Draws a 3d line.
|
|
|
|
virtual void draw3DLine(const core::vector3df& start,
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::vector3df& end, SColor color = SColor(255,255,255,255)) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! 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.
|
|
|
|
virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
|
|
|
|
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
|
2021-08-27 14:55:10 +02:00
|
|
|
SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! draw an 2d rectangle
|
|
|
|
virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::rect<s32>* clip = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//!Draws an 2d rectangle with a gradient.
|
|
|
|
virtual void draw2DRectangle(const core::rect<s32>& pos,
|
|
|
|
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
|
2021-08-27 14:55:10 +02:00
|
|
|
const core::rect<s32>* clip = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Draws a 2d line.
|
|
|
|
virtual void draw2DLine(const core::position2d<s32>& start,
|
|
|
|
const core::position2d<s32>& end,
|
2021-08-27 14:55:10 +02:00
|
|
|
SColor color=SColor(255,255,255,255)) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Draws a single pixel
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void drawPixel(u32 x, u32 y, const SColor & color) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! \return Returns the name of the video driver. Example: In case of the Direct3D8
|
|
|
|
//! driver, it would return "Direct3D8.1".
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const wchar_t* getName() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns type of video driver
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual E_DRIVER_TYPE getDriverType() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! get color format of the current color buffer
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ECOLOR_FORMAT getColorFormat() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the transformation set by setTransform
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) IRR_OVERRIDE;
|
|
|
|
virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Creates a render target texture.
|
|
|
|
virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
|
2021-08-27 14:55:10 +02:00
|
|
|
const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns an image created from the last rendered frame.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Returns the maximum amount of primitives (mostly vertices) which
|
|
|
|
//! the device is able to render with one drawIndexedTriangleList
|
|
|
|
//! call.
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual u32 getMaximalPrimitiveCount() const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
//! Check if the driver supports creating textures with the given color format
|
2021-08-27 14:55:10 +02:00
|
|
|
virtual bool queryTextureFormat(ECOLOR_FORMAT format) const IRR_OVERRIDE;
|
2019-12-12 17:32:41 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
//! sets a render target
|
|
|
|
void setRenderTargetImage(video::CImage* image);
|
|
|
|
|
|
|
|
//! sets the current Texture
|
|
|
|
bool setActiveTexture(u32 stage, video::ITexture* texture);
|
|
|
|
|
|
|
|
//! switches to a triangle renderer
|
|
|
|
void switchToTriangleRenderer(ETriangleRenderer renderer);
|
|
|
|
|
|
|
|
//! void selects the right triangle renderer based on the render states.
|
|
|
|
void selectRightTriangleRenderer();
|
|
|
|
|
|
|
|
//! clips a triangle agains the viewing frustum
|
|
|
|
void clipTriangle(f32* transformedPos);
|
|
|
|
|
|
|
|
|
|
|
|
//! draws a vertex primitive list
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace video
|
|
|
|
} // end namespace irr
|
|
|
|
|
|
|
|
#endif
|