mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Add cubemap arrays, as well as control for generation of MIPs on texture targets.
This commit is contained in:
parent
e32a431a6c
commit
83dd55e851
25 changed files with 412 additions and 60 deletions
|
|
@ -181,7 +181,7 @@ void GFXGLCubemap::initStatic( DDSFile *dds )
|
|||
}
|
||||
}
|
||||
|
||||
void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat)
|
||||
void GFXGLCubemap::initDynamic(U32 texSize, GFXFormat faceFormat, U32 mipLevels)
|
||||
{
|
||||
mDynamicTexSize = texSize;
|
||||
mFaceFormat = faceFormat;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
virtual void initStatic( GFXTexHandle *faces );
|
||||
virtual void initStatic( DDSFile *dds );
|
||||
virtual void initDynamic( U32 texSize, GFXFormat faceFormat = GFXFormatR8G8B8A8 );
|
||||
virtual void initDynamic( U32 texSize, GFXFormat faceFormat = GFXFormatR8G8B8A8, U32 mipLevels = 0);
|
||||
virtual U32 getSize() const { return mWidth; }
|
||||
virtual GFXFormat getFormat() const { return mFaceFormat; }
|
||||
|
||||
|
|
|
|||
|
|
@ -495,6 +495,12 @@ void GFXGLDevice::clear(U32 flags, const LinearColorF& color, F32 z, U32 stencil
|
|||
glStencilMask(desc->stencilWriteMask);
|
||||
}
|
||||
|
||||
void GFXGLDevice::clearColorAttachment(const U32 attachment, const LinearColorF& color)
|
||||
{
|
||||
const GLfloat clearColor[4] = { color.red, color.green, color.blue, color.alpha };
|
||||
glClearBufferfv(GL_COLOR, attachment, clearColor);
|
||||
}
|
||||
|
||||
// Given a primitive type and a number of primitives, return the number of indexes/vertexes used.
|
||||
inline GLsizei GFXGLDevice::primCountToIndexCount(GFXPrimitiveType primType, U32 primitiveCount)
|
||||
{
|
||||
|
|
@ -749,9 +755,9 @@ void GFXGLDevice::setStateBlockInternal(GFXStateBlock* block, bool force)
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GFXTextureTarget * GFXGLDevice::allocRenderToTextureTarget()
|
||||
GFXTextureTarget * GFXGLDevice::allocRenderToTextureTarget(bool genMips)
|
||||
{
|
||||
GFXGLTextureTarget *targ = new GFXGLTextureTarget();
|
||||
GFXGLTextureTarget *targ = new GFXGLTextureTarget(genMips);
|
||||
targ->registerResourceWithDevice(this);
|
||||
return targ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ public:
|
|||
virtual U32 getTotalVideoMemory();
|
||||
|
||||
virtual GFXCubemap * createCubemap();
|
||||
virtual GFXCubemapArray *createCubemapArray() { return NULL; } //TODO: implement
|
||||
|
||||
virtual F32 getFillConventionOffset() const { return 0.0f; }
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ public:
|
|||
/// @{
|
||||
|
||||
///
|
||||
virtual GFXTextureTarget *allocRenderToTextureTarget();
|
||||
virtual GFXTextureTarget *allocRenderToTextureTarget(bool genMips = true);
|
||||
virtual GFXWindowTarget *allocWindowTarget(PlatformWindow *window);
|
||||
virtual void _updateRenderTargets();
|
||||
|
||||
|
|
@ -117,6 +118,7 @@ public:
|
|||
virtual GFXShader* createShader();
|
||||
|
||||
virtual void clear( U32 flags, const LinearColorF& color, F32 z, U32 stencil );
|
||||
virtual void clearColorAttachment(const U32 attachment, const LinearColorF& color);
|
||||
virtual bool beginSceneInternal();
|
||||
virtual void endSceneInternal();
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureInternalFormat[GFXFormatR8G8B8X8] = GL_RGBA8;
|
||||
GFXGLTextureInternalFormat[GFXFormatB8G8R8A8] = GL_RGBA8;
|
||||
GFXGLTextureInternalFormat[GFXFormatR10G10B10A2] = GL_RGB10_A2;
|
||||
GFXGLTextureInternalFormat[GFXFormatR11G11B10] = GL_R11F_G11F_B10F;
|
||||
GFXGLTextureInternalFormat[GFXFormatD32] = GL_DEPTH_COMPONENT32;
|
||||
GFXGLTextureInternalFormat[GFXFormatD24X8] = GL_DEPTH24_STENCIL8;
|
||||
GFXGLTextureInternalFormat[GFXFormatD24S8] = GL_DEPTH24_STENCIL8;
|
||||
|
|
@ -165,6 +166,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureFormat[GFXFormatR8G8B8X8] = GL_RGBA;
|
||||
GFXGLTextureFormat[GFXFormatB8G8R8A8] = GL_BGRA;
|
||||
GFXGLTextureFormat[GFXFormatR10G10B10A2] = GL_RGBA;
|
||||
GFXGLTextureFormat[GFXFormatR11G11B10] = GL_RGB;
|
||||
GFXGLTextureFormat[GFXFormatD32] = GL_DEPTH_COMPONENT;
|
||||
GFXGLTextureFormat[GFXFormatD24X8] = GL_DEPTH_STENCIL;
|
||||
GFXGLTextureFormat[GFXFormatD24S8] = GL_DEPTH_STENCIL;
|
||||
|
|
@ -192,6 +194,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLTextureType[GFXFormatR8G8B8X8] = GL_UNSIGNED_BYTE;
|
||||
GFXGLTextureType[GFXFormatB8G8R8A8] = GL_UNSIGNED_BYTE;;
|
||||
GFXGLTextureType[GFXFormatR10G10B10A2] = GL_UNSIGNED_INT_10_10_10_2;
|
||||
GFXGLTextureType[GFXFormatR11G11B10] = GL_UNSIGNED_INT_10F_11F_11F_REV;
|
||||
GFXGLTextureType[GFXFormatD32] = GL_UNSIGNED_INT;
|
||||
GFXGLTextureType[GFXFormatD24X8] = GL_UNSIGNED_INT_24_8;
|
||||
GFXGLTextureType[GFXFormatD24S8] = GL_UNSIGNED_INT_24_8;
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ class _GFXGLTextureTargetFBOImpl : public _GFXGLTextureTargetImpl
|
|||
{
|
||||
public:
|
||||
GLuint mFramebuffer;
|
||||
bool mGenMips;
|
||||
|
||||
_GFXGLTextureTargetFBOImpl(GFXGLTextureTarget* target);
|
||||
virtual ~_GFXGLTextureTargetFBOImpl();
|
||||
|
|
@ -147,6 +148,7 @@ public:
|
|||
|
||||
_GFXGLTextureTargetFBOImpl::_GFXGLTextureTargetFBOImpl(GFXGLTextureTarget* target)
|
||||
{
|
||||
mGenMips = target->isGenMipsEnabled();
|
||||
mTarget = target;
|
||||
glGenFramebuffers(1, &mFramebuffer);
|
||||
}
|
||||
|
|
@ -245,6 +247,9 @@ void _GFXGLTextureTargetFBOImpl::finish()
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
GFXGL->getOpenglCache()->setCacheBinded(GL_FRAMEBUFFER, 0);
|
||||
|
||||
if (!mGenMips)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < GFXGL->getNumRenderTargets(); ++i)
|
||||
{
|
||||
_GFXGLTargetDesc* color = mTarget->getTargetDesc( static_cast<GFXTextureTarget::RenderSlot>(GFXTextureTarget::Color0+i ) );
|
||||
|
|
@ -263,8 +268,9 @@ void _GFXGLTextureTargetFBOImpl::finish()
|
|||
}
|
||||
|
||||
// Actual GFXGLTextureTarget interface
|
||||
GFXGLTextureTarget::GFXGLTextureTarget() : mCopyFboSrc(0), mCopyFboDst(0)
|
||||
GFXGLTextureTarget::GFXGLTextureTarget(bool genMips) : mCopyFboSrc(0), mCopyFboDst(0)
|
||||
{
|
||||
mGenMips = genMips;
|
||||
for(U32 i=0; i<MaxRenderSlotId; i++)
|
||||
mTargets[i] = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class _GFXGLTextureTargetImpl;
|
|||
class GFXGLTextureTarget : public GFXTextureTarget
|
||||
{
|
||||
public:
|
||||
GFXGLTextureTarget();
|
||||
GFXGLTextureTarget(bool genMips);
|
||||
virtual ~GFXGLTextureTarget();
|
||||
|
||||
virtual const Point2I getSize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue