Commit c26cb454 authored by hybrid's avatar hybrid

Merged from 1.5 branch, revisions 2137:2293. Minor bugfixes, some doc updates.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2295 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e862f147
......@@ -107,8 +107,15 @@ namespace scene
// animate this node with all animators
core::list<ISceneNodeAnimator*>::Iterator ait = Animators.begin();
for (; ait != Animators.end(); ++ait)
(*ait)->animateNode(this, timeMs);
while (ait != Animators.end())
{
// continue to the next node before calling animateNode()
// so that the animator may remove itself from the scene
// node without the iterator becoming invalid
ISceneNodeAnimator* anim = *ait;
++ait;
anim->animateNode(this, timeMs);
}
// update absolute position
updateAbsolutePosition();
......@@ -420,8 +427,11 @@ namespace scene
}
//! Gets the relative scale of the scene node.
/** \return The scale of the scene node. */
//! Gets the scale of the scene node relative to its parent.
/** This is the scale of this node relative to its parent.
If you want the absolute scale, use
getAbsoluteTransformation().getScale()
\return The scale of the scene node. */
virtual const core::vector3df& getScale() const
{
return RelativeScale;
......@@ -429,15 +439,17 @@ namespace scene
//! Sets the relative scale of the scene node.
/** \param scale New scale of the node */
/** \param scale New scale of the node, relative to its parent. */
virtual void setScale(const core::vector3df& scale)
{
RelativeScale = scale;
}
//! Gets the rotation of the node.
//! Gets the rotation of the node relative to its parent.
/** Note that this is the relative rotation of the node.
If you want the absolute rotation, use
getAbsoluteTransformation().getRotation()
\return Current relative rotation of the scene node. */
virtual const core::vector3df& getRotation() const
{
......@@ -445,7 +457,7 @@ namespace scene
}
//! Sets the rotation of the node.
//! Sets the rotation of the node relative to its parent.
/** This only modifies the relative rotation of the node.
\param rotation New rotation of the node in degrees. */
virtual void setRotation(const core::vector3df& rotation)
......@@ -454,8 +466,9 @@ namespace scene
}
//! Gets the position of the node.
/** Note that the position is relative to the parent.
//! Gets the position of the node relative to its parent.
/** Note that the position is relative to the parent. If you want
the position in world coordinates, use getAbsolutePosition() instead.
\return The current position of the node relative to the parent. */
virtual const core::vector3df& getPosition() const
{
......@@ -463,17 +476,19 @@ namespace scene
}
//! Sets the position of the node.
//! Sets the position of the node relative to its parent.
/** Note that the position is relative to the parent.
\param newpos New relative postition of the scene node. */
\param newpos New relative position of the scene node. */
virtual void setPosition(const core::vector3df& newpos)
{
RelativeTranslation = newpos;
}
//! Gets the abolute position of the node.
/** \return The current absolute position of the scene node. */
//! Gets the absolute position of the node in world coordinates.
/** If you want the position of the node relative to its parent,
use getPosition() instead.
\return The current absolute position of the scene node. */
virtual core::vector3df getAbsolutePosition() const
{
return AbsoluteTransformation.getTranslation();
......
......@@ -18,63 +18,62 @@ namespace video
{
//! Enumeration flags telling the video driver in which format textures
//! should be created.
//! Enumeration flags telling the video driver in which format textures should be created.
enum E_TEXTURE_CREATION_FLAG
{
//! Forces the driver to create 16 bit textures always, independent of
//! which format the file on disk has. When choosing this you may loose
//! some color detail, but gain much speed and memory. 16 bit textures
//! can be transferred twice as fast as 32 bit textures and only use
//! half of the space in memory.
//! When using this flag, it does not make sense to use the flags
//! ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY,
//! or ETCF_OPTIMIZED_FOR_SPEED at the same time.
/** Forces the driver to create 16 bit textures always, independent of
which format the file on disk has. When choosing this you may loose
some color detail, but gain much speed and memory. 16 bit textures can
be transferred twice as fast as 32 bit textures and only use half of
the space in memory.
When using this flag, it does not make sense to use the flags
ETCF_ALWAYS_32_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or
ETCF_OPTIMIZED_FOR_SPEED at the same time. */
ETCF_ALWAYS_16_BIT = 0x00000001,
//! Forces the driver to create 32 bit textures always, independent of
//! which format the file on disk has. Please note that some drivers
//! (like the software device) will ignore this, because they are only
//! able to create and use 16 bit textures.
//! When using this flag, it does not make sense to use the flags
//! ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY,
//! or ETCF_OPTIMIZED_FOR_SPEED at the same time.
/** Forces the driver to create 32 bit textures always, independent of
which format the file on disk has. Please note that some drivers (like
the software device) will ignore this, because they are only able to
create and use 16 bit textures.
When using this flag, it does not make sense to use the flags
ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY, or
ETCF_OPTIMIZED_FOR_SPEED at the same time. */
ETCF_ALWAYS_32_BIT = 0x00000002,
//! Lets the driver decide in which format the textures are created and
//! tries to make the textures look as good as possible.
//! Usually it simply chooses the format in which the texture was stored on disk.
//! When using this flag, it does not make sense to use the flags
//! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT,
//! or ETCF_OPTIMIZED_FOR_SPEED at the same time.
/** Lets the driver decide in which format the textures are created and
tries to make the textures look as good as possible. Usually it simply
chooses the format in which the texture was stored on disk.
When using this flag, it does not make sense to use the flags
ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_SPEED at
the same time. */
ETCF_OPTIMIZED_FOR_QUALITY = 0x00000004,
//! Lets the driver decide in which format the textures are created and
//! tries to create them maximizing render speed.
//! When using this flag, it does not make sense to use the flags
//! ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY,
//! at the same time.
/** Lets the driver decide in which format the textures are created and
tries to create them maximizing render speed.
When using this flag, it does not make sense to use the flags
ETCF_ALWAYS_16_BIT, ETCF_ALWAYS_32_BIT, or ETCF_OPTIMIZED_FOR_QUALITY,
at the same time. */
ETCF_OPTIMIZED_FOR_SPEED = 0x00000008,
//! Automatically creates mip map levels for the textures.
/** Automatically creates mip map levels for the textures. */
ETCF_CREATE_MIP_MAPS = 0x00000010,
//! Discard any alpha layer and use non-alpha color format.
/** Discard any alpha layer and use non-alpha color format. */
ETCF_NO_ALPHA_CHANNEL = 0x00000020,
//! Allow the Driver to use Non-Power-2-Textures
//! BurningVideo can handle Non-Power-2 Textures in 2D (GUI), but not it 3D
/** BurningVideo can handle Non-Power-2 Textures in 2D (GUI), but not it 3D. */
ETCF_ALLOW_NON_POWER_2 = 0x00000040,
//! This flag is never used, it only forces the compiler to
//! compile these enumeration values to 32 bit.
/** This flag is never used, it only forces the compiler to compile
these enumeration values to 32 bit. */
ETCF_FORCE_32_BIT_DO_NOT_USE = 0x7fffffff
};
//! Helper function, helps to get the desired texture creation format from the flags.
//! Returns either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT, ETCF_OPTIMIZED_FOR_QUALITY,
//! or ETCF_OPTIMIZED_FOR_SPEED.
/** \return Either ETCF_ALWAYS_32_BIT, ETCF_ALWAYS_16_BIT,
ETCF_OPTIMIZED_FOR_QUALITY, or ETCF_OPTIMIZED_FOR_SPEED. */
inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
{
if (flags & ETCF_OPTIMIZED_FOR_SPEED)
......@@ -90,13 +89,13 @@ inline E_TEXTURE_CREATION_FLAG getTextureFormatFromFlags(u32 flags)
//! Interface of a Video Driver dependent Texture.
/**
An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture or
IVideoDriver::getTexture. After that, the texture may only be used by this VideoDriver.
As you can imagine, textures of the DirectX and the OpenGL device will, e.g., not be compatible.
An exception is the Software device and the NULL device, their textures are compatible.
If you try to use a texture created by one device with an other device, the device
will refuse to do that and write a warning or an error message to the output buffer.
/** An ITexture is created by an IVideoDriver by using IVideoDriver::addTexture
or IVideoDriver::getTexture. After that, the texture may only be used by this
VideoDriver. As you can imagine, textures of the DirectX and the OpenGL device
will, e.g., not be compatible. An exception is the Software device and the
NULL device, their textures are compatible. If you try to use a texture
created by one device with an other device, the device will refuse to do that
and write a warning or an error message to the output buffer.
*/
class ITexture : public virtual IReferenceCounted
{
......@@ -125,42 +124,40 @@ public:
/** One should avoid to call unlock more than once before another lock. */
virtual void unlock() = 0;
//! Returns original size of the texture.
/** The texture is usually
scaled, if it was created with an unoptimal size. For example if the size
of the texture file it was loaded from was not a power of two. This returns
the size of the texture, it had before it was scaled. Can be useful
when drawing 2d images on the screen, which should have the exact size
of the original texture. Use ITexture::getSize() if you want to know
the real size it has now stored in the system.
\return Returns the original size of the texture. */
//! Get original size of the texture.
/** The texture is usually scaled, if it was created with an unoptimal
size. For example if the size of the texture file it was loaded from
was not a power of two. This returns the size of the texture, it had
before it was scaled. Can be useful when drawing 2d images on the
screen, which should have the exact size of the original texture. Use
ITexture::getSize() if you want to know the real size it has now stored
in the system.
\return The original size of the texture. */
virtual const core::dimension2d<u32>& getOriginalSize() const = 0;
//! Returns dimension (=size) of the texture.
/** \return Returns the size of the texture. */
//! Get dimension (=size) of the texture.
/** \return The size of the texture. */
virtual const core::dimension2d<u32>& getSize() const = 0;
//! Returns driver type of texture.
/** This is the driver, which created the texture.
This method is used internally by the video devices, to check, if they may
use a texture because textures may be incompatible between different
devices.
\return Returns driver type of texture. */
//! Get driver type of texture.
/** This is the driver, which created the texture. This method is used
internally by the video devices, to check, if they may use a texture
because textures may be incompatible between different devices.
\return Driver type of texture. */
virtual E_DRIVER_TYPE getDriverType() const = 0;
//! Returns the color format of texture.
/** \return Returns the color format of texture. */
//! Get the color format of texture.
/** \return The color format of texture. */
virtual ECOLOR_FORMAT getColorFormat() const = 0;
//! Returns pitch of texture (in bytes).
/** The pitch is the amount of bytes
used for a row of pixels in a texture.
\return Returns pitch of texture in bytes. */
//! Get pitch of texture (in bytes).
/** The pitch is the amount of bytes used for a row of pixels in a
texture.
\return Pitch of texture in bytes. */
virtual u32 getPitch() const = 0;
//! Returns whether the texture has MipMaps
/** \return Returns true if texture has MipMaps, else false. */
//! Check whether the texture has MipMaps
/** \return True if texture has MipMaps, else false. */
virtual bool hasMipMaps() const { return false; }
//! Returns if the texture has an alpha channel
......@@ -169,14 +166,14 @@ public:
}
//! Regenerates the mip map levels of the texture.
/** Required after locking and modifying the texture */
/** Required after modifying the texture, usually after calling unlock(). */
virtual void regenerateMipMapLevels() = 0;
//! Returns whether the texture is a render target
/** \return Returns true if this is a render target, otherwise false. */
//! Check whether the texture is a render target
/** \return True if this is a render target, otherwise false. */
virtual bool isRenderTarget() const { return false; }
//! Returns name of texture (in most cases this is the filename)
//! Get name of texture (in most cases this is the filename)
const core::string<c16>& getName() const { return Name; }
protected:
......
......@@ -96,9 +96,16 @@ directX header files, and directX is only available on windows platforms. If you
are using Dev-Cpp, and want to compile this using a DX dev pack, you can define
_IRR_COMPILE_WITH_DX9_DEV_PACK_. So you simply need to add something like this
to the compiler settings: -DIRR_COMPILE_WITH_DX9_DEV_PACK
and this to the linker settings: -ld3dx9 -ld3dx8 **/
and this to the linker settings: -ld3dx9 -ld3dx8
Microsoft have chosen to remove D3D8 headers from their recent DXSDKs, and
so D3D8 support is now disabled by default. If you really want to build
with D3D8 support, then you will have to source a DXSDK with the appropriate
headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one.
*/
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK))
//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004
//#define _IRR_COMPILE_WITH_DIRECT3D_8_
#define _IRR_COMPILE_WITH_DIRECT3D_9_
......
......@@ -16,7 +16,7 @@ namespace scene
struct SSharedMeshBuffer : public IMeshBuffer
{
//! constructor
SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHint(EHM_NEVER)
SSharedMeshBuffer() : IMeshBuffer(), Vertices(0), ChangedID_Vertex(1), ChangedID_Index(1), MappingHintVertex(EHM_NEVER), MappingHintIndex(EHM_NEVER)
{
#ifdef _DEBUG
setDebugName("SSharedMeshBuffer");
......@@ -127,24 +127,33 @@ namespace scene
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint() const
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Vertex() const
{
return MappingHint;
return MappingHintVertex;
}
//! get the current hardware mapping hint
virtual E_HARDWARE_MAPPING getHardwareMappingHint_Index() const
{
return MappingHintIndex;
}
//! set the hardware mapping hint, for driver
virtual void setHardwareMappingHint( E_HARDWARE_MAPPING NewMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX )
{
MappingHint=NewMappingHint;
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
MappingHintVertex=NewMappingHint;
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
MappingHintIndex=NewMappingHint;
}
//! flags the mesh as changed, reloads hardware buffers
virtual void setDirty(E_BUFFER_TYPE Buffer=EBT_VERTEX_AND_INDEX)
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX)
{
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_VERTEX)
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_VERTEX)
++ChangedID_Vertex;
if (Buffer==EBT_VERTEX_AND_INDEX || Buffer==EBT_INDEX)
if (buffer==EBT_VERTEX_AND_INDEX || buffer==EBT_INDEX)
++ChangedID_Index;
}
......@@ -175,7 +184,8 @@ namespace scene
core::aabbox3df BoundingBox;
//! hardware mapping hint
E_HARDWARE_MAPPING MappingHint;
E_HARDWARE_MAPPING MappingHintVertex;
E_HARDWARE_MAPPING MappingHintIndex;
};
......
......@@ -432,10 +432,13 @@ namespace io
\param callback: Callback for file read abstraction. Implement your own
callback to make the xml parser read in other things than just files. See
IFileReadCallBack for more information about this.
\param deleteCallback: if true, the callback will be deleted after the file
has been read. Otherwise the caller si responsible for cleaning it up.
\return Returns a pointer to the created xml parser. This pointer should be
deleted using 'delete' after no longer needed. Returns 0 if an error occured
and the file could not be opened. */
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback);
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
bool deleteCallback = false);
//! Creates an instance of an UFT-16 xml parser.
/** This means that
......@@ -469,10 +472,13 @@ namespace io
\param callback: Callback for file read abstraction. Implement your own
callback to make the xml parser read in other things than just files. See
IFileReadCallBack for more information about this.
\param deleteCallback: if true, the callback will be deleted after the file
has been read. Otherwise the caller si responsible for cleaning it up.
\return Returns a pointer to the created xml parser. This pointer should be
deleted using 'delete' after no longer needed. Returns 0 if an error occured
and the file could not be opened. */
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback);
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
bool deleteCallback = false);
//! Creates an instance of an UFT-32 xml parser.
......@@ -507,10 +513,13 @@ namespace io
\param callback: Callback for file read abstraction. Implement your own
callback to make the xml parser read in other things than just files. See
IFileReadCallBack for more information about this.
\param deleteCallback: if true, the callback will be deleted after the file
has been read. Otherwise the caller si responsible for cleaning it up.
\return Returns a pointer to the created xml parser. This pointer should be
deleted using 'delete' after no longer needed. Returns 0 if an error occured
and the file could not be opened. */
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback);
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
bool deleteCallback = false);
/*! \file irrxml.h
......
......@@ -28,10 +28,6 @@ The Irrlicht Engine SDK version 1.5
\doc Documentation of the Irrlicht Engine.
\examples Examples and tutorials showing how to use the engine with
C++.
\example.net Examples and tutorials showing how to use the engine with
.NET languages.
\exporters Exporters and tools for various 3D modelling packages. There
is a readme file with more details in the directory.
\include Header files to include when programming with the engine.
\lib Libs to link with your programs when using the engine.
\media Graphics and sound resources for the demo applications and
......
......@@ -323,7 +323,6 @@ core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename
p = _fullpath( fpath, filename.c_str(), _MAX_PATH);
#endif
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
c8 fpath[4096];
fpath[0]=0;
......
......@@ -131,10 +131,6 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
for (u32 i=0; i<numJoysticks; ++i)
SDL_JoystickClose(Joysticks[i]);
#endif
// only free surfaces created by us
if (Screen && !CreationParams.WindowId)
SDL_FreeSurface(Screen);
SDL_Quit();
}
......@@ -424,8 +420,6 @@ bool CIrrDeviceSDL::run()
{
Width = SDL_event.resize.w;
Height = SDL_event.resize.h;
if (Screen)
SDL_FreeSurface(Screen);
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
......@@ -724,8 +718,6 @@ void CIrrDeviceSDL::setResizable(bool resize)
SDL_Flags |= SDL_RESIZABLE;
else
SDL_Flags &= ~SDL_RESIZABLE;
if (Screen)
SDL_FreeSurface(Screen);
Screen = SDL_SetVideoMode( Width, Height, CreationParams.Bits, SDL_Flags );
Resizable = resize;
}
......
......@@ -235,6 +235,10 @@ IImageWriter* CNullDriver::getImageWriter(u32 n)
//! deletes all textures
void CNullDriver::deleteAllTextures()
{
// we need to remove previously set textures which might otherwise be kept in the
// last set material member. Could be optimized to reduce state changes.
setMaterial(SMaterial());
for (u32 i=0; i<Textures.size(); ++i)
Textures[i].Surface->drop();
......
......@@ -20,8 +20,8 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
StencilBuffer(false), MultiTextureExtension(false),
TextureCompressionExtension(false),
MaxTextureUnits(1), MaxLights(1), MaxAnisotropy(1), MaxUserClipPlanes(0),
MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1),
MaxTextureLODBias(0.f), Version(0), ShaderLanguageVersion(0)
MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1), MaxTextureLODBias(0.f),
MaxMultipleRenderTargets(1), Version(0), ShaderLanguageVersion(0)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0),
pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0),
......@@ -44,6 +44,7 @@ COpenGLExtensionHandler::COpenGLExtensionHandler() :
pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0),
pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0),
pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0),
pGlDrawBuffersARB(0), pGlDrawBuffersATI(0),
pGlGenBuffersARB(0), pGlBindBufferARB(0), pGlBufferDataARB(0), pGlDeleteBuffersARB(0),
pGlBufferSubDataARB(0), pGlGetBufferSubDataARB(0), pGlMapBufferARB(0), pGlUnmapBufferARB(0),
pGlIsBufferARB(0), pGlGetBufferParameterivARB(0), pGlGetBufferPointervARB(0)
......@@ -160,6 +161,8 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT");
pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT");
pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC) wglGetProcAddress("glDrawBuffersARB");
pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC) wglGetProcAddress("glDrawBuffersATI");
// get vertex buffer extension
pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC) wglGetProcAddress("glGenBuffersARB");
......@@ -349,6 +352,12 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glFramebufferRenderbufferEXT"));
pGlDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDrawBuffersARB"));
pGlDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glDrawBuffersATI"));
pGlGenBuffersARB = (PFNGLGENBUFFERSARBPROC)
IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGenBuffersARB"));
......@@ -419,6 +428,19 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MaxUserClipPlanes=static_cast<u8>(num);
glGetIntegerv(GL_AUX_BUFFERS, &num);
MaxAuxBuffers=static_cast<u8>(num);
#ifdef ARB_draw_buffers
if (FeatureAvailable[IRR_ARB_draw_buffers])
{
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, reinterpret_cast<GLint*>(&MaxUserClipPlanes));
MaxMultipleRenderTargets = static_cast<u8>(MaxUserClipPlanes);
}
#elif defined(ATI_draw_buffers)
if (FeatureAvailable[IRR_ATI_draw_buffers])
{
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ATI, reinterpret_cast<GLint*>(&MaxUserClipPlanes));
MaxMultipleRenderTargets = static_cast<u8>(MaxUserClipPlanes);
}
#endif
#if defined(GL_ARB_shading_language_100) || defined (GL_VERSION_2_0)
if (FeatureAvailable[IRR_ARB_shading_language_100] || Version>=200)
{
......
......@@ -733,6 +733,8 @@ class COpenGLExtensionHandler
u32 MaxTextureSize;
//! Maximal LOD Bias
f32 MaxTextureLODBias;
//! Number of rendertargets available as MRTs
u8 MaxMultipleRenderTargets;
//! OpenGL version as Integer: 100*Major+Minor, i.e. 2.1 becomes 201
u16 Version;
......@@ -790,6 +792,7 @@ class COpenGLExtensionHandler
void extGlRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
void extGlFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
void extGlActiveStencilFace(GLenum face);
void extGlDrawBuffers(GLsizei n, const GLenum *bufs);
// vertex buffer object
void extGlGenBuffers(GLsizei n, GLuint *buffers);
......@@ -861,6 +864,8 @@ class COpenGLExtensionHandler
PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT;
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT;
PFNGLACTIVESTENCILFACEEXTPROC pGlActiveStencilFaceEXT;
PFNGLDRAWBUFFERSARBPROC pGlDrawBuffersARB;
PFNGLDRAWBUFFERSATIPROC pGlDrawBuffersATI;
PFNGLGENBUFFERSARBPROC pGlGenBuffersARB;
PFNGLBINDBUFFERARBPROC pGlBindBufferARB;
PFNGLBUFFERDATAARBPROC pGlBufferDataARB;
......@@ -1404,6 +1409,22 @@ inline void COpenGLExtensionHandler::extGlActiveStencilFace(GLenum face)
#endif
}
inline void COpenGLExtensionHandler::extGlDrawBuffers(GLsizei n, const GLenum *bufs)
{
#ifdef _IRR_OPENGL_USE_EXTPOINTER_
if (pGlDrawBuffersARB)
pGlDrawBuffersARB(n, bufs);
else if (pGlDrawBuffersATI)
pGlDrawBuffersATI(n, bufs);
#elif defined(GL_ARB_draw_buffers)
glDrawBuffersARB(n, bufs);
#elif defined(GL_ATI_draw_buffers)
glDrawBuffersATI(n, bufs);
#else
os::Printer::log("glDrawBuffers not supported", ELL_ERROR);
#endif
}
inline void COpenGLExtensionHandler::extGlGenBuffers(GLsizei n, GLuint *buffers)
{
......
......@@ -555,7 +555,7 @@ private:
long size = callback->getSize();
if (size<0)
return false;
size += 4; // We need two terminating 0's at the end.
size += 4; // We need four terminating 0's at the end.
// For ASCII we need 1 0's, for UTF-16 2, for UTF-32 4.
char* data8 = new char[size];
......@@ -588,35 +588,35 @@ private:
{
// UTF-32, big endian
SourceFormat = ETF_UTF32_BE;
convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header
convertTextData(data32+1, data8, (size/4)-1); // data32+1 because we need to skip the header
}
else
if (size >= 4 && data32[0] == (char32)UTF32_LE)
{
// UTF-32, little endian
SourceFormat = ETF_UTF32_LE;
convertTextData(data32+1, data8, (size/4)); // data32+1 because we need to skip the header
convertTextData(data32+1, data8, (size/4)-1); // data32+1 because we need to skip the header
}
else
if (size >= 2 && data16[0] == UTF16_BE)
{
// UTF-16, big endian
SourceFormat = ETF_UTF16_BE;
convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header
convertTextData(data16+1, data8, (size/2)-1); // data16+1 because we need to skip the header
}
else
if (size >= 2 && data16[0] == UTF16_LE)
{
// UTF-16, little endian
SourceFormat = ETF_UTF16_LE;
convertTextData(data16+1, data8, (size/2)); // data16+1 because we need to skip the header
convertTextData(data16+1, data8, (size/2)-1); // data16+1 because we need to skip the header
}
else
if (size >= 3 && data8[0] == UTF8[0] && data8[1] == UTF8[1] && data8[2] == UTF8[2])
if (size >= 3 && memcmp(data8,UTF8,3)==0)
{
// UTF-8
SourceFormat = ETF_UTF8;
convertTextData(data8+3, data8, size); // data8+3 because we need to skip the header
convertTextData(data8+3, data8, size-3); // data8+3 because we need to skip the header
}
else
{
......
......@@ -83,72 +83,96 @@ private:
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(const char* filename)
{
return createIrrXMLReader(new CFileReadCallBack(filename));
return createIrrXMLReader(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(FILE* file)
{
return createIrrXMLReader(new CFileReadCallBack(file));
return createIrrXMLReader(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UFT-8 or ASCII character xml parser.
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback)
IRRLICHT_API IrrXMLReader* IRRCALLCONV createIrrXMLReader(IFileReadCallBack* callback,
bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
return new CXMLReaderImpl<char, IXMLBase>(callback, false);
{
return new CXMLReaderImpl<char, IXMLBase>(callback, deleteCallback);
}
else
{
if(callback && deleteCallback)
delete callback;
return 0;
}
}
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(const char* filename)
{
return createIrrXMLReaderUTF16(new CFileReadCallBack(filename));
return createIrrXMLReaderUTF16(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(FILE* file)
{
return createIrrXMLReaderUTF16(new CFileReadCallBack(file));
return createIrrXMLReaderUTF16(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UTF-16 xml parser.
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback)
IRRLICHT_API IrrXMLReaderUTF16* IRRCALLCONV createIrrXMLReaderUTF16(IFileReadCallBack* callback,
bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
return new CXMLReaderImpl<char16, IXMLBase>(callback, false);
{
return new CXMLReaderImpl<char16, IXMLBase>(callback, deleteCallback);
}
else
{
if(callback && deleteCallback)
delete callback;
return 0;
}
}
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(const char* filename)
{
return createIrrXMLReaderUTF32(new CFileReadCallBack(filename));
return createIrrXMLReaderUTF32(new CFileReadCallBack(filename), true);
}
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(FILE* file)
{
return createIrrXMLReaderUTF32(new CFileReadCallBack(file));
return createIrrXMLReaderUTF32(new CFileReadCallBack(file), true);
}
//! Creates an instance of an UTF-32 xml parser.
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback)
IRRLICHT_API IrrXMLReaderUTF32* IRRCALLCONV createIrrXMLReaderUTF32(IFileReadCallBack* callback,
bool deleteCallback)
{
if (callback && (callback->getSize() >= 0))
return new CXMLReaderImpl<char32, IXMLBase>(callback, false);
{
return new CXMLReaderImpl<char32, IXMLBase>(callback, deleteCallback);
}
else
{
if(callback && deleteCallback)
delete callback;
return 0;
}
}
......
......@@ -72,15 +72,13 @@ namespace os
void Printer::print(const c8* message)
{
#if defined (_WIN32_WCE )
core::stringw tmp ( message );
core::stringw tmp(message);
tmp += L"\n";
OutputDebugStringW( tmp.c_str() );
OutputDebugStringW(tmp.c_str());
#else
c8* tmp = new c8[strlen(message) + 4];
sprintf(tmp, "%s\n", message);
OutputDebugString(tmp);
printf(tmp);
delete [] tmp;
OutputDebugString(message);
OutputDebugString("\n");
printf("%s\n", message);
#endif
}
......
......@@ -76,6 +76,7 @@ int main(int argumentCount, char * arguments[])
TEST(cursorSetVisible);
TEST(transparentAlphaChannelRef);
TEST(drawRectOutline);
TEST(removeCustomAnimator);
// Tests available on 1.6+
TEST(collisionResponseAnimator);
......
// Copyright (C) 2008-2009 Colin MacDonald
// No rights reserved: this software is in the public domain.
#include "testUtils.h"
#include "irrlicht.h"
#include <assert.h>
using namespace irr;
using namespace core;
using namespace scene;
class CustomAnimator : public ISceneNodeAnimator
{
void animateNode(ISceneNode* node, u32 timeMs)
{
// Check that I can remove myself from my node durings its animateNode() loop.
node->removeAnimator(this);
}
ISceneNodeAnimator* createClone(ISceneNode* node, ISceneManager* newManager=0) { return 0 ; }
};
/** Test that a custom animator can remove itself cleanly from an ISceneNode during its
* own animateNode() loop.
* http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32271 */
bool removeCustomAnimator(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<s32>(160, 120));
assert(device);
if(!device)
return false;
ISceneManager * smgr = device->getSceneManager();
ISceneNode * node = smgr->addEmptySceneNode();
CustomAnimator * instantlyElapsing1 = new CustomAnimator();
CustomAnimator * instantlyElapsing2 = new CustomAnimator();
node->addAnimator(instantlyElapsing1);
node->addAnimator(instantlyElapsing2);
// This should result in both custom animators being removed and
// deleted cleanly, without a crash.
node->OnAnimate(0);
device->drop();
// If we didn't crash, then the test passed.
return true;
}
......@@ -57,6 +57,7 @@
<Unit filename="md2Animation.cpp" />
<Unit filename="planeMatrix.cpp" />
<Unit filename="relativeTransformations.cpp" />
<Unit filename="removeCustomAnimator.cpp" />
<Unit filename="sceneCollisionManager.cpp" />
<Unit filename="sceneNodeAnimator.cpp" />
<Unit filename="softwareDevice.cpp" />
......
......@@ -248,6 +248,10 @@
RelativePath=".\planeMatrix.cpp"
>
</File>
<File
RelativePath=".\removeCustomAnimator.cpp"
>
</File>
<File
RelativePath=".\sceneCollisionManager.cpp"
>
......
......@@ -246,6 +246,10 @@
RelativePath=".\planeMatrix.cpp"
>
</File>
<File
RelativePath=".\removeCustomAnimator.cpp"
>
</File>
<File
RelativePath=".\sceneCollisionManager.cpp"
>
......
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