Commit 4dc82327 authored by hybrid's avatar hybrid

Added the getColorFormat for some drivers. Added the GLX context in exposed...

Added the getColorFormat for some drivers. Added the GLX context in exposed video data under OpenGL/X11.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1387 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 67da89e3
...@@ -73,6 +73,7 @@ struct SExposedVideoData ...@@ -73,6 +73,7 @@ struct SExposedVideoData
{ {
// XWindow handles // XWindow handles
void* X11Display; void* X11Display;
void* X11Context;
unsigned long X11Window; unsigned long X11Window;
} OpenGLLinux; } OpenGLLinux;
}; };
......
...@@ -49,7 +49,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, ...@@ -49,7 +49,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize,
bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
HWND window, u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) HWND window, u32 bits, bool fullscreen, bool vsync, bool stencilBuffer)
{ {
static PIXELFORMATDESCRIPTOR pfd = { PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number 1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_DRAW_TO_WINDOW | // Format Must Support Window
...@@ -142,6 +142,26 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -142,6 +142,26 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
break; break;
} }
if (HDc)
{
int pf = GetPixelFormat(HDc);
DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.cAlphaBits != 0)
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_A8R8G8B8;
else
ColorFormat = ECF_A1R5G5B5;
}
else
{
if (pfd.cRedBits == 8)
ColorFormat = ECF_R8G8B8;
else
ColorFormat = ECF_R5G6B5;
}
}
genericDriverInit(screenSize, stencilBuffer); genericDriverInit(screenSize, stencilBuffer);
// set vsync // set vsync
...@@ -168,7 +188,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -168,7 +188,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(params.AntiAlias), RenderTargetTexture(0), LastSetLight(-1), AntiAlias(params.AntiAlias), RenderTargetTexture(0), LastSetLight(-1),
CurrentRendertargetSize(0,0), _device(device) CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8), _device(device)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -188,15 +208,14 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -188,15 +208,14 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0) RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
#endif #endif
XWindow = glXGetCurrentDrawable(); ExposedData.OpenGLLinux.X11Context = glXGetCurrentContext();
XDisplay = glXGetCurrentDisplay(); ExposedData.OpenGLLinux.X11Display = glXGetCurrentDisplay();
ExposedData.OpenGLLinux.X11Display = XDisplay; ExposedData.OpenGLLinux.X11Window = glXGetCurrentDrawable();
ExposedData.OpenGLLinux.X11Window = XWindow;
genericDriverInit(params.WindowSize, params.Stencilbuffer); genericDriverInit(params.WindowSize, params.Stencilbuffer);
...@@ -225,7 +244,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, ...@@ -225,7 +244,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
: CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
Transformation3DChanged(true), AntiAlias(params.AntiAlias), Transformation3DChanged(true), AntiAlias(params.AntiAlias),
RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0) RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0), ColorFormat(ECF_R8G8B8)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -423,7 +442,7 @@ bool COpenGLDriver::endScene( void* windowId, core::rect<s32>* sourceRect ) ...@@ -423,7 +442,7 @@ bool COpenGLDriver::endScene( void* windowId, core::rect<s32>* sourceRect )
#ifdef _IRR_USE_WINDOWS_DEVICE_ #ifdef _IRR_USE_WINDOWS_DEVICE_
return SwapBuffers(HDc) == TRUE; return SwapBuffers(HDc) == TRUE;
#elif defined(_IRR_USE_LINUX_DEVICE_) #elif defined(_IRR_USE_LINUX_DEVICE_)
glXSwapBuffers(XDisplay, XWindow); glXSwapBuffers((Display*)ExposedData.OpenGLLinux.X11Display, ExposedData.OpenGLLinux.X11Window);
return true; return true;
#elif defined(_IRR_USE_OSX_DEVICE_) #elif defined(_IRR_USE_OSX_DEVICE_)
_device->flush(); _device->flush();
...@@ -2360,7 +2379,6 @@ void COpenGLDriver::OnResize(const core::dimension2d<s32>& size) ...@@ -2360,7 +2379,6 @@ void COpenGLDriver::OnResize(const core::dimension2d<s32>& size)
} }
//! Returns type of video driver //! Returns type of video driver
E_DRIVER_TYPE COpenGLDriver::getDriverType() const E_DRIVER_TYPE COpenGLDriver::getDriverType() const
{ {
...@@ -2368,6 +2386,12 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType() const ...@@ -2368,6 +2386,12 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType() const
} }
//! returns color format
ECOLOR_FORMAT COpenGLDriver::getColorFormat() const
{
return ColorFormat;
}
//! Sets a vertex shader constant. //! Sets a vertex shader constant.
void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
...@@ -2511,8 +2535,6 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff ...@@ -2511,8 +2535,6 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
// check if we should set the previous RT back // check if we should set the previous RT back
bool ret = true;
setTexture(0, 0); setTexture(0, 0);
ResetRenderStates=true; ResetRenderStates=true;
if (RenderTargetTexture!=0) if (RenderTargetTexture!=0)
...@@ -2567,7 +2589,7 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff ...@@ -2567,7 +2589,7 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
glClear(mask); glClear(mask);
return ret; return true;
} }
......
...@@ -245,6 +245,9 @@ namespace video ...@@ -245,6 +245,9 @@ namespace video
//! Returns type of video driver //! Returns type of video driver
virtual E_DRIVER_TYPE getDriverType() const; virtual E_DRIVER_TYPE getDriverType() const;
//! get color format of the current color buffer
virtual ECOLOR_FORMAT getColorFormat() const;
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
...@@ -352,9 +355,6 @@ namespace video ...@@ -352,9 +355,6 @@ namespace video
void createMaterialRenderers(); void createMaterialRenderers();
core::stringw Name; core::stringw Name;
core::matrix4 Matrices[ETS_COUNT]; core::matrix4 Matrices[ETS_COUNT];
core::array<u8> ColorBuffer; core::array<u8> ColorBuffer;
...@@ -386,13 +386,13 @@ namespace video ...@@ -386,13 +386,13 @@ namespace video
core::matrix4 TextureFlipMatrix; core::matrix4 TextureFlipMatrix;
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
HDC HDc; // Private GDI Device Context HDC HDc; // Private GDI Device Context
HWND Window; HWND Window;
HGLRC HRc; // Permanent Rendering Context HGLRC HRc; // Permanent Rendering Context
#elif defined(_IRR_USE_LINUX_DEVICE_)
GLXDrawable XWindow;
Display* XDisplay;
#elif defined(_IRR_USE_OSX_DEVICE_) #elif defined(_IRR_USE_OSX_DEVICE_)
CIrrDeviceMacOSX *_device; CIrrDeviceMacOSX *_device;
#endif #endif
......
...@@ -46,6 +46,7 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const char* name, COpenGLDrive ...@@ -46,6 +46,7 @@ COpenGLTexture::COpenGLTexture(IImage* origImage, const char* name, COpenGLDrive
} }
} }
//! ColorFrameBuffer constructor //! ColorFrameBuffer constructor
COpenGLTexture::COpenGLTexture(const core::dimension2d<s32>& size, COpenGLTexture::COpenGLTexture(const core::dimension2d<s32>& size,
bool extPackedDepthStencilSupported, bool extPackedDepthStencilSupported,
...@@ -247,7 +248,6 @@ void COpenGLTexture::getImageData(IImage* image) ...@@ -247,7 +248,6 @@ void COpenGLTexture::getImageData(IImage* image)
} }
//! copies the the texture into an open gl texture. //! copies the the texture into an open gl texture.
void COpenGLTexture::copyTexture(bool newTexture) void COpenGLTexture::copyTexture(bool newTexture)
{ {
...@@ -335,7 +335,6 @@ void COpenGLTexture::copyTexture(bool newTexture) ...@@ -335,7 +335,6 @@ void COpenGLTexture::copyTexture(bool newTexture)
} }
//! returns the size of a texture which would be the optimal size for rendering it //! returns the size of a texture which would be the optimal size for rendering it
inline s32 COpenGLTexture::getTextureSizeFromSurfaceSize(s32 size) const inline s32 COpenGLTexture::getTextureSizeFromSurfaceSize(s32 size) const
{ {
...@@ -360,7 +359,6 @@ void* COpenGLTexture::lock() ...@@ -360,7 +359,6 @@ void* COpenGLTexture::lock()
} }
//! unlock function //! unlock function
void COpenGLTexture::unlock() void COpenGLTexture::unlock()
{ {
...@@ -373,7 +371,6 @@ void COpenGLTexture::unlock() ...@@ -373,7 +371,6 @@ void COpenGLTexture::unlock()
} }
//! Returns size of the original image. //! Returns size of the original image.
const core::dimension2d<s32>& COpenGLTexture::getOriginalSize() const const core::dimension2d<s32>& COpenGLTexture::getOriginalSize() const
{ {
...@@ -381,7 +378,6 @@ const core::dimension2d<s32>& COpenGLTexture::getOriginalSize() const ...@@ -381,7 +378,6 @@ const core::dimension2d<s32>& COpenGLTexture::getOriginalSize() const
} }
//! Returns of the texture. //! Returns of the texture.
const core::dimension2d<s32>& COpenGLTexture::getSize() const const core::dimension2d<s32>& COpenGLTexture::getSize() const
{ {
...@@ -392,15 +388,13 @@ const core::dimension2d<s32>& COpenGLTexture::getSize() const ...@@ -392,15 +388,13 @@ const core::dimension2d<s32>& COpenGLTexture::getSize() const
} }
//! returns driver type of texture, i.e. the driver, which created the texture
//! returns driver type of texture (=the driver, who created the texture)
E_DRIVER_TYPE COpenGLTexture::getDriverType() const E_DRIVER_TYPE COpenGLTexture::getDriverType() const
{ {
return EDT_OPENGL; return EDT_OPENGL;
} }
//! returns color format of texture //! returns color format of texture
ECOLOR_FORMAT COpenGLTexture::getColorFormat() const ECOLOR_FORMAT COpenGLTexture::getColorFormat() const
{ {
...@@ -411,7 +405,6 @@ ECOLOR_FORMAT COpenGLTexture::getColorFormat() const ...@@ -411,7 +405,6 @@ ECOLOR_FORMAT COpenGLTexture::getColorFormat() const
} }
//! returns pitch of texture (in bytes) //! returns pitch of texture (in bytes)
u32 COpenGLTexture::getPitch() const u32 COpenGLTexture::getPitch() const
{ {
...@@ -422,7 +415,6 @@ u32 COpenGLTexture::getPitch() const ...@@ -422,7 +415,6 @@ u32 COpenGLTexture::getPitch() const
} }
//! return open gl texture name //! return open gl texture name
GLuint COpenGLTexture::getOpenGLTextureName() const GLuint COpenGLTexture::getOpenGLTextureName() const
{ {
...@@ -474,11 +466,13 @@ bool COpenGLTexture::isFrameBufferObject() const ...@@ -474,11 +466,13 @@ bool COpenGLTexture::isFrameBufferObject() const
return ColorFrameBuffer != 0; return ColorFrameBuffer != 0;
} }
bool COpenGLTexture::isRenderTarget() const bool COpenGLTexture::isRenderTarget() const
{ {
return IsRenderTarget; return IsRenderTarget;
} }
void COpenGLTexture::setRenderTarget(bool isTarget) void COpenGLTexture::setRenderTarget(bool isTarget)
{ {
IsRenderTarget = isTarget; IsRenderTarget = isTarget;
...@@ -504,6 +498,7 @@ void COpenGLTexture::unbindFrameBufferObject() ...@@ -504,6 +498,7 @@ void COpenGLTexture::unbindFrameBufferObject()
#endif #endif
} }
#ifdef GL_EXT_framebuffer_object #ifdef GL_EXT_framebuffer_object
bool checkFBOStatus(COpenGLDriver* Driver) bool checkFBOStatus(COpenGLDriver* Driver)
{ {
...@@ -558,6 +553,7 @@ bool checkFBOStatus(COpenGLDriver* Driver) ...@@ -558,6 +553,7 @@ bool checkFBOStatus(COpenGLDriver* Driver)
} }
#endif #endif
} // end namespace video } // end namespace video
} // end namespace irr } // end namespace irr
......
...@@ -20,7 +20,7 @@ namespace video ...@@ -20,7 +20,7 @@ namespace video
//! constructor //! constructor
CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter) CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool fullscreen, io::IFileSystem* io, video::IImagePresenter* presenter)
: CNullDriver(io, windowSize), RenderTargetTexture(0), RenderTargetSurface(0), : CNullDriver(io, windowSize), RenderTargetTexture(0), RenderTargetSurface(0),
CurrentTriangleRenderer(0), ZBuffer(0), Texture(0) CurrentTriangleRenderer(0), ZBuffer(0), Texture(0), Presenter(presenter)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CSoftwareDriver"); setDebugName("CSoftwareDriver");
...@@ -29,15 +29,13 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool ...@@ -29,15 +29,13 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool
// create backbuffer // create backbuffer
BackBuffer = new CImage(ECF_A1R5G5B5, windowSize); BackBuffer = new CImage(ECF_A1R5G5B5, windowSize);
BackBuffer->fill(SColor(0)); if (BackBuffer)
{
// get presenter BackBuffer->fill(SColor(0));
Presenter = presenter;
// create z buffer
ZBuffer = video::createZBuffer(BackBuffer->getDimension()); // create z buffer
ZBuffer = video::createZBuffer(BackBuffer->getDimension());
}
// create triangle renderers // create triangle renderers
...@@ -67,7 +65,8 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool ...@@ -67,7 +65,8 @@ CSoftwareDriver::CSoftwareDriver(const core::dimension2d<s32>& windowSize, bool
CSoftwareDriver::~CSoftwareDriver() CSoftwareDriver::~CSoftwareDriver()
{ {
// delete Backbuffer // delete Backbuffer
BackBuffer->drop(); if (BackBuffer)
BackBuffer->drop();
// delete triangle renderers // delete triangle renderers
...@@ -232,7 +231,7 @@ bool CSoftwareDriver::beginScene(bool backBuffer, bool zBuffer, SColor color) ...@@ -232,7 +231,7 @@ bool CSoftwareDriver::beginScene(bool backBuffer, bool zBuffer, SColor color)
{ {
CNullDriver::beginScene(backBuffer, zBuffer, color); CNullDriver::beginScene(backBuffer, zBuffer, color);
if (backBuffer) if (backBuffer && BackBuffer)
BackBuffer->fill( color ); BackBuffer->fill( color );
if (ZBuffer && zBuffer) if (ZBuffer && zBuffer)
...@@ -753,7 +752,8 @@ void CSoftwareDriver::OnResize(const core::dimension2d<s32>& size) ...@@ -753,7 +752,8 @@ void CSoftwareDriver::OnResize(const core::dimension2d<s32>& size)
bool resetRT = (RenderTargetSurface == BackBuffer); bool resetRT = (RenderTargetSurface == BackBuffer);
BackBuffer->drop(); if (BackBuffer)
BackBuffer->drop();
BackBuffer = new CImage(ECF_A1R5G5B5, realSize); BackBuffer = new CImage(ECF_A1R5G5B5, realSize);
if (resetRT) if (resetRT)
...@@ -853,6 +853,16 @@ E_DRIVER_TYPE CSoftwareDriver::getDriverType() const ...@@ -853,6 +853,16 @@ E_DRIVER_TYPE CSoftwareDriver::getDriverType() const
} }
//! returns color format
ECOLOR_FORMAT CSoftwareDriver::getColorFormat() const
{
if (BackBuffer)
return BackBuffer->getColorFormat();
else
return CNullDriver::getColorFormat();
}
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) const const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state) const
{ {
...@@ -880,7 +890,10 @@ void CSoftwareDriver::clearZBuffer() ...@@ -880,7 +890,10 @@ void CSoftwareDriver::clearZBuffer()
//! Returns an image created from the last rendered frame. //! Returns an image created from the last rendered frame.
IImage* CSoftwareDriver::createScreenShot() IImage* CSoftwareDriver::createScreenShot()
{ {
return new CImage(BackBuffer->getColorFormat(), BackBuffer); if (BackBuffer)
return new CImage(BackBuffer->getColorFormat(), BackBuffer);
else
return 0;
} }
......
...@@ -87,6 +87,9 @@ namespace video ...@@ -87,6 +87,9 @@ namespace video
//! Returns type of video driver //! Returns type of video driver
virtual E_DRIVER_TYPE getDriverType() const; virtual E_DRIVER_TYPE getDriverType() const;
//! get color format of the current color buffer
virtual ECOLOR_FORMAT getColorFormat() const;
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
......
...@@ -36,11 +36,13 @@ CBurningVideoDriver::CBurningVideoDriver(const core::dimension2d<s32>& windowSiz ...@@ -36,11 +36,13 @@ CBurningVideoDriver::CBurningVideoDriver(const core::dimension2d<s32>& windowSiz
// create backbuffer // create backbuffer
BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, windowSize); BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, windowSize);
BackBuffer->fill(SColor(0)); if (BackBuffer)
{
BackBuffer->fill(SColor(0));
// create z buffer // create z buffer
DepthBuffer = video::createDepthBuffer(BackBuffer->getDimension());
DepthBuffer = video::createDepthBuffer(BackBuffer->getDimension()); }
// create triangle renderers // create triangle renderers
...@@ -110,33 +112,28 @@ CBurningVideoDriver::CBurningVideoDriver(const core::dimension2d<s32>& windowSiz ...@@ -110,33 +112,28 @@ CBurningVideoDriver::CBurningVideoDriver(const core::dimension2d<s32>& windowSiz
tmr->drop (); tmr->drop ();
umr->drop (); umr->drop ();
// select render target // select render target
setRenderTarget(BackBuffer); setRenderTarget(BackBuffer);
LightSpace.Global_AmbientLight.set ( 0.f, 0.f, 0.f, 0.f ); LightSpace.Global_AmbientLight.set ( 0.f, 0.f, 0.f, 0.f );
// select the right renderer // select the right renderer
//CurrentShader = BurningShader[ETR_REFERENCE]; //CurrentShader = BurningShader[ETR_REFERENCE];
setCurrentShader(); setCurrentShader();
} }
//! destructor //! destructor
CBurningVideoDriver::~CBurningVideoDriver() CBurningVideoDriver::~CBurningVideoDriver()
{ {
s32 i;
// delete Backbuffer // delete Backbuffer
BackBuffer->drop(); if (BackBuffer)
BackBuffer->drop();
// delete triangle renderers // delete triangle renderers
for (i=0; i<ETR2_COUNT; ++i) for (s32 i=0; i<ETR2_COUNT; ++i)
if (BurningShader[i]) if (BurningShader[i])
BurningShader[i]->drop(); BurningShader[i]->drop();
...@@ -153,7 +150,6 @@ CBurningVideoDriver::~CBurningVideoDriver() ...@@ -153,7 +150,6 @@ CBurningVideoDriver::~CBurningVideoDriver()
} }
//! void selects the right triangle renderer based on the render states. //! void selects the right triangle renderer based on the render states.
void CBurningVideoDriver::setCurrentShader() void CBurningVideoDriver::setCurrentShader()
{ {
...@@ -389,7 +385,7 @@ bool CBurningVideoDriver::beginScene(bool backBuffer, bool zBuffer, SColor color ...@@ -389,7 +385,7 @@ bool CBurningVideoDriver::beginScene(bool backBuffer, bool zBuffer, SColor color
{ {
CNullDriver::beginScene(backBuffer, zBuffer, color); CNullDriver::beginScene(backBuffer, zBuffer, color);
if (backBuffer) if (backBuffer && BackBuffer)
BackBuffer->fill( color ); BackBuffer->fill( color );
if (DepthBuffer && zBuffer) if (DepthBuffer && zBuffer)
...@@ -403,7 +399,7 @@ bool CBurningVideoDriver::endScene( void* windowId, core::rect<s32>* sourceRect ...@@ -403,7 +399,7 @@ bool CBurningVideoDriver::endScene( void* windowId, core::rect<s32>* sourceRect
{ {
CNullDriver::endScene(); CNullDriver::endScene();
Presenter->present(BackBuffer, windowId, sourceRect ); Presenter->present(BackBuffer, windowId, sourceRect);
return true; return true;
} }
...@@ -1556,7 +1552,6 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start, ...@@ -1556,7 +1552,6 @@ void CBurningVideoDriver::draw2DLine(const core::position2d<s32>& start,
} }
//! draw an 2d rectangle //! draw an 2d rectangle
void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos, void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& pos,
const core::rect<s32>* clip) const core::rect<s32>* clip)
...@@ -1581,6 +1576,7 @@ void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& p ...@@ -1581,6 +1576,7 @@ void CBurningVideoDriver::draw2DRectangle(SColor color, const core::rect<s32>& p
} }
} }
//! Only used by the internal engine. Used to notify the driver that //! Only used by the internal engine. Used to notify the driver that
//! the window was resized. //! the window was resized.
void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size) void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size)
...@@ -1606,7 +1602,8 @@ void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size) ...@@ -1606,7 +1602,8 @@ void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size)
bool resetRT = (RenderTargetSurface == BackBuffer); bool resetRT = (RenderTargetSurface == BackBuffer);
BackBuffer->drop(); if (BackBuffer)
BackBuffer->drop();
BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, realSize); BackBuffer = new CImage(BURNINGSHADER_COLOR_FORMAT, realSize);
if (resetRT) if (resetRT)
...@@ -1614,12 +1611,14 @@ void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size) ...@@ -1614,12 +1611,14 @@ void CBurningVideoDriver::OnResize(const core::dimension2d<s32>& size)
} }
} }
//! returns the current render target size //! returns the current render target size
const core::dimension2d<s32>& CBurningVideoDriver::getCurrentRenderTargetSize() const const core::dimension2d<s32>& CBurningVideoDriver::getCurrentRenderTargetSize() const
{ {
return RenderTargetSize; return RenderTargetSize;
} }
//!Draws an 2d rectangle with a gradient. //!Draws an 2d rectangle with a gradient.
void CBurningVideoDriver::draw2DRectangle(const core::rect<s32>& position, void CBurningVideoDriver::draw2DRectangle(const core::rect<s32>& position,
SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
...@@ -1733,7 +1732,6 @@ void CBurningVideoDriver::draw2DRectangle(const core::rect<s32>& position, ...@@ -1733,7 +1732,6 @@ void CBurningVideoDriver::draw2DRectangle(const core::rect<s32>& position,
} }
//! Draws a 3d line. //! Draws a 3d line.
void CBurningVideoDriver::draw3DLine(const core::vector3df& start, void CBurningVideoDriver::draw3DLine(const core::vector3df& start,
const core::vector3df& end, SColor color) const core::vector3df& end, SColor color)
...@@ -1782,7 +1780,6 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start, ...@@ -1782,7 +1780,6 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start,
} }
//! \return Returns the name of the video driver. Example: In case of the DirectX8 //! \return Returns the name of the video driver. Example: In case of the DirectX8
//! driver, it would return "Direct3D8.1". //! driver, it would return "Direct3D8.1".
const wchar_t* CBurningVideoDriver::getName() const const wchar_t* CBurningVideoDriver::getName() const
...@@ -1798,18 +1795,28 @@ const wchar_t* CBurningVideoDriver::getName() const ...@@ -1798,18 +1795,28 @@ const wchar_t* CBurningVideoDriver::getName() const
#endif #endif
} }
//! Returns type of video driver //! Returns type of video driver
E_DRIVER_TYPE CBurningVideoDriver::getDriverType() const E_DRIVER_TYPE CBurningVideoDriver::getDriverType() const
{ {
return EDT_BURNINGSVIDEO; return EDT_BURNINGSVIDEO;
} }
//! returns color format
ECOLOR_FORMAT CBurningVideoDriver::getColorFormat() const
{
return BURNINGSHADER_COLOR_FORMAT;
}
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE state) const const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE state) const
{ {
return Transformation[state].m; return Transformation[state].m;
} }
//! Creates a render target texture. //! Creates a render target texture.
ITexture* CBurningVideoDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name) ITexture* CBurningVideoDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
{ {
...@@ -1832,7 +1839,10 @@ void CBurningVideoDriver::clearZBuffer() ...@@ -1832,7 +1839,10 @@ void CBurningVideoDriver::clearZBuffer()
//! Returns an image created from the last rendered frame. //! Returns an image created from the last rendered frame.
IImage* CBurningVideoDriver::createScreenShot() IImage* CBurningVideoDriver::createScreenShot()
{ {
return new CImage(BackBuffer->getColorFormat(), BackBuffer); if (BackBuffer)
return new CImage(BackBuffer->getColorFormat(), BackBuffer);
else
return 0;
} }
...@@ -1844,6 +1854,7 @@ ITexture* CBurningVideoDriver::createDeviceDependentTexture(IImage* surface, con ...@@ -1844,6 +1854,7 @@ ITexture* CBurningVideoDriver::createDeviceDependentTexture(IImage* surface, con
} }
//! Returns the maximum amount of primitives (mostly vertices) which //! Returns the maximum amount of primitives (mostly vertices) which
//! the device is able to render with one drawIndexedTriangleList //! the device is able to render with one drawIndexedTriangleList
//! call. //! call.
...@@ -1852,8 +1863,9 @@ u32 CBurningVideoDriver::getMaximalPrimitiveCount() const ...@@ -1852,8 +1863,9 @@ u32 CBurningVideoDriver::getMaximalPrimitiveCount() const
return 0x00800000; return 0x00800000;
} }
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow //! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail) void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
{ {
......
...@@ -103,6 +103,9 @@ namespace video ...@@ -103,6 +103,9 @@ namespace video
//! Returns type of video driver //! Returns type of video driver
virtual E_DRIVER_TYPE getDriverType() const; virtual E_DRIVER_TYPE getDriverType() const;
//! get color format of the current color buffer
virtual ECOLOR_FORMAT getColorFormat() const;
//! Returns the transformation set by setTransform //! Returns the transformation set by setTransform
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
...@@ -134,7 +137,6 @@ namespace video ...@@ -134,7 +137,6 @@ namespace video
video::SColor leftDownEdge = video::SColor(0,0,0,0), video::SColor leftDownEdge = video::SColor(0,0,0,0),
video::SColor rightDownEdge = video::SColor(0,0,0,0)); video::SColor rightDownEdge = video::SColor(0,0,0,0));
protected: protected:
//! sets a render target //! sets a render target
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment