Merging r6196 through r6248 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6249 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2021-08-26 21:57:27 +00:00
committed by sfan5
父節點 c26ff3476f
當前提交 9690c1b3e3
共有 56 個文件被更改,包括 3123 次插入245 次删除

查看文件

@@ -37,10 +37,10 @@ public:
if (ColorAttachment > 0)
Driver->irrGlGenFramebuffers(1, &BufferID);
AssignedTexture.set_used(static_cast<u32>(ColorAttachment));
AssignedTextures.set_used(static_cast<u32>(ColorAttachment));
for (u32 i = 0; i < AssignedTexture.size(); ++i)
AssignedTexture[i] = GL_NONE;
for (u32 i = 0; i < AssignedTextures.size(); ++i)
AssignedTextures[i] = GL_NONE;
}
virtual ~COpenGLCoreRenderTarget()
@@ -48,28 +48,28 @@ public:
if (ColorAttachment > 0 && BufferID != 0)
Driver->irrGlDeleteFramebuffers(1, &BufferID);
for (u32 i = 0; i < Texture.size(); ++i)
for (u32 i = 0; i < Textures.size(); ++i)
{
if (Texture[i])
Texture[i]->drop();
if (Textures[i])
Textures[i]->drop();
}
if (DepthStencil)
DepthStencil->drop();
}
virtual void setTexture(const core::array<ITexture*>& textures, ITexture* depthStencil, const core::array<E_CUBE_SURFACE>& cubeSurfaces) _IRR_OVERRIDE_
virtual void setTextures(ITexture* const * textures, u32 numTextures, ITexture* depthStencil, const E_CUBE_SURFACE* cubeSurfaces, u32 numCubeSurfaces) _IRR_OVERRIDE_
{
bool needSizeUpdate = false;
// Set color attachments.
if ((Texture != textures) || (CubeSurfaces != cubeSurfaces))
if (!Textures.equals(textures, numTextures) || !CubeSurfaces.equals(cubeSurfaces, numCubeSurfaces))
{
needSizeUpdate = true;
core::array<ITexture*> prevTextures(Texture);
core::array<ITexture*> prevTextures(Textures);
if (textures.size() > static_cast<u32>(ColorAttachment))
if (numTextures > static_cast<u32>(ColorAttachment))
{
core::stringc message = "This GPU supports up to ";
message += static_cast<u32>(ColorAttachment);
@@ -78,9 +78,9 @@ public:
os::Printer::log(message.c_str(), ELL_WARNING);
}
Texture.set_used(core::min_(textures.size(), static_cast<u32>(ColorAttachment)));
Textures.set_used(core::min_(numTextures, static_cast<u32>(ColorAttachment)));
for (u32 i = 0; i < Texture.size(); ++i)
for (u32 i = 0; i < Textures.size(); ++i)
{
TOpenGLTexture* currentTexture = (textures[i] && textures[i]->getDriverType() == DriverType) ? static_cast<TOpenGLTexture*>(textures[i]) : 0;
@@ -93,12 +93,12 @@ public:
if (textureID != 0)
{
Texture[i] = textures[i];
Texture[i]->grab();
Textures[i] = textures[i];
Textures[i]->grab();
}
else
{
Texture[i] = 0;
Textures[i] = 0;
}
}
@@ -111,9 +111,9 @@ public:
RequestTextureUpdate = true;
}
if (CubeSurfaces != cubeSurfaces)
if (!CubeSurfaces.equals(cubeSurfaces, numCubeSurfaces))
{
CubeSurfaces = cubeSurfaces;
CubeSurfaces.set_data(cubeSurfaces, numCubeSurfaces);
RequestTextureUpdate = true;
}
@@ -183,26 +183,26 @@ public:
{
// Set new color textures.
const u32 textureSize = core::min_(Texture.size(), AssignedTexture.size());
const u32 textureSize = core::min_(Textures.size(), AssignedTextures.size());
for (u32 i = 0; i < textureSize; ++i)
{
TOpenGLTexture* currentTexture = static_cast<TOpenGLTexture*>(Texture[i]);
TOpenGLTexture* currentTexture = static_cast<TOpenGLTexture*>(Textures[i]);
GLuint textureID = currentTexture ? currentTexture->getOpenGLTextureName() : 0;
if (textureID != 0)
{
AssignedTexture[i] = GL_COLOR_ATTACHMENT0 + i;
AssignedTextures[i] = GL_COLOR_ATTACHMENT0 + i;
GLenum textarget = currentTexture->getType() == ETT_2D ? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP_POSITIVE_X + (int)CubeSurfaces[i];
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTexture[i], textarget, textureID, 0);
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], textarget, textureID, 0);
#ifdef _DEBUG
Driver->testGLError(__LINE__);
#endif
}
else if (AssignedTexture[i] != GL_NONE)
else if (AssignedTextures[i] != GL_NONE)
{
AssignedTexture[i] = GL_NONE;
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTexture[i], GL_TEXTURE_2D, 0, 0);
AssignedTextures[i] = GL_NONE;
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], GL_TEXTURE_2D, 0, 0);
os::Printer::log("Error: Could not set render target.", ELL_ERROR);
}
@@ -210,12 +210,12 @@ public:
// Reset other render target channels.
for (u32 i = textureSize; i < AssignedTexture.size(); ++i)
for (u32 i = textureSize; i < AssignedTextures.size(); ++i)
{
if (AssignedTexture[i] != GL_NONE)
if (AssignedTextures[i] != GL_NONE)
{
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTexture[i], GL_TEXTURE_2D, 0, 0);
AssignedTexture[i] = GL_NONE;
Driver->irrGlFramebufferTexture2D(GL_FRAMEBUFFER, AssignedTextures[i], GL_TEXTURE_2D, 0, 0);
AssignedTextures[i] = GL_NONE;
}
}
@@ -285,7 +285,7 @@ public:
if (ColorAttachment > 0 && BufferID != 0)
{
const u32 textureSize = Texture.size();
const u32 textureSize = Textures.size();
if (textureSize == 0)
Driver->irrGlDrawBuffer(GL_NONE);
@@ -293,9 +293,9 @@ public:
Driver->irrGlDrawBuffer(GL_COLOR_ATTACHMENT0);
else
{
const u32 bufferCount = core::min_(MultipleRenderTarget, core::min_(textureSize, AssignedTexture.size()));
const u32 bufferCount = core::min_(MultipleRenderTarget, core::min_(textureSize, AssignedTextures.size()));
Driver->irrGlDrawBuffers(bufferCount, AssignedTexture.pointer());
Driver->irrGlDrawBuffers(bufferCount, AssignedTextures.pointer());
}
#ifdef _DEBUG
@@ -322,10 +322,10 @@ public:
ITexture* getTexture() const
{
for (u32 i = 0; i < Texture.size(); ++i)
for (u32 i = 0; i < Textures.size(); ++i)
{
if (Texture[i])
return Texture[i];
if (Textures[i])
return Textures[i];
}
return 0;
@@ -372,7 +372,7 @@ protected:
return false;
}
core::array<GLenum> AssignedTexture;
core::array<GLenum> AssignedTextures;
bool AssignedDepth;
bool AssignedStencil;