Added driver support for user clip planes.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@829 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
981d1d61f2
commit
29e890bfc3
|
@ -1,5 +1,11 @@
|
|||
Changes in version 1.4 (... 2007)
|
||||
|
||||
- Added river support for user defined clip planes, based on mandrav's patch.
|
||||
|
||||
- .obj files now load relative indices correctly. Collada files load textures.
|
||||
|
||||
- In some cases fullscreeen modes under win32 should have a better frame rate now.
|
||||
|
||||
- Fixed the hillplane mesh to work with non-quadratic dimensions as well. Changed the interface also, so use a u32 dimension to specify the tilecount now.
|
||||
|
||||
- Hires timers are disabled on windows systems with more than one CPU, due to bugs
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "ITexture.h"
|
||||
#include "irrArray.h"
|
||||
#include "matrix4.h"
|
||||
#include "plane3d.h"
|
||||
#include "dimension2d.h"
|
||||
#include "position2d.h"
|
||||
#include "SMaterial.h"
|
||||
|
@ -769,6 +770,21 @@ namespace video
|
|||
|
||||
//! looks if the image is already loaded
|
||||
virtual video::ITexture* findTexture(const c8* filename) = 0;
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
//! \return Returns true if the clipping plane is usable.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) = 0;
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual void enableClipPlane(u32 index, bool enable) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace video
|
||||
|
|
|
@ -31,7 +31,7 @@ CD3D8Driver::CD3D8Driver(const core::dimension2d<s32>& screenSize, HWND window,
|
|||
: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE),
|
||||
ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer),
|
||||
D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0),
|
||||
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0),
|
||||
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0),
|
||||
MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
@ -370,6 +370,7 @@ bool CD3D8Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
|
|||
createMaterialRenderers();
|
||||
|
||||
MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES);
|
||||
MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes;
|
||||
|
||||
// set the renderstates
|
||||
setRenderStates3DMode();
|
||||
|
@ -2058,6 +2059,35 @@ core::dimension2d<s32> CD3D8Driver::getCurrentRenderTargetSize()
|
|||
return CurrentRendertargetSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Set/unset a clipping plane.
|
||||
bool CD3D8Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return false;
|
||||
|
||||
pID3DDevice->SetClipPlane(index, (const float*)&plane);
|
||||
enableClipPlane(index, enable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Enable/disable a clipping plane.
|
||||
void CD3D8Driver::enableClipPlane(u32 index, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return;
|
||||
DWORD renderstate;
|
||||
pID3DDevice->GetRenderState(D3DRS_CLIPPLANEENABLE, &renderstate);
|
||||
if (enable)
|
||||
renderstate |= (1 << index);
|
||||
else
|
||||
renderstate &= ~(1 << index);
|
||||
pID3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, renderstate);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
|
|
@ -183,6 +183,19 @@ namespace video
|
|||
//! Returns an image created from the last rendered frame.
|
||||
virtual IImage* createScreenShot();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false);
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual void enableClipPlane(u32 index, bool enable);
|
||||
|
||||
private:
|
||||
|
||||
// enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
|
||||
|
@ -267,6 +280,7 @@ namespace video
|
|||
D3DMATRIX UnitMatrix;
|
||||
|
||||
u32 MaxTextureUnits;
|
||||
u32 MaxUserClipPlanes;
|
||||
f32 MaxLightDistance;
|
||||
s32 LastSetLight;
|
||||
bool DeviceLost;
|
||||
|
|
|
@ -30,7 +30,7 @@ CD3D9Driver::CD3D9Driver(const core::dimension2d<s32>& screenSize, HWND window,
|
|||
: CNullDriver(io, screenSize), CurrentRenderMode(ERM_NONE),
|
||||
ResetRenderStates(true), Transformation3DChanged(false), StencilBuffer(stencilbuffer),
|
||||
D3DLibrary(0), pID3D(0), pID3DDevice(0), PrevRenderTarget(0),
|
||||
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0),
|
||||
LastVertexType((video::E_VERTEX_TYPE)-1), MaxTextureUnits(0), MaxUserClipPlanes(0),
|
||||
MaxLightDistance(sqrtf(FLT_MAX)), LastSetLight(-1), DeviceLost(false),
|
||||
Fullscreen(fullscreen)
|
||||
{
|
||||
|
@ -415,6 +415,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
|
|||
createMaterialRenderers();
|
||||
|
||||
MaxTextureUnits = core::min_((u32)Caps.MaxSimultaneousTextures, MATERIAL_MAX_TEXTURES);
|
||||
MaxUserClipPlanes = (u32)Caps.MaxUserClipPlanes;
|
||||
|
||||
// set the renderstates
|
||||
setRenderStates3DMode();
|
||||
|
@ -2154,6 +2155,33 @@ core::dimension2d<s32> CD3D9Driver::getCurrentRenderTargetSize()
|
|||
|
||||
|
||||
|
||||
// Set/unset a clipping plane.
|
||||
bool CD3D9Driver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return false;
|
||||
|
||||
pID3DDevice->SetClipPlane(index, (const float*)&plane);
|
||||
enableClipPlane(index, enable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Enable/disable a clipping plane.
|
||||
void CD3D9Driver::enableClipPlane(u32 index, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return;
|
||||
DWORD renderstate;
|
||||
pID3DDevice->GetRenderState(D3DRS_CLIPPLANEENABLE, &renderstate);
|
||||
if (enable)
|
||||
renderstate |= (1 << index);
|
||||
else
|
||||
renderstate &= ~(1 << index);
|
||||
pID3DDevice->SetRenderState(D3DRS_CLIPPLANEENABLE, renderstate);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace video
|
||||
} // end namespace irr
|
||||
|
||||
|
|
|
@ -177,6 +177,19 @@ namespace video
|
|||
//! Returns an image created from the last rendered frame.
|
||||
virtual IImage* createScreenShot();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false);
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual void enableClipPlane(u32 index, bool enable);
|
||||
|
||||
private:
|
||||
|
||||
// enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
|
||||
|
@ -273,6 +286,7 @@ namespace video
|
|||
E_VERTEX_TYPE LastVertexType;
|
||||
|
||||
u32 MaxTextureUnits;
|
||||
u32 MaxUserClipPlanes;
|
||||
f32 MaxLightDistance;
|
||||
s32 LastSetLight;
|
||||
bool DeviceLost;
|
||||
|
|
|
@ -1693,6 +1693,26 @@ IVideoDriver* createNullDriver(io::IFileSystem* io, const core::dimension2d<s32>
|
|||
}
|
||||
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
bool CNullDriver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
void CNullDriver::enableClipPlane(u32 index, bool enable)
|
||||
{
|
||||
// not necessary
|
||||
}
|
||||
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
|
|
|
@ -401,6 +401,19 @@ namespace video
|
|||
//! looks if the image is already loaded
|
||||
virtual video::ITexture* findTexture(const c8* filename);
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false);
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual void enableClipPlane(u32 index, bool enable);
|
||||
|
||||
protected:
|
||||
|
||||
//! deletes all textures
|
||||
|
|
|
@ -2302,6 +2302,43 @@ IImage* COpenGLDriver::createScreenShot()
|
|||
}
|
||||
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
bool COpenGLDriver::setClipPlane(u32 index, const core::plane3df& plane, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return false;
|
||||
|
||||
// opengl needs an array of doubles for the plane equation
|
||||
double clip_plane[4];
|
||||
clip_plane[0] = plane.Normal.X;
|
||||
clip_plane[1] = plane.Normal.Y;
|
||||
clip_plane[2] = plane.Normal.Z;
|
||||
clip_plane[3] = plane.D;
|
||||
glClipPlane(GL_CLIP_PLANE0 + index, clip_plane);
|
||||
enableClipPlane(index, enable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
void COpenGLDriver::enableClipPlane(u32 index, bool enable)
|
||||
{
|
||||
if (index >= MaxUserClipPlanes)
|
||||
return;
|
||||
if (enable)
|
||||
glEnable(GL_CLIP_PLANE0 + index);
|
||||
else
|
||||
glDisable(GL_CLIP_PLANE0 + index);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
|
|
|
@ -283,6 +283,19 @@ namespace video
|
|||
//! for performance reasons only available in debug mode
|
||||
bool testGLError();
|
||||
|
||||
//! Set/unset a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param plane: The plane itself.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false);
|
||||
|
||||
//! Enable/disable a clipping plane.
|
||||
//! There are at least 6 clipping planes available for the user to set at will.
|
||||
//! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
|
||||
//! \param enable: If true, enable the clipping plane else disable it.
|
||||
virtual void enableClipPlane(u32 index, bool enable);
|
||||
|
||||
private:
|
||||
|
||||
//! inits the parts of the open gl driver used on all platforms
|
||||
|
|
|
@ -19,7 +19,8 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
|
|||
TextureCompressionExtension(false),
|
||||
PackedDepthStencilExtension(false),
|
||||
MaxTextureUnits(1), MaxLights(1), MaxIndices(65535),
|
||||
MaxAnisotropy(1.0f), Version(0), ShaderLanguageVersion(0)
|
||||
MaxAnisotropy(1.0f), MaxUserClipPlanes(0),
|
||||
Version(0), ShaderLanguageVersion(0)
|
||||
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
|
||||
,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0),
|
||||
pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0),
|
||||
|
@ -366,6 +367,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
|
|||
if (Version>101)
|
||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &MaxIndices);
|
||||
#endif
|
||||
glGetIntegerv(GL_MAX_CLIP_PLANES, reinterpret_cast<GLint*>(&MaxUserClipPlanes));
|
||||
#if defined(GL_ARB_shading_language_100) || defined (GL_VERSION_2_0)
|
||||
if (FeatureAvailable[IRR_ARB_shading_language_100] || Version>=200)
|
||||
{
|
||||
|
|
|
@ -677,6 +677,9 @@ class COpenGLExtensionHandler
|
|||
GLint MaxIndices;
|
||||
//! Maximal Anisotropy
|
||||
f32 MaxAnisotropy;
|
||||
//! Number of user clipplanes
|
||||
u32 MaxUserClipPlanes;
|
||||
|
||||
//! OpenGL version as Integer: 100*Major+Minor, i.e. 2.1 becomes 201
|
||||
u32 Version;
|
||||
//! GLSL version as Integer: 100*Major+Minor
|
||||
|
|
Loading…
Reference in New Issue