Switch COpenGLCoreTexture::lock to using glGetTexImage instead of glReadPixels.

Also got rid of extra temporary image. Main reason it didn't work before was likely because the image had not been set as active.
tests failing: 51,53,54 (some related to this, but none of those worked before, so no change there).
Note: Still keeping old code around a little longer as it's currently nice to have for comparison. If new stuff causes any preoblems, we could even make it optional somehow (some driver flag or so).

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5659 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2018-11-19 15:24:48 +00:00
parent c5e36eb111
commit 665324b6a8
2 changed files with 14 additions and 9 deletions

View File

@ -230,9 +230,13 @@ public:
if (LockImage && mode != ETLM_WRITE_ONLY)
{
IImage* tmpImage = Driver->createImage(ECF_A8R8G8B8, Size);
bool passed = true;
#if 1
IImage* tmpImage = LockImage; // not sure yet if the size required by glGetTexImage is always correct, if not we might have to allocate a different tmpImage and convert colors later on.
Driver->getCacheHandler()->getTextureCache().set(0, this);
#if 0 // This method doesn't work properly in some cases.
GLenum tmpTextureType = TextureType;
if (tmpTextureType == GL_TEXTURE_CUBE_MAP)
@ -242,7 +246,7 @@ public:
tmpTextureType = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
}
glGetTexImage(tmpTextureType, 0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->getData());
glGetTexImage(tmpTextureType, 0, PixelFormat, PixelType, tmpImage->getData());
if (IsRenderTarget)
{
@ -264,7 +268,7 @@ public:
delete[] tmpBuffer;
}
#else // this method does not work with cubemaps in RTT's (but works with other cubemaps)
#else // Alternative method working with copies to memory, still here for quick testing when things break, hope we can remove that before 1.9 release.
COpenGLCoreTexture* tmpTexture = new COpenGLCoreTexture("OGL_CORE_LOCK_TEXTURE", Size, ETT_2D, ColorFormat, Driver);
GLuint tmpFBO = 0;
@ -287,6 +291,7 @@ public:
Driver->draw2DImage(this, layer, true);
IImage* tmpImage = Driver->createImage(ECF_A8R8G8B8, Size);
glReadPixels(0, 0, Size.Width, Size.Height, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->getData());
Driver->getCacheHandler()->setFBO(prevFBO);
@ -294,12 +299,10 @@ public:
Driver->irrGlDeleteFramebuffers(1, &tmpFBO);
delete tmpTexture;
#endif
void* src = tmpImage->getData();
void* dest = LockImage->getData();
bool passed = true;
switch (ColorFormat)
{
case ECF_A1R5G5B5:
@ -318,8 +321,8 @@ public:
passed = false;
break;
}
tmpImage->drop();
#endif
if (!passed)
{
@ -329,6 +332,8 @@ public:
}
}
Driver->testGLError(__LINE__);
return (LockImage) ? LockImage->getData() : 0;
}

View File

@ -164,7 +164,7 @@ bool CWGLManager::initialize(const SIrrlichtCreationParameters& params, const SE
}
SetPixelFormat(HDc, PixelFormat, &pfd);
os::Printer::log("Temporary context");
os::Printer::log("Create temporary GL rendering context", ELL_DEBUG);
HGLRC hrc=wglCreateContext(HDc);
if (!hrc)
{