You receive the erroneous appeal to memory.
I corrected this issue for GL RenderSystem. However time to deal with others Render Systems (DX, GLES) at me isn't present, therefore created this question.
In GL render system need fix OgreGLTexture.cpp
void GLTexture::createInternalResourcesImpl(void) for 1.8.0 line 220 and 259
Code: Select all
if (depth>1 && mTextureType != TEX_TYPE_2D_ARRAY)
Code: Select all
@@ -127,23 +127,24 @@
if(mNumMipmaps>maxMips)
mNumMipmaps = maxMips;
- // Generate texture name
- glGenTextures( 1, &mTextureID );
-
+ // Generate texture object
+ glGenTextures(1, &mTextureID);
+
// Set texture type
- glBindTexture( getGLTextureTarget(), mTextureID );
+ GLenum nGlTexTarget = getGLTextureTarget();
+ glBindTexture(nGlTexTarget, mTextureID);
// This needs to be set otherwise the texture doesn't get rendered
if (GLEW_VERSION_1_2)
- glTexParameteri( getGLTextureTarget(), GL_TEXTURE_MAX_LEVEL, mNumMipmaps );
+ glTexParameteri(nGlTexTarget, GL_TEXTURE_MAX_LEVEL, mNumMipmaps);
// Set some misc default parameters so NVidia won't complain, these can of course be changed later
- glTexParameteri(getGLTextureTarget(), GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(getGLTextureTarget(), GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(nGlTexTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(nGlTexTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
if (GLEW_VERSION_1_2)
{
- glTexParameteri(getGLTextureTarget(), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(getGLTextureTarget(), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(nGlTexTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(nGlTexTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
// If we can do automip generation and the user desires this, do so
@@ -163,11 +164,8 @@
mMipmapsHardwareGenerated = false;
}
#endif
- if((mUsage & TU_AUTOMIPMAP) &&
- mNumRequestedMipmaps && mMipmapsHardwareGenerated)
- {
- glTexParameteri( getGLTextureTarget(), GL_GENERATE_MIPMAP, GL_TRUE );
- }
+ if ((mUsage & TU_AUTOMIPMAP) != 0 && mNumRequestedMipmaps && mMipmapsHardwareGenerated)
+ glTexParameteri(nGlTexTarget, GL_GENERATE_MIPMAP, GL_TRUE);
// Allocate internal buffer so that glTexSubImageXD can be used
// Internal format
@@ -176,7 +174,7 @@
size_t height = mHeight;
size_t depth = mDepth;
- if(PixelUtil::isCompressed(mFormat))
+ if (PixelUtil::isCompressed(mFormat))
{
// Compressed formats
size_t size = PixelUtil::getMemorySize(mWidth, mHeight, mDepth, mFormat);
@@ -185,83 +183,87 @@
// Run through this process for every mipmap to pregenerate mipmap piramid
uint8 *tmpdata = new uint8[size];
memset(tmpdata, 0, size);
-
- for(size_t mip=0; mip<=mNumMipmaps; mip++)
+
+ for (size_t mip = 0; mip <= mNumMipmaps; ++mip)
{
size = PixelUtil::getMemorySize(width, height, depth, mFormat);
switch(mTextureType)
{
- case TEX_TYPE_1D:
- glCompressedTexImage1DARB(GL_TEXTURE_1D, mip, format,
- width, 0,
- size, tmpdata);
- break;
- case TEX_TYPE_2D:
- glCompressedTexImage2DARB(GL_TEXTURE_2D, mip, format,
+ case TEX_TYPE_1D:
+ glCompressedTexImage1DARB(GL_TEXTURE_1D, mip, format,
+ width, 0,
+ size, tmpdata);
+ break;
+ case TEX_TYPE_2D:
+ glCompressedTexImage2DARB(GL_TEXTURE_2D, mip, format,
+ width, height, 0,
+ size, tmpdata);
+ break;
+ case TEX_TYPE_2D_ARRAY:
+ case TEX_TYPE_3D:
+ glCompressedTexImage3DARB(nGlTexTarget, mip, format,
+ width, height, depth, 0,
+ size, tmpdata);
+ break;
+ case TEX_TYPE_CUBE_MAP:
+ for (int face = 0; face < 6; ++face)
+ {
+ glCompressedTexImage2DARB(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mip, format,
width, height, 0,
size, tmpdata);
- break;
- case TEX_TYPE_2D_ARRAY:
- case TEX_TYPE_3D:
- glCompressedTexImage3DARB(getGLTextureTarget(), mip, format,
- width, height, depth, 0,
- size, tmpdata);
- break;
- case TEX_TYPE_CUBE_MAP:
- for(int face=0; face<6; face++) {
- glCompressedTexImage2DARB(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mip, format,
- width, height, 0,
- size, tmpdata);
- }
- break;
+ }
+ break;
};
- if(width>1) width = width/2;
- if(height>1) height = height/2;
- if(depth>1) depth = depth/2;
+
+ width = width > 1 ? width / 2 : width;
+ height = height > 1 ? height / 2 : height;
+ depth = depth > 1 ? (mTextureType != TEX_TYPE_2D_ARRAY ? depth / 2 : depth) : depth;
}
delete [] tmpdata;
}
else
{
// Run through this process to pregenerate mipmap pyramid
- for(size_t mip=0; mip<=mNumMipmaps; mip++)
+ for (size_t mip = 0; mip <= mNumMipmaps; ++mip)
{
// Normal formats
switch(mTextureType)
{
- case TEX_TYPE_1D:
- glTexImage1D(GL_TEXTURE_1D, mip, format,
- width, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, 0);
-
- break;
- case TEX_TYPE_2D:
- glTexImage2D(GL_TEXTURE_2D, mip, format,
+ case TEX_TYPE_1D:
+ glTexImage1D(GL_TEXTURE_1D, mip, format,
+ width, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, 0);
+
+ break;
+ case TEX_TYPE_2D:
+ glTexImage2D(GL_TEXTURE_2D, mip, format,
+ width, height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ break;
+ case TEX_TYPE_2D_ARRAY:
+ case TEX_TYPE_3D:
+ glTexImage3D(nGlTexTarget, mip, format,
+ width, height, depth, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ break;
+ case TEX_TYPE_CUBE_MAP:
+ for (int face = 0; face < 6; ++face)
+ {
+ glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mip, format,
width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0);
- break;
- case TEX_TYPE_2D_ARRAY:
- case TEX_TYPE_3D:
- glTexImage3D(getGLTextureTarget(), mip, format,
- width, height, depth, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, 0);
- break;
- case TEX_TYPE_CUBE_MAP:
- for(int face=0; face<6; face++) {
- glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, mip, format,
- width, height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, 0);
- }
- break;
+ }
+ break;
};
- if(width>1) width = width/2;
- if(height>1) height = height/2;
- if(depth>1) depth = depth/2;
+
+ width = width > 1 ? width / 2 : width;
+ height = height > 1 ? height / 2 : height;
+ depth = depth > 1 ? (mTextureType != TEX_TYPE_2D_ARRAY ? depth / 2 : depth) : depth;
}
}
+
_createSurfaceList();
- // Get final internal format
- mFormat = getBuffer(0,0)->getFormat();
+ mFormat = getBuffer(0,0)->getFormat(); // Get final internal format
}
void GLTexture::createRenderTexture(void)
@@ -394,16 +396,20 @@
// only when mipmap generation is desired.
bool doSoftware = wantGeneratedMips && !mMipmapsHardwareGenerated && getNumMipmaps();
- for(size_t face=0; face<getNumFaces(); face++)
+ GLenum nGlTexTarget = getGLTextureTarget();
+ HardwareBuffer::Usage nUsage = static_cast<HardwareBuffer::Usage>(mUsage);
+
+ for (size_t face = 0, numFaces = getNumFaces(); face < numFaces; ++face)
{
- for(size_t mip=0; mip<=getNumMipmaps(); mip++)
+ for (size_t mip = 0, numMipmaps = getNumMipmaps(); mip <= numMipmaps; ++mip)
{
- GLHardwarePixelBuffer *buf = new GLTextureBuffer(mName, getGLTextureTarget(), mTextureID, face, mip,
- static_cast<HardwareBuffer::Usage>(mUsage), doSoftware && mip==0, mHwGamma, mFSAA);
+ GLHardwarePixelBuffer *buf = new GLTextureBuffer(mName, nGlTexTarget, mTextureID, face,
+ mip, nUsage, doSoftware && mip == 0, mHwGamma, mFSAA);
+
mSurfaceList.push_back(HardwarePixelBufferSharedPtr(buf));
/// Check for error
- if(buf->getWidth()==0 || buf->getHeight()==0 || buf->getDepth()==0)
+ if (buf->getWidth() == 0 || buf->getHeight() == 0 || buf->getDepth() == 0)
{
OGRE_EXCEPT(
Exception::ERR_RENDERINGAPI_ERROR,