mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
mipmap support on DDS for openGL cubemap
This commit is contained in:
parent
5d5303cf6d
commit
0cf36a8906
1 changed files with 10 additions and 15 deletions
|
|
@ -123,24 +123,21 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
||||||
mDDSFile = ResourceManager::get().load( dds->getSourcePath() );
|
mDDSFile = ResourceManager::get().load( dds->getSourcePath() );
|
||||||
AssertFatal( mDDSFile == dds, "GFXGLCubemap::initStatic - Couldn't find DDSFile resource!" );
|
AssertFatal( mDDSFile == dds, "GFXGLCubemap::initStatic - Couldn't find DDSFile resource!" );
|
||||||
|
|
||||||
|
mWidth = dds->getWidth();
|
||||||
|
mHeight = dds->getHeight();
|
||||||
|
mFaceFormat = dds->getFormat();
|
||||||
|
mMipLevels = dds->getMipLevels();
|
||||||
|
|
||||||
glGenTextures(1, &mCubemap);
|
glGenTextures(1, &mCubemap);
|
||||||
|
|
||||||
PRESERVE_CUBEMAP_TEXTURE();
|
PRESERVE_CUBEMAP_TEXTURE();
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, mCubemap);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, 0 );
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_LEVEL, mMipLevels - 1);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
mWidth = dds->getWidth();
|
|
||||||
mHeight = dds->getHeight();
|
|
||||||
mFaceFormat = dds->getFormat();
|
|
||||||
mMipLevels = 1;
|
|
||||||
|
|
||||||
// TODO: Support mipmaps here as well as decompressing the
|
|
||||||
// DDS if the format is unsupported.
|
|
||||||
|
|
||||||
AssertFatal(mWidth == mHeight, "GFXGLCubemap::initStatic - Width and height must be equal!");
|
AssertFatal(mWidth == mHeight, "GFXGLCubemap::initStatic - Width and height must be equal!");
|
||||||
|
|
||||||
|
|
@ -151,13 +148,11 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
||||||
// TODO: The DDS can skip surfaces, but i'm unsure what i should
|
// TODO: The DDS can skip surfaces, but i'm unsure what i should
|
||||||
// do here when creating the cubemap. Ignore it for now.
|
// do here when creating the cubemap. Ignore it for now.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const U8 *buffer = dds->mSurfaces[i]->mMips[0];
|
// Now loop thru the mip levels!
|
||||||
U32 surfaceSize = dds->getSurfaceSize( mHeight, mWidth, i );
|
for (U32 j = 0; j < mMipLevels; j++)
|
||||||
|
glCompressedTexImage2D(faceList[i], j, GFXGLTextureInternalFormat[mFaceFormat], mWidth, mHeight, 0, dds->getSurfaceSize(j), dds->mSurfaces[i]->mMips[j]);
|
||||||
glCompressedTexImage2D( faceList[i], 0, GFXGLTextureInternalFormat[mFaceFormat],
|
|
||||||
mWidth, mHeight, 0, surfaceSize, buffer );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue