Added RTTs to texture cache.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1622 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
324acd72ad
commit
b44c2bdadf
|
@ -1,5 +1,7 @@
|
|||
Changes in version 1.5 (... 2008)
|
||||
|
||||
- Major API change: RTTs are now created via addRenderTargetTexture instead of createRenderTargetTexture, which allows to retrieve them from the texture cache, but also changes the way of removing the RTTs, and especially one must not drop the pointer anymore.
|
||||
|
||||
- WindowsCE-Bugfix
|
||||
|
||||
- isBetweenPoints return true now even for the begin and end points, i.e. line segments are now including their start and end.
|
||||
|
|
|
@ -120,14 +120,14 @@ int main()
|
|||
/*
|
||||
To test out the render to texture feature, we need a render target
|
||||
texture. These are not like standard textures, but need to be created
|
||||
first. To create one, we call IVideoDriver::createRenderTargetTexture()
|
||||
first. To create one, we call IVideoDriver::addRenderTargetTexture()
|
||||
and specify the size of the texture. Please don't use sizes bigger than
|
||||
the frame buffer for this, because the render target shares the zbuffer
|
||||
with the frame buffer. And because we want to render the scene not from
|
||||
the user camera into the texture, we add another fixed camera to the
|
||||
scene. But before we do all this, we check if the current running
|
||||
driver is able to render to textures. If it is not, we simply display a
|
||||
warning text.
|
||||
with the frame buffer.
|
||||
Because we want to render the scene not from the user camera into the
|
||||
texture, we add another fixed camera to the scene. But before we do all
|
||||
this, we check if the current running driver is able to render to
|
||||
textures. If it is not, we simply display a warning text.
|
||||
*/
|
||||
|
||||
// create render target
|
||||
|
@ -137,7 +137,7 @@ int main()
|
|||
|
||||
if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
|
||||
{
|
||||
rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256,256));
|
||||
rt = driver->addRenderTargetTexture(core::dimension2d<s32>(256,256), "RTT1");
|
||||
test->setMaterialTexture(0, rt); // set material of cube to render target
|
||||
|
||||
// add fixed camera
|
||||
|
@ -218,9 +218,6 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
if (rt)
|
||||
rt->drop(); // drop render target because we created if with a create() method
|
||||
|
||||
device->drop(); // drop device
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -214,17 +214,22 @@ namespace video
|
|||
information. */
|
||||
virtual ITexture* addTexture(const c8* name, IImage* image) = 0;
|
||||
|
||||
//! Creates a render target texture.
|
||||
//! Adds a new render target texture to the texture cache.
|
||||
/** \param size Size of the texture, in pixels. Width and
|
||||
height should be a power of two (e.g. 64, 128, 256, 512, ...)
|
||||
and it should not be bigger than the backbuffer, because it
|
||||
shares the zbuffer with the screen buffer.
|
||||
\param name An optional name for the RTT.
|
||||
\return Pointer to the created texture or 0 if the texture
|
||||
could not be created. If you no longer need the image, you
|
||||
should call ITexture::drop(). See IReferenceCounted::drop()
|
||||
for more information. */
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name = 0) = 0;
|
||||
could not be created. This pointer should not be dropped. See
|
||||
IReferenceCounted::drop() for more information. */
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name=0) =0;
|
||||
|
||||
//! Adds a new render target texture
|
||||
/** \deprecated use addRenderTargetTexture instead. */
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name=0) =0;
|
||||
|
||||
//! Removes a texture from the texture cache and deletes it.
|
||||
/** This method can free a lot of memory!
|
||||
|
@ -293,7 +298,7 @@ namespace video
|
|||
way:
|
||||
\code
|
||||
// create render target
|
||||
ITexture* target = driver->createRenderTargetTexture(core::dimension2d<s32>(128,128));
|
||||
ITexture* target = driver->addRenderTargetTexture(core::dimension2d<s32>(128,128), "rtt1");
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -311,7 +316,7 @@ namespace video
|
|||
simple workaround for this is to flip the texture coordinates
|
||||
of the geometry where the render target texture is displayed on.
|
||||
\param texture New render target. Must be a texture created with
|
||||
IVideoDriver::createRenderTargetTexture(). If set to 0, it sets
|
||||
IVideoDriver::addRenderTargetTexture(). If set to 0, it sets
|
||||
the previous render target which was set before the last
|
||||
setRenderTarget() call.
|
||||
\param clearBackBuffer Clears the backbuffer of the render
|
||||
|
|
|
@ -752,10 +752,15 @@ bool CD3D8Driver::setRenderTarget(video::ITexture* texture,
|
|||
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CD3D8Driver::createRenderTargetTexture(
|
||||
ITexture* CD3D8Driver::addRenderTargetTexture(
|
||||
const core::dimension2d<s32>& size, const c8* name)
|
||||
{
|
||||
return new CD3D8Texture(this, size, name);
|
||||
if (!name)
|
||||
name="rt";
|
||||
ITexture* tex = new CD3D8Texture(this, size, name);
|
||||
addTexture(tex);
|
||||
tex->drop();
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -180,7 +180,8 @@ namespace video
|
|||
virtual IVideoDriver* getVideoDriver();
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name);
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
virtual void clearZBuffer();
|
||||
|
|
|
@ -2434,9 +2434,15 @@ IVideoDriver* CD3D9Driver::getVideoDriver()
|
|||
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CD3D9Driver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
ITexture* CD3D9Driver::addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name)
|
||||
{
|
||||
return new CD3D9Texture(this, size, name);
|
||||
if (!name)
|
||||
name="rt";
|
||||
ITexture* tex = new CD3D9Texture(this, size, name);
|
||||
addTexture(tex);
|
||||
tex->drop();
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -200,7 +200,8 @@ namespace video
|
|||
virtual IVideoDriver* getVideoDriver();
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name);
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
virtual void clearZBuffer();
|
||||
|
|
|
@ -1808,12 +1808,15 @@ s32 CNullDriver::addShaderMaterialFromFiles(const c8* vertexShaderProgramFileNam
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
ITexture* CNullDriver::addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
void CNullDriver::clearZBuffer()
|
||||
{
|
||||
|
@ -1833,6 +1836,7 @@ IImage* CNullDriver::createScreenShot()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// prints renderer version
|
||||
void CNullDriver::printVersion()
|
||||
{
|
||||
|
@ -1879,6 +1883,15 @@ void CNullDriver::enableClipPlane(u32 index, bool enable)
|
|||
}
|
||||
|
||||
|
||||
ITexture* CNullDriver::createRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name)
|
||||
{
|
||||
os::Printer::log("createRenderTargetTexture is deprecated, use addRenderTargetTexture istead");
|
||||
ITexture* tex = addRenderTargetTexture(size, name);
|
||||
tex->grab();
|
||||
return tex;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
|
|
|
@ -267,7 +267,8 @@ namespace video
|
|||
virtual void removeAllTextures();
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name);
|
||||
|
||||
//! Creates an 1bit alpha channel of the texture based of an color key.
|
||||
virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color) const;
|
||||
|
@ -507,6 +508,10 @@ namespace video
|
|||
virtual void setAllowZWriteOnTransparent(bool flag)
|
||||
{ AllowZWriteOnTransparent=flag; }
|
||||
|
||||
//! deprecated method
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name=0);
|
||||
|
||||
protected:
|
||||
|
||||
//! deletes all textures
|
||||
|
|
|
@ -2548,7 +2548,7 @@ IGPUProgrammingServices* COpenGLDriver::getGPUProgrammingServices()
|
|||
}
|
||||
|
||||
|
||||
ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
ITexture* COpenGLDriver::addRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
{
|
||||
//disable mip-mapping
|
||||
bool generateMipLevels = getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
|
||||
|
@ -2560,7 +2560,11 @@ ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d<s32>&
|
|||
#if defined(GL_EXT_framebuffer_object)
|
||||
// if driver supports FrameBufferObjects, use them
|
||||
if (queryFeature(EVDF_FRAMEBUFFER_OBJECT))
|
||||
{
|
||||
rtt = new COpenGLTexture(size, name, this);
|
||||
addTexture(rtt);
|
||||
rtt->drop();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
|
|
|
@ -306,7 +306,8 @@ namespace video
|
|||
//! call.
|
||||
virtual u32 getMaximalPrimitiveCount() const;
|
||||
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name);
|
||||
|
||||
virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer,
|
||||
bool clearZBuffer, SColor color);
|
||||
|
|
|
@ -880,12 +880,17 @@ const core::matrix4& CSoftwareDriver::getTransform(E_TRANSFORMATION_STATE state)
|
|||
return TransformationMatrix[state];
|
||||
}
|
||||
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CSoftwareDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
ITexture* CSoftwareDriver::addRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
{
|
||||
CImage* img = new CImage(video::ECF_A1R5G5B5, size);
|
||||
if (!name)
|
||||
name="rt";
|
||||
ITexture* tex = new CSoftwareTexture(img, name, true);
|
||||
img->drop();
|
||||
addTexture(tex);
|
||||
tex->drop();
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ namespace video
|
|||
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name);
|
||||
|
||||
//! Clears the ZBuffer.
|
||||
virtual void clearZBuffer();
|
||||
|
|
|
@ -1845,12 +1845,16 @@ const core::matrix4& CBurningVideoDriver::getTransform(E_TRANSFORMATION_STATE st
|
|||
|
||||
|
||||
//! Creates a render target texture.
|
||||
ITexture* CBurningVideoDriver::createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name)
|
||||
ITexture* CBurningVideoDriver::addRenderTargetTexture(const core::dimension2d<s32>& size,
|
||||
const c8* name)
|
||||
{
|
||||
CImage* img = new CImage(BURNINGSHADER_COLOR_FORMAT, size);
|
||||
|
||||
if (!name)
|
||||
name="rt";
|
||||
ITexture* tex = new CSoftwareTexture2(img, name, false, true);
|
||||
img->drop();
|
||||
addTexture(tex);
|
||||
tex->drop();
|
||||
return tex;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace video
|
|||
virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const;
|
||||
|
||||
//! Creates a render target texture.
|
||||
virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
virtual ITexture* addRenderTargetTexture(const core::dimension2d<s32>& size, const c8* name);
|
||||
|
||||
//! Clears the DepthBuffer.
|
||||
virtual void clearZBuffer();
|
||||
|
|
Loading…
Reference in New Issue