Merging r5664 through r5672 from trunk to ogl-es:

- Allow to create images with floating point formats. 
- No longer set world transform twice in CMeshSceneNode.
- Add IMaterialRenderer::getShaderConstantSetCallBack to allow access to user provided shader callbacks.
- Reset blend and alphatest states in GL and GLSL shader materials.
- Fix memory leak in OpenGL for automatic generated rendertarget depthbuffer textures.
- Remove .aps file from source control.
- Get rid of compile warnings in CAnimatedMeshHalfLife.cpp


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5683 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2019-01-17 22:47:46 +00:00
parent 00c13a165b
commit 021839deee
13 changed files with 115 additions and 86 deletions

View File

@ -20,6 +20,7 @@ namespace video
//! Interface for software image data.
/** Image loaders create these images from files. IVideoDrivers convert
these images into their (hardware) textures.
NOTE: Floating point formats are not well supported yet. Basically only getData() works for them.
*/
class IImage : public virtual IReferenceCounted
{
@ -444,7 +445,7 @@ public:
}
}
//! check if the color format is only viable for RenderTarget textures
//! Check if the color format is only viable for RenderTarget textures
/** Since we don't have support for e.g. floating point IImage formats
one should test if the color format can be used for arbitrary usage, or
if it is restricted to RTTs. */
@ -475,6 +476,7 @@ public:
case ECF_ETC2_ARGB:
return false;
default:
// All floating point formats. Function name should really be isFloatingPointFormat.
return true;
}
}

View File

@ -16,6 +16,7 @@ namespace video
class IVideoDriver;
class IMaterialRendererServices;
class IShaderConstantSetCallBack;
//! Interface for material rendering.
/** Can be used to extend the engine with new materials. Refer to
@ -91,6 +92,11 @@ public:
Fixed function pipeline materials should return 0 in most cases, parallax mapped
material will only return 0 when at least pixel shader 1.4 is available on that machine. */
virtual s32 getRenderCapability() const { return 0; }
//! Access the callback provided by the users when creating shader materials
/** \returns Returns either the users provided callback or 0 when no such
callback exists. Non-shader materials will always return 0. */
virtual IShaderConstantSetCallBack* getShaderConstantSetCallBack() const { return 0; }
};

View File

@ -61,7 +61,7 @@ namespace scene
void QuaternionSlerp( const vec4_hl p, vec4_hl q, f32 t, vec4_hl qt )
{
s32 i;
f32 omega, cosom, sinom, sclp, sclq;
double omega, cosom, sinom, sclp, sclq;
// decide if one of the quaternions is backwards
f32 a = 0;
@ -90,7 +90,7 @@ namespace scene
sclq = t;
}
for (i = 0; i < 4; i++) {
qt[i] = sclp * p[i] + sclq * q[i];
qt[i] = f32(sclp * p[i] + sclq * q[i]);
}
}
else {
@ -101,7 +101,7 @@ namespace scene
sclp = sin( (1.f - t) * 0.5f * core::PI);
sclq = sin( t * 0.5f * core::PI);
for (i = 0; i < 3; i++) {
qt[i] = sclp * p[i] + sclq * qt[i];
qt[i] = f32(sclp * p[i] + sclq * qt[i]);
}
}
}

View File

@ -48,6 +48,12 @@ public:
//! Returns if the material is transparent.
virtual bool isTransparent() const _IRR_OVERRIDE_;
//! Access the callback provided by the users when creating shader materials
virtual IShaderConstantSetCallBack* getShaderConstantSetCallBack() const _IRR_OVERRIDE_
{
return CallBack;
}
protected:
//! constructor only for use by derived classes who want to

View File

@ -175,8 +175,6 @@ void CMeshSceneNode::render()
}
}
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
// for debug purposes only:
if (DebugDataVisible && PassCount==1)
{

View File

@ -1672,12 +1672,6 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format,
const core::dimension2d<u32>& size, void *data, bool ownForeignMemory,
bool deleteMemory)
{
if(IImage::isRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, size, data, ownForeignMemory, deleteMemory);
}
@ -1685,12 +1679,6 @@ IImage* CNullDriver::createImageFromData(ECOLOR_FORMAT format,
//! Creates an empty software image.
IImage* CNullDriver::createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size)
{
if(IImage::isRenderTargetOnlyFormat(format))
{
os::Printer::log("Could not create IImage, format only supported for render target textures.", ELL_WARNING);
return 0;
}
return new CImage(format, size);
}

View File

@ -60,93 +60,90 @@ public:
virtual void setTexture(const core::array<ITexture*>& texture, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces) _IRR_OVERRIDE_
{
bool textureUpdate = (Texture != texture) || (CubeSurfaces != cubeSurfaces) ? true : false;
bool depthStencilUpdate = (DepthStencil != depthStencil) ? true : false;
bool needSizeUpdate = false;
if (textureUpdate || depthStencilUpdate)
// Set color attachments.
if ((Texture != texture) || (CubeSurfaces != cubeSurfaces))
{
// Set color attachments.
needSizeUpdate = true;
CubeSurfaces = cubeSurfaces;
if (textureUpdate)
for (u32 i = 0; i < Texture.size(); ++i)
{
CubeSurfaces = cubeSurfaces;
for (u32 i = 0; i < Texture.size(); ++i)
{
if (Texture[i])
Texture[i]->drop();
}
if (texture.size() > static_cast<u32>(ColorAttachment))
{
core::stringc message = "This GPU supports up to ";
message += static_cast<u32>(ColorAttachment);
message += " textures per render target.";
os::Printer::log(message.c_str(), ELL_WARNING);
}
Texture.set_used(core::min_(texture.size(), static_cast<u32>(ColorAttachment)));
for (u32 i = 0; i < Texture.size(); ++i)
{
TOpenGLTexture* currentTexture = (texture[i] && texture[i]->getDriverType() == DriverType) ? static_cast<TOpenGLTexture*>(texture[i]) : 0;
GLuint textureID = 0;
if (currentTexture)
{
textureID = currentTexture->getOpenGLTextureName();
}
if (textureID != 0)
{
Texture[i] = texture[i];
Texture[i]->grab();
}
else
{
Texture[i] = 0;
}
}
RequestTextureUpdate = true;
if (Texture[i])
Texture[i]->drop();
}
// Set depth and stencil attachments.
if (depthStencilUpdate)
if (texture.size() > static_cast<u32>(ColorAttachment))
{
TOpenGLTexture* currentTexture = (depthStencil && depthStencil->getDriverType() == DriverType) ? static_cast<TOpenGLTexture*>(depthStencil) : 0;
core::stringc message = "This GPU supports up to ";
message += static_cast<u32>(ColorAttachment);
message += " textures per render target.";
os::Printer::log(message.c_str(), ELL_WARNING);
}
Texture.set_used(core::min_(texture.size(), static_cast<u32>(ColorAttachment)));
for (u32 i = 0; i < Texture.size(); ++i)
{
TOpenGLTexture* currentTexture = (texture[i] && texture[i]->getDriverType() == DriverType) ? static_cast<TOpenGLTexture*>(texture[i]) : 0;
GLuint textureID = 0;
if (currentTexture)
{
if (currentTexture->getType() == ETT_2D)
textureID = currentTexture->getOpenGLTextureName();
else
os::Printer::log("This driver doesn't support depth/stencil to cubemaps.", ELL_WARNING);
{
textureID = currentTexture->getOpenGLTextureName();
}
const ECOLOR_FORMAT textureFormat = (textureID != 0) ? depthStencil->getColorFormat() : ECF_UNKNOWN;
if (IImage::isDepthFormat(textureFormat))
if (textureID != 0)
{
DepthStencil = depthStencil;
DepthStencil->grab();
Texture[i] = texture[i];
Texture[i]->grab();
}
else
{
if (DepthStencil)
DepthStencil->drop();
DepthStencil = 0;
Texture[i] = 0;
}
RequestDepthStencilUpdate = true;
}
RequestTextureUpdate = true;
}
// Set depth and stencil attachments.
if (DepthStencil != depthStencil)
{
if (DepthStencil)
{
DepthStencil->drop();
DepthStencil = 0;
}
needSizeUpdate = true;
TOpenGLTexture* currentTexture = (depthStencil && depthStencil->getDriverType() == DriverType) ? static_cast<TOpenGLTexture*>(depthStencil) : 0;
GLuint textureID = 0;
if (currentTexture)
{
if (currentTexture->getType() == ETT_2D)
textureID = currentTexture->getOpenGLTextureName();
else
os::Printer::log("This driver doesn't support depth/stencil to cubemaps.", ELL_WARNING);
}
const ECOLOR_FORMAT textureFormat = (textureID != 0) ? depthStencil->getColorFormat() : ECF_UNKNOWN;
if (IImage::isDepthFormat(textureFormat))
{
DepthStencil = depthStencil;
DepthStencil->grab();
}
RequestDepthStencilUpdate = true;
}
if (needSizeUpdate)
{
// Set size required for a viewport.
ITexture* firstTexture = getTexture();

View File

@ -220,7 +220,7 @@ public:
if (LockImage)
return LockImage->getData();
if (IImage::isCompressedFormat(ColorFormat) || IImage::isRenderTargetOnlyFormat(ColorFormat))
if (IImage::isCompressedFormat(ColorFormat))
return 0;
LockReadOnly |= (mode == ETLM_READ_ONLY);

View File

@ -293,6 +293,16 @@ void COpenGLSLMaterialRenderer::OnUnsetMaterial()
Driver->extGlUseProgramObject(0);
if (Program2)
Driver->irrGlUseProgram(0);
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
if (Alpha || FixedBlending || Blending)
{
cacheHandler->setBlend(false);
}
else if (AlphaTest)
{
cacheHandler->setAlphaTest(false);
}
}

View File

@ -65,6 +65,12 @@ public:
//! Returns if the material is transparent.
virtual bool isTransparent() const _IRR_OVERRIDE_;
//! Access the callback provided by the users when creating shader materials
virtual IShaderConstantSetCallBack* getShaderConstantSetCallBack() const _IRR_OVERRIDE_
{
return CallBack;
}
// implementations for the render services
virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) _IRR_OVERRIDE_;
virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;

View File

@ -266,6 +266,16 @@ void COpenGLShaderMaterialRenderer::OnUnsetMaterial()
if (PixelShader[0])
glDisable(GL_FRAGMENT_PROGRAM_NV);
#endif
COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler();
if (Alpha || FixedBlending || Blending)
{
cacheHandler->setBlend(false);
}
else if (AlphaTest)
{
cacheHandler->setAlphaTest(false);
}
}

View File

@ -44,6 +44,12 @@ public:
//! Returns if the material is transparent.
virtual bool isTransparent() const _IRR_OVERRIDE_;
//! Access the callback provided by the users when creating shader materials
virtual IShaderConstantSetCallBack* getShaderConstantSetCallBack() const _IRR_OVERRIDE_
{
return CallBack;
}
protected:
//! constructor only for use by derived classes who want to

Binary file not shown.