mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 00:05:40 +00:00
Merge remote-tracking branch 'refs/remotes/origin/development' into pr/1153
This commit is contained in:
commit
10cb6ab9c4
893 changed files with 44063 additions and 6437 deletions
|
|
@ -101,11 +101,20 @@ void GFXD3D9Cubemap::initStatic( GFXTexHandle *faces )
|
|||
mTexSize = faces[0].getWidth();
|
||||
mFaceFormat = faces[0].getFormat();
|
||||
|
||||
D3D9Assert( D3D9Device->CreateCubeTexture( mTexSize, 1, 0, GFXD3D9TextureFormat[mFaceFormat],
|
||||
U32 levels = faces->getPointer()->getMipLevels();
|
||||
if (levels >1)
|
||||
{
|
||||
D3D9Assert(D3D9Device->CreateCubeTexture(mTexSize, levels, 0, GFXD3D9TextureFormat[mFaceFormat],
|
||||
pool, &mCubeTex, NULL), NULL);
|
||||
fillCubeTextures(faces, D3D9Device);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D9Assert( D3D9Device->CreateCubeTexture( mTexSize, 0, D3DUSAGE_AUTOGENMIPMAP, GFXD3D9TextureFormat[mFaceFormat],
|
||||
pool, &mCubeTex, NULL ), NULL );
|
||||
|
||||
fillCubeTextures( faces, D3D9Device );
|
||||
// mCubeTex->GenerateMipSubLevels();
|
||||
fillCubeTextures( faces, D3D9Device );
|
||||
mCubeTex->GenerateMipSubLevels();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,24 +204,29 @@ void GFXD3D9Cubemap::initDynamic( U32 texSize, GFXFormat faceFormat )
|
|||
//-----------------------------------------------------------------------------
|
||||
// Fills in face textures of cube map from existing textures
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFXD3D9Cubemap::fillCubeTextures( GFXTexHandle *faces, LPDIRECT3DDEVICE9 D3DDevice )
|
||||
void GFXD3D9Cubemap::fillCubeTextures( GFXTexHandle *faces, LPDIRECT3DDEVICE9 D3DDevice)
|
||||
{
|
||||
for( U32 i=0; i<6; i++ )
|
||||
{
|
||||
// get cube face surface
|
||||
IDirect3DSurface9 *cubeSurf = NULL;
|
||||
D3D9Assert( mCubeTex->GetCubeMapSurface( faceList[i], 0, &cubeSurf ), NULL );
|
||||
|
||||
// get incoming texture surface
|
||||
GFXD3D9TextureObject *texObj = dynamic_cast<GFXD3D9TextureObject*>( (GFXTextureObject*)faces[i] );
|
||||
IDirect3DSurface9 *inSurf;
|
||||
D3D9Assert( texObj->get2DTex()->GetSurfaceLevel( 0, &inSurf ), NULL );
|
||||
|
||||
// copy incoming texture into cube face
|
||||
D3D9Assert( GFXD3DX.D3DXLoadSurfaceFromSurface( cubeSurf, NULL, NULL, inSurf, NULL,
|
||||
NULL, D3DX_FILTER_NONE, 0 ), NULL );
|
||||
cubeSurf->Release();
|
||||
inSurf->Release();
|
||||
U32 levels = faces->getPointer()->getMipLevels();
|
||||
for (U32 mip = 0; mip < levels; mip++)
|
||||
{
|
||||
for (U32 i = 0; i < 6; i++)
|
||||
{
|
||||
// get cube face surface
|
||||
IDirect3DSurface9 *cubeSurf = NULL;
|
||||
D3D9Assert(mCubeTex->GetCubeMapSurface(faceList[i], mip, &cubeSurf), NULL);
|
||||
|
||||
// get incoming texture surface
|
||||
GFXD3D9TextureObject *texObj = dynamic_cast<GFXD3D9TextureObject*>((GFXTextureObject*)faces[i]);
|
||||
IDirect3DSurface9 *inSurf;
|
||||
D3D9Assert(texObj->get2DTex()->GetSurfaceLevel(mip, &inSurf), NULL);
|
||||
|
||||
// copy incoming texture into cube face
|
||||
D3D9Assert(GFXD3DX.D3DXLoadSurfaceFromSurface(cubeSurf, NULL, NULL, inSurf, NULL,
|
||||
NULL, D3DX_FILTER_NONE, 0), NULL);
|
||||
cubeSurf->Release();
|
||||
inSurf->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -695,9 +695,9 @@ GFXShader* GFXD3D9Device::createShader()
|
|||
return shader;
|
||||
}
|
||||
|
||||
void GFXD3D9Device::disableShaders()
|
||||
void GFXD3D9Device::disableShaders(bool force)
|
||||
{
|
||||
setShader( NULL );
|
||||
setShader( NULL, force );
|
||||
setShaderConstBuffer( NULL );
|
||||
}
|
||||
|
||||
|
|
@ -706,25 +706,24 @@ void GFXD3D9Device::disableShaders()
|
|||
// and to make sure redundant shader states are not being
|
||||
// sent to the card.
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFXD3D9Device::setShader( GFXShader *shader )
|
||||
void GFXD3D9Device::setShader( GFXShader *shader, bool force )
|
||||
{
|
||||
GFXD3D9Shader *d3dShader = static_cast<GFXD3D9Shader*>( shader );
|
||||
|
||||
IDirect3DPixelShader9 *pixShader = ( d3dShader != NULL ? d3dShader->mPixShader : NULL );
|
||||
IDirect3DVertexShader9 *vertShader = ( d3dShader ? d3dShader->mVertShader : NULL );
|
||||
|
||||
if( pixShader != mLastPixShader )
|
||||
if( pixShader != mLastPixShader || force )
|
||||
{
|
||||
mD3DDevice->SetPixelShader( pixShader );
|
||||
mLastPixShader = pixShader;
|
||||
}
|
||||
|
||||
if( vertShader != mLastVertShader )
|
||||
if( vertShader != mLastVertShader || force )
|
||||
{
|
||||
mD3DDevice->SetVertexShader( vertShader );
|
||||
mLastVertShader = vertShader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -732,7 +731,8 @@ void GFXD3D9Device::setShader( GFXShader *shader )
|
|||
//-----------------------------------------------------------------------------
|
||||
GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data )
|
||||
{
|
||||
// Allocate a buffer to return
|
||||
GFXD3D9PrimitiveBuffer * res = new GFXD3D9PrimitiveBuffer(this, numIndices, numPrimitives, bufferType);
|
||||
|
|
@ -742,12 +742,13 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
D3DPOOL pool = D3DPOOL_DEFAULT;
|
||||
|
||||
// Assumptions:
|
||||
// - static buffers are write once, use many
|
||||
// - static buffers are write rarely, use many
|
||||
// - dynamic buffers are write many, use many
|
||||
// - volatile buffers are write once, use once
|
||||
// You may never read from a buffer.
|
||||
switch(bufferType)
|
||||
{
|
||||
case GFXBufferTypeImmutable:
|
||||
case GFXBufferTypeStatic:
|
||||
pool = isD3D9Ex() ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
|
||||
break;
|
||||
|
|
@ -782,6 +783,14 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
D3D9Assert(mD3DDevice->CreateIndexBuffer( sizeof(U16) * numIndices , usage, GFXD3D9IndexFormat[GFXIndexFormat16], pool, &res->ib, 0),
|
||||
"Failed to allocate an index buffer.");
|
||||
}
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
res->lock(0, numIndices, &dest);
|
||||
dMemcpy(dest, data, sizeof(U16) * numIndices);
|
||||
res->unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -792,7 +801,8 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data)
|
||||
{
|
||||
PROFILE_SCOPE( GFXD3D9Device_allocVertexBuffer );
|
||||
|
||||
|
|
@ -809,7 +819,7 @@ GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
|||
res->mNumVerts = 0;
|
||||
|
||||
// Assumptions:
|
||||
// - static buffers are write once, use many
|
||||
// - static buffers are write rarely, use many
|
||||
// - dynamic buffers are write many, use many
|
||||
// - volatile buffers are write once, use once
|
||||
// You may never read from a buffer.
|
||||
|
|
@ -851,6 +861,15 @@ GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
|||
}
|
||||
|
||||
res->mNumVerts = numVerts;
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
res->lock(0, numVerts, &dest);
|
||||
dMemcpy(dest, data, vertSize * numVerts);
|
||||
res->unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ inline void D3D9Assert( HRESULT hr, const char *info )
|
|||
|
||||
// Typedefs
|
||||
#define D3DX_FUNCTION(fn_name, fn_return, fn_args) \
|
||||
typedef fn_return (WINAPI *D3DXFNPTR##fn_name##)##fn_args##;
|
||||
typedef fn_return (WINAPI *D3DXFNPTR##fn_name)fn_args;
|
||||
#include "gfx/D3D9/d3dx9Functions.h"
|
||||
#undef D3DX_FUNCTION
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ protected:
|
|||
// }
|
||||
|
||||
virtual GFXShader* createShader();
|
||||
void disableShaders();
|
||||
void disableShaders(bool force = false);
|
||||
|
||||
/// Device helper function
|
||||
virtual D3DPRESENT_PARAMETERS setupPresentParams( const GFXVideoMode &mode, const HWND &hwnd ) const = 0;
|
||||
|
|
@ -272,7 +272,7 @@ public:
|
|||
|
||||
virtual F32 getPixelShaderVersion() const { return mPixVersion; }
|
||||
virtual void setPixelShaderVersion( F32 version ){ mPixVersion = version; }
|
||||
virtual void setShader( GFXShader *shader );
|
||||
virtual void setShader( GFXShader *shader, bool force = false );
|
||||
virtual U32 getNumSamplers() const { return mNumSamplers; }
|
||||
virtual U32 getNumRenderTargets() const { return mNumRenderTargets; }
|
||||
// }
|
||||
|
|
@ -298,10 +298,12 @@ public:
|
|||
virtual GFXVertexBuffer* allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType );
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL );
|
||||
virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType );
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL );
|
||||
virtual void deallocVertexBuffer( GFXD3D9VertexBuffer *vertBuff );
|
||||
virtual GFXVertexDecl* allocVertexDecl( const GFXVertexFormat *vertexFormat );
|
||||
virtual void setVertexDecl( const GFXVertexDecl *decl );
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ extern _D3DDECLTYPE GFXD3D9DeclType[GFXDeclType_COUNT];
|
|||
|
||||
#define GFXREVERSE_LOOKUP( tablearray, enumprefix, val ) \
|
||||
for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
|
||||
if( (S32)tablearray##[i] == val ) \
|
||||
if( (S32)tablearray[i] == val ) \
|
||||
{ \
|
||||
val = i; \
|
||||
break; \
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ _D3DDECLTYPE GFXD3D9DeclType[GFXDeclType_COUNT];
|
|||
|
||||
#define INIT_LOOKUPTABLE( tablearray, enumprefix, type ) \
|
||||
for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
|
||||
tablearray##[i] = (##type##)GFX_UNINIT_VAL;
|
||||
tablearray[i] = (type)GFX_UNINIT_VAL;
|
||||
|
||||
#define VALIDATE_LOOKUPTABLE( tablearray, enumprefix ) \
|
||||
for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
|
||||
if( (S32)tablearray##[i] == GFX_UNINIT_VAL ) \
|
||||
if( (S32)tablearray[i] == GFX_UNINIT_VAL ) \
|
||||
Con::warnf( "GFXD3D9EnumTranslate: Unassigned value in " #tablearray ": %i", i ); \
|
||||
else if( (S32)tablearray##[i] == GFX_UNSUPPORTED_VAL ) \
|
||||
else if( (S32)tablearray[i] == GFX_UNSUPPORTED_VAL ) \
|
||||
Con::warnf( "GFXD3D9EnumTranslate: Unsupported value in " #tablearray ": %i", i );
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ void GFXD3D9PrimitiveBuffer::lock(U32 indexStart, U32 indexEnd, void **indexPtr)
|
|||
U32 flags=0;
|
||||
switch(mBufferType)
|
||||
{
|
||||
case GFXBufferTypeImmutable:
|
||||
case GFXBufferTypeStatic:
|
||||
// flags |= D3DLOCK_DISCARD;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void GFXPCD3D9Device::createDirect3D9(LPDIRECT3D9 &d3d9, LPDIRECT3D9EX &d3d9ex)
|
|||
|
||||
if (pfnCreate9Ex)
|
||||
{
|
||||
if (!FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)) && d3d9ex)
|
||||
if (d3d9ex && !FAILED(pfnCreate9Ex(D3D_SDK_VERSION, &d3d9ex)))
|
||||
d3d9ex->QueryInterface(__uuidof(IDirect3D9), reinterpret_cast<void **>(&d3d9));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -276,14 +276,16 @@ GFXNullDevice::~GFXNullDevice()
|
|||
GFXVertexBuffer *GFXNullDevice::allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data )
|
||||
{
|
||||
return new GFXNullVertexBuffer(GFX, numVerts, vertexFormat, vertSize, bufferType);
|
||||
}
|
||||
|
||||
GFXPrimitiveBuffer *GFXNullDevice::allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType)
|
||||
GFXBufferType bufferType,
|
||||
void* data )
|
||||
{
|
||||
return new GFXNullPrimitiveBuffer(GFX, numIndices, numPrimitives, bufferType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,10 +115,12 @@ protected:
|
|||
virtual GFXVertexBuffer *allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType );
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL );
|
||||
virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType );
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL );
|
||||
|
||||
virtual GFXVertexDecl* allocVertexDecl( const GFXVertexFormat *vertexFormat ) { return NULL; }
|
||||
virtual void setVertexDecl( const GFXVertexDecl *decl ) { }
|
||||
|
|
|
|||
|
|
@ -606,8 +606,6 @@ bool DDSFile::read(Stream &s, U32 dropMipCount)
|
|||
mPitchOrLinearSize = getSurfaceSize( dropMipCount );
|
||||
else if ( mFlags.test( PitchSizeFlag ) )
|
||||
mPitchOrLinearSize = getSurfacePitch( dropMipCount );
|
||||
else
|
||||
mPitchOrLinearSize = mPitchOrLinearSize; // Do nothing?
|
||||
|
||||
// Now fix up the rest of the
|
||||
mMipMapCount = getMax( (U32)1, mMipMapCount - dropMipCount );
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ void GBitmap::allocateBitmap(const U32 in_width, const U32 in_height, const bool
|
|||
|
||||
mNumMipLevels++;
|
||||
allocPixels += currWidth * currHeight * mBytesPerPixel;
|
||||
} while (currWidth != 1 || currHeight != 1);
|
||||
} while (currWidth != 1 && currHeight != 1);
|
||||
}
|
||||
AssertFatal(mNumMipLevels <= c_maxMipLevels, "GBitmap::allocateBitmap: too many miplevels");
|
||||
|
||||
|
|
|
|||
|
|
@ -568,6 +568,7 @@ void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOff
|
|||
|
||||
for (U32 i = 0; i < len;)
|
||||
{
|
||||
U32 wide = 0;
|
||||
startLine = i;
|
||||
startLineOffset.push_back(startLine);
|
||||
|
||||
|
|
@ -584,6 +585,10 @@ void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOff
|
|||
else if(isValidChar(txt[i]))
|
||||
{
|
||||
lineStrWidth += getCharInfo(txt[i]).xIncrement;
|
||||
if(txt[i] < 0) // symbols which code > 127
|
||||
{
|
||||
wide++; i++;
|
||||
}
|
||||
if( lineStrWidth > lineWidth )
|
||||
{
|
||||
needsNewLine = true;
|
||||
|
|
@ -595,7 +600,7 @@ void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOff
|
|||
if (!needsNewLine)
|
||||
{
|
||||
// we are done!
|
||||
lineLen.push_back(i - startLine);
|
||||
lineLen.push_back(i - startLine - wide);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -628,7 +633,7 @@ void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOff
|
|||
}
|
||||
}
|
||||
|
||||
lineLen.push_back(j - startLine);
|
||||
lineLen.push_back(j - startLine - wide);
|
||||
i = j;
|
||||
|
||||
// Now we need to increment through any space characters at the
|
||||
|
|
@ -918,17 +923,18 @@ void GFont::importStrip(const char *fileName, U32 padding, U32 kerning)
|
|||
|
||||
// Allocate a new bitmap for this glyph, taking into account kerning and padding.
|
||||
glyphList.increment();
|
||||
glyphList.last().bitmap = new GBitmap(mCharInfoList[i].width + kerning + 2*padding, mCharInfoList[i].height + 2*padding, false, strip->getFormat());
|
||||
glyphList.last().charId = i;
|
||||
GlyphMap& lastGlyphMap = glyphList.last();
|
||||
lastGlyphMap.bitmap = new GBitmap(mCharInfoList[i].width + kerning + 2 * padding, mCharInfoList[i].height + 2 * padding, false, strip->getFormat());
|
||||
lastGlyphMap.charId = i;
|
||||
|
||||
// Copy the rect.
|
||||
RectI ri(curWidth, getBaseline() - mCharInfoList[i].yOrigin, glyphList.last().bitmap->getWidth(), glyphList.last().bitmap->getHeight());
|
||||
RectI ri(curWidth, getBaseline() - mCharInfoList[i].yOrigin, lastGlyphMap.bitmap->getWidth(), lastGlyphMap.bitmap->getHeight());
|
||||
Point2I outRi(0,0);
|
||||
glyphList.last().bitmap->copyRect(strip, ri, outRi);
|
||||
lastGlyphMap.bitmap->copyRect(strip, ri, outRi);
|
||||
|
||||
// Update glyph attributes.
|
||||
mCharInfoList[i].width = glyphList.last().bitmap->getWidth();
|
||||
mCharInfoList[i].height = glyphList.last().bitmap->getHeight();
|
||||
mCharInfoList[i].width = lastGlyphMap.bitmap->getWidth();
|
||||
mCharInfoList[i].height = lastGlyphMap.bitmap->getHeight();
|
||||
mCharInfoList[i].xOffset -= kerning + padding;
|
||||
mCharInfoList[i].xIncrement += kerning;
|
||||
mCharInfoList[i].yOffset -= padding;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ GFXDevice::GFXDevice()
|
|||
mGlobalAmbientColor = ColorF(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
mLightMaterialDirty = false;
|
||||
dMemset(&mCurrentLightMaterial, NULL, sizeof(GFXLightMaterial));
|
||||
dMemset(&mCurrentLightMaterial, 0, sizeof(GFXLightMaterial));
|
||||
|
||||
// State block
|
||||
mStateBlockDirty = false;
|
||||
|
|
@ -161,7 +161,6 @@ GFXDevice::GFXDevice()
|
|||
mAllowRender = true;
|
||||
mCurrentRenderStyle = RS_Standard;
|
||||
mCurrentProjectionOffset = Point2F::Zero;
|
||||
mStereoEyeOffset = Point3F::Zero;
|
||||
mCanCurrentlyRender = false;
|
||||
mInitialized = false;
|
||||
|
||||
|
|
@ -197,6 +196,9 @@ GFXDevice::GFXDevice()
|
|||
#elif defined TORQUE_OS_PS3
|
||||
GFXShader::addGlobalMacro( "TORQUE_OS_PS3" );
|
||||
#endif
|
||||
|
||||
mStereoTargets[0] = NULL;
|
||||
mStereoTargets[1] = NULL;
|
||||
}
|
||||
|
||||
GFXDrawUtil* GFXDevice::getDrawUtil()
|
||||
|
|
@ -733,14 +735,14 @@ void GFXDevice::setLight(U32 stage, GFXLightInfo* light)
|
|||
//-----------------------------------------------------------------------------
|
||||
// Set Light Material
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFXDevice::setLightMaterial(GFXLightMaterial mat)
|
||||
void GFXDevice::setLightMaterial(const GFXLightMaterial& mat)
|
||||
{
|
||||
mCurrentLightMaterial = mat;
|
||||
mLightMaterialDirty = true;
|
||||
mStateDirty = true;
|
||||
}
|
||||
|
||||
void GFXDevice::setGlobalAmbientColor(ColorF color)
|
||||
void GFXDevice::setGlobalAmbientColor(const ColorF& color)
|
||||
{
|
||||
if(mGlobalAmbientColor != color)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,6 +213,9 @@ public:
|
|||
/// The device is about to finish rendering a frame
|
||||
deEndOfFrame,
|
||||
|
||||
/// The device has rendered a frame and ended the scene
|
||||
dePostFrame,
|
||||
|
||||
/// The device has started rendering a frame's field (such as for side-by-side rendering)
|
||||
deStartOfField,
|
||||
|
||||
|
|
@ -244,7 +247,12 @@ public:
|
|||
enum GFXDeviceRenderStyles
|
||||
{
|
||||
RS_Standard = 0,
|
||||
RS_StereoSideBySide = (1<<0),
|
||||
RS_StereoSideBySide = (1<<0), // Render into current Render Target side-by-side
|
||||
};
|
||||
|
||||
enum GFXDeviceLimits
|
||||
{
|
||||
NumStereoPorts = 2
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
@ -277,7 +285,19 @@ protected:
|
|||
Point2F mCurrentProjectionOffset;
|
||||
|
||||
/// Eye offset used when using a stereo rendering style
|
||||
Point3F mStereoEyeOffset;
|
||||
Point3F mStereoEyeOffset[NumStereoPorts];
|
||||
|
||||
MatrixF mStereoEyeTransforms[NumStereoPorts];
|
||||
MatrixF mInverseStereoEyeTransforms[NumStereoPorts];
|
||||
|
||||
/// Fov port settings
|
||||
FovPort mFovPorts[NumStereoPorts];
|
||||
|
||||
/// Destination viewports for stereo rendering
|
||||
RectI mStereoViewports[NumStereoPorts];
|
||||
|
||||
/// Destination targets for stereo rendering
|
||||
GFXTextureTarget* mStereoTargets[NumStereoPorts];
|
||||
|
||||
/// This will allow querying to see if a device is initialized and ready to
|
||||
/// have operations performed on it.
|
||||
|
|
@ -323,10 +343,50 @@ public:
|
|||
void setCurrentProjectionOffset(const Point2F& offset) { mCurrentProjectionOffset = offset; }
|
||||
|
||||
/// Get the current eye offset used during stereo rendering
|
||||
const Point3F& getStereoEyeOffset() { return mStereoEyeOffset; }
|
||||
const Point3F* getStereoEyeOffsets() { return mStereoEyeOffset; }
|
||||
|
||||
const MatrixF* getStereoEyeTransforms() { return mStereoEyeTransforms; }
|
||||
const MatrixF* getInverseStereoEyeTransforms() { return mInverseStereoEyeTransforms; }
|
||||
|
||||
/// Set the current eye offset used during stereo rendering
|
||||
void setStereoEyeOffset(const Point3F& offset) { mStereoEyeOffset = offset; }
|
||||
void setStereoEyeOffsets(Point3F *offsets) { dMemcpy(mStereoEyeOffset, offsets, sizeof(Point3F) * NumStereoPorts); }
|
||||
|
||||
void setStereoEyeTransforms(MatrixF *transforms) { dMemcpy(mStereoEyeTransforms, transforms, sizeof(mStereoEyeTransforms)); dMemcpy(mInverseStereoEyeTransforms, transforms, sizeof(mInverseStereoEyeTransforms)); mInverseStereoEyeTransforms[0].inverse(); mInverseStereoEyeTransforms[1].inverse(); }
|
||||
|
||||
/// Set the current eye offset used during stereo rendering. Assumes NumStereoPorts are available.
|
||||
void setStereoFovPort(const FovPort *ports) { dMemcpy(mFovPorts, ports, sizeof(mFovPorts)); }
|
||||
|
||||
/// Get the current eye offset used during stereo rendering
|
||||
const FovPort* getStereoFovPort() { return mFovPorts; }
|
||||
|
||||
/// Sets stereo viewports
|
||||
void setSteroViewports(const RectI *ports) { dMemcpy(mStereoViewports, ports, sizeof(RectI) * NumStereoPorts); }
|
||||
|
||||
/// Sets stereo render targets
|
||||
void setStereoTargets(GFXTextureTarget **targets) { mStereoTargets[0] = targets[0]; mStereoTargets[1] = targets[1]; }
|
||||
|
||||
RectI* getStereoViewports() { return mStereoViewports; }
|
||||
|
||||
/// Activates a stereo render target, setting the correct viewport to render eye contents.
|
||||
/// If eyeId is -1, set a viewport encompassing the entire size of the render targets.
|
||||
void activateStereoTarget(S32 eyeId)
|
||||
{
|
||||
if (eyeId == -1)
|
||||
{
|
||||
if (mStereoTargets[0])
|
||||
{
|
||||
setActiveRenderTarget(mStereoTargets[0], true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mStereoTargets[eyeId])
|
||||
{
|
||||
setActiveRenderTarget(mStereoTargets[eyeId], false);
|
||||
}
|
||||
setViewport(mStereoViewports[eyeId]);
|
||||
}
|
||||
}
|
||||
|
||||
GFXCardProfiler* getCardProfiler() const { return mCardProfiler; }
|
||||
|
||||
|
|
@ -577,7 +637,8 @@ protected:
|
|||
virtual GFXVertexBuffer *allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType ) = 0;
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL ) = 0;
|
||||
|
||||
/// Called from GFXVertexFormat to allocate the hardware
|
||||
/// specific vertex declaration for rendering.
|
||||
|
|
@ -614,7 +675,8 @@ protected:
|
|||
/// @note All index buffers use unsigned 16-bit indices.
|
||||
virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType ) = 0;
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL ) = 0;
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
@ -722,8 +784,8 @@ public:
|
|||
/// Returns the number of simultaneous render targets supported by the device.
|
||||
virtual U32 getNumRenderTargets() const = 0;
|
||||
|
||||
virtual void setShader( GFXShader *shader ) {}
|
||||
virtual void disableShaders() {} // TODO Remove when T3D 4.0
|
||||
virtual void setShader( GFXShader *shader, bool force = false ) {}
|
||||
virtual void disableShaders( bool force = false ) {} // TODO Remove when T3D 4.0
|
||||
|
||||
/// Set the buffer! (Actual set happens on the next draw call, just like textures, state blocks, etc)
|
||||
void setShaderConstBuffer(GFXShaderConstBuffer* buffer);
|
||||
|
|
@ -841,8 +903,8 @@ public:
|
|||
/// because of the state caching stuff.
|
||||
/// @{
|
||||
void setLight(U32 stage, GFXLightInfo* light);
|
||||
void setLightMaterial(GFXLightMaterial mat);
|
||||
void setGlobalAmbientColor(ColorF color);
|
||||
void setLightMaterial(const GFXLightMaterial& mat);
|
||||
void setGlobalAmbientColor(const ColorF& color);
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
|
|||
|
|
@ -526,10 +526,10 @@ void GFXDrawUtil::drawRectFill( const Point2F &upperLeft, const Point2F &lowerRi
|
|||
|
||||
F32 ulOffset = 0.5f - mDevice->getFillConventionOffset();
|
||||
|
||||
verts[0].point.set( upperLeft.x+nw.x+ulOffset, upperLeft.y+nw.y+ulOffset, 0.0f );
|
||||
verts[1].point.set( lowerRight.x+ne.x, upperLeft.y+ne.y+ulOffset, 0.0f );
|
||||
verts[2].point.set( upperLeft.x-ne.x+ulOffset, lowerRight.y-ne.y, 0.0f );
|
||||
verts[3].point.set( lowerRight.x-nw.x, lowerRight.y-nw.y, 0.0f );
|
||||
verts[0].point.set( upperLeft.x + nw.x + ulOffset, upperLeft.y + nw.y + ulOffset, 0.0f);
|
||||
verts[1].point.set( lowerRight.x + ne.x + ulOffset, upperLeft.y + ne.y + ulOffset, 0.0f);
|
||||
verts[2].point.set( upperLeft.x - ne.x + ulOffset, lowerRight.y - ne.y + ulOffset, 0.0f);
|
||||
verts[3].point.set( lowerRight.x - nw.x + ulOffset, lowerRight.y - nw.y + ulOffset, 0.0f);
|
||||
|
||||
for (S32 i=0; i<4; i++)
|
||||
verts[i].color = color;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
enum GFXBufferType
|
||||
{
|
||||
GFXBufferTypeStatic, ///< Static vertex buffers are created and filled one time.
|
||||
///< incur a performance penalty. Resizing a static vertex buffer is not
|
||||
GFXBufferTypeStatic, ///< Static vertex buffers are created and rarely updated.
|
||||
///< Updating might incur a performance penalty. Resizing a static vertex buffer is not
|
||||
///< allowed.
|
||||
GFXBufferTypeDynamic, ///< Dynamic vertex buffers are meant for vertices that can be changed
|
||||
///< often. Vertices written into dynamic vertex buffers will remain valid
|
||||
|
|
@ -48,7 +48,8 @@ enum GFXBufferType
|
|||
///< allowed.
|
||||
GFXBufferTypeVolatile, ///< Volatile vertex or index buffers are meant for vertices or indices that are essentially
|
||||
///< only used once. They can be resized without any performance penalty.
|
||||
|
||||
GFXBufferTypeImmutable, ///< Immutable buffers must specify the data when creating the buffer. Cannot be modified.
|
||||
|
||||
GFXBufferType_COUNT ///< Number of buffer types.
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -80,3 +80,16 @@ void GFXPrimitiveBufferHandle::set(GFXDevice *theDevice, U32 indexCount, U32 pri
|
|||
getPointer()->mDebugCreationPath = desc;
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// immutable
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFXPrimitiveBufferHandle::immutable(GFXDevice *theDevice, U32 indexCount, U32 primitiveCount, void* data, String desc)
|
||||
{
|
||||
StrongRefPtr<GFXPrimitiveBuffer>::operator=( theDevice->allocPrimitiveBuffer(indexCount, primitiveCount, GFXBufferTypeImmutable, data) );
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
if( desc.isNotEmpty() )
|
||||
getPointer()->mDebugCreationPath = desc;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ public:
|
|||
}
|
||||
|
||||
void set(GFXDevice *theDevice, U32 indexCount, U32 primitiveCount, GFXBufferType bufferType, String desc = String::EmptyString );
|
||||
|
||||
void immutable(GFXDevice *theDevice, U32 indexCount, U32 primitiveCount, void* data, String desc = String::EmptyString );
|
||||
|
||||
void lock(U16 **indexBuffer, GFXPrimitive **primitiveBuffer = NULL, U32 indexStart = 0, U32 indexEnd = 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ void GFXStringEnumTranslate::init()
|
|||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8A8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8X8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatB8G8R8A8 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32F );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR5G6B5 );
|
||||
GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR5G5B5A1 );
|
||||
|
|
|
|||
|
|
@ -192,13 +192,13 @@ void GFXTextureManager::cleanupPool()
|
|||
// This texture is unreferenced, so take the time
|
||||
// now to completely remove it from the pool.
|
||||
TexturePoolMap::Iterator unref = iter;
|
||||
iter++;
|
||||
++iter;
|
||||
unref->value = NULL;
|
||||
mTexturePool.erase( unref );
|
||||
continue;
|
||||
}
|
||||
|
||||
iter++;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1041,7 +1041,8 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
|
|||
}
|
||||
|
||||
// inOutFormat is not modified by this method
|
||||
bool chekFmt = GFX->getCardProfiler()->checkFormat( testingFormat, profile, autoGenSupp );
|
||||
GFXCardProfiler* cardProfiler = GFX->getCardProfiler();
|
||||
bool chekFmt = cardProfiler->checkFormat(testingFormat, profile, autoGenSupp);
|
||||
|
||||
if( !chekFmt )
|
||||
{
|
||||
|
|
@ -1057,16 +1058,16 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
|
|||
{
|
||||
case GFXFormatR8G8B8:
|
||||
testingFormat = GFXFormatR8G8B8X8;
|
||||
chekFmt = GFX->getCardProfiler()->checkFormat( testingFormat, profile, autoGenSupp );
|
||||
chekFmt = cardProfiler->checkFormat(testingFormat, profile, autoGenSupp);
|
||||
break;
|
||||
|
||||
case GFXFormatA8:
|
||||
testingFormat = GFXFormatR8G8B8A8;
|
||||
chekFmt = GFX->getCardProfiler()->checkFormat( testingFormat, profile, autoGenSupp );
|
||||
chekFmt = cardProfiler->checkFormat(testingFormat, profile, autoGenSupp);
|
||||
break;
|
||||
|
||||
default:
|
||||
chekFmt = GFX->getCardProfiler()->checkFormat( testingFormat, profile, autoGenSupp );
|
||||
chekFmt = cardProfiler->checkFormat(testingFormat, profile, autoGenSupp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1098,7 +1099,7 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
|
|||
currHeight = 1;
|
||||
|
||||
inOutNumMips++;
|
||||
} while ( currWidth != 1 || currHeight != 1 );
|
||||
} while ( currWidth != 1 && currHeight != 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ public:
|
|||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertexSize,
|
||||
GFXBufferType bufferType )
|
||||
: mDevice( device ),
|
||||
mVolatileStart( 0 ),
|
||||
mNumVerts( numVerts ),
|
||||
: mNumVerts( numVerts ),
|
||||
mVertexSize( vertexSize ),
|
||||
mBufferType( bufferType )
|
||||
mBufferType( bufferType ),
|
||||
mDevice( device ),
|
||||
mVolatileStart( 0 )
|
||||
{
|
||||
if ( vertexFormat )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -114,10 +114,11 @@ void GFXVertexFormat::addElement( const String& semantic, GFXDeclType type, U32
|
|||
{
|
||||
mDirty = true;
|
||||
mElements.increment();
|
||||
mElements.last().mStreamIndex = stream;
|
||||
mElements.last().mSemantic = semantic.intern();
|
||||
mElements.last().mSemanticIndex = index;
|
||||
mElements.last().mType = type;
|
||||
GFXVertexElement& lastElement = mElements.last();
|
||||
lastElement.mStreamIndex = stream;
|
||||
lastElement.mSemantic = semantic.intern();
|
||||
lastElement.mSemanticIndex = index;
|
||||
lastElement.mType = type;
|
||||
}
|
||||
|
||||
const String& GFXVertexFormat::getDescription() const
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ public:
|
|||
|
||||
~GLFenceRange()
|
||||
{
|
||||
AssertFatal( mSync == 0, "");
|
||||
//the order of creation/destruction of static variables is indetermined... depends on detail of the build
|
||||
//looks like for some reason on windows + sdl + opengl the order make invalid / wrong the process TODO: Refactor -LAR
|
||||
//AssertFatal( mSync == 0, "");
|
||||
}
|
||||
|
||||
void init(U32 start, U32 end)
|
||||
|
|
@ -87,7 +89,9 @@ public:
|
|||
|
||||
~GLOrderedFenceRangeManager( )
|
||||
{
|
||||
waitAllRanges( );
|
||||
//the order of creation/destruction of static variables is indetermined... depends on detail of the build
|
||||
//looks like for some reason on windows + sdl + opengl the order make invalid / wrong the process TODO: Refactor -LAR
|
||||
//waitAllRanges( );
|
||||
}
|
||||
|
||||
void protectOrderedRange( U32 start, U32 end )
|
||||
|
|
@ -139,6 +143,11 @@ public:
|
|||
init();
|
||||
}
|
||||
|
||||
~GLCircularVolatileBuffer()
|
||||
{
|
||||
glDeleteBuffers(1, &mBufferName);
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
glGenBuffers(1, &mBufferName);
|
||||
|
|
@ -286,4 +295,4 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -82,20 +82,25 @@ void loadGLExtensions(void *context)
|
|||
}
|
||||
|
||||
void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id,
|
||||
GLenum severity, GLsizei length, const GLchar* message, void* userParam)
|
||||
GLenum severity, GLsizei length, const GLchar* message, void* userParam)
|
||||
{
|
||||
#if defined(TORQUE_DEBUG) && !defined(TORQUE_DEBUG_GFX)
|
||||
if( type == GL_DEBUG_TYPE_OTHER_ARB )
|
||||
return;
|
||||
#endif
|
||||
|
||||
Con::errorf("OPENGL: %s", message);
|
||||
if (severity == GL_DEBUG_SEVERITY_HIGH)
|
||||
Con::errorf("OPENGL: %s", message);
|
||||
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
|
||||
Con::warnf("OPENGL: %s", message);
|
||||
else if (severity == GL_DEBUG_SEVERITY_LOW)
|
||||
Con::printf("OPENGL: %s", message);
|
||||
}
|
||||
|
||||
void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLsizei length,
|
||||
const GLchar* message,GLvoid* userParam)
|
||||
const GLchar* message, GLvoid* userParam)
|
||||
{
|
||||
Con::errorf("OPENGL: %s",message);
|
||||
if (severity == GL_DEBUG_SEVERITY_HIGH)
|
||||
Con::errorf("AMDOPENGL: %s", message);
|
||||
else if (severity == GL_DEBUG_SEVERITY_MEDIUM)
|
||||
Con::warnf("AMDOPENGL: %s", message);
|
||||
else if (severity == GL_DEBUG_SEVERITY_LOW)
|
||||
Con::printf("AMDOPENGL: %s", message);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -152,6 +157,9 @@ void GFXGLDevice::initGLState()
|
|||
glBindFramebuffer = &_t3d_glBindFramebuffer;
|
||||
}
|
||||
|
||||
#ifdef TORQUE_NSIGHT_WORKAROUND
|
||||
__GLEW_ARB_buffer_storage = false;
|
||||
#endif
|
||||
#if TORQUE_DEBUG
|
||||
if( gglHasExtension(ARB_debug_output) )
|
||||
{
|
||||
|
|
@ -176,7 +184,7 @@ void GFXGLDevice::initGLState()
|
|||
}
|
||||
#endif
|
||||
|
||||
PlatformGL::setVSync(0);
|
||||
PlatformGL::setVSync(smDisableVSync ? 0 : 1);
|
||||
|
||||
//OpenGL 3 need a binded VAO for render
|
||||
GLuint vao;
|
||||
|
|
@ -347,23 +355,47 @@ GFXPrimitiveBuffer* GFXGLDevice::findVolatilePBO(U32 numIndices, U32 numPrimitiv
|
|||
GFXVertexBuffer *GFXGLDevice::allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data )
|
||||
{
|
||||
if(bufferType == GFXBufferTypeVolatile)
|
||||
return findVolatileVBO(numVerts, vertexFormat, vertSize);
|
||||
|
||||
GFXGLVertexBuffer* buf = new GFXGLVertexBuffer( GFX, numVerts, vertexFormat, vertSize, bufferType );
|
||||
buf->registerResourceWithDevice(this);
|
||||
buf->registerResourceWithDevice(this);
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
buf->lock(0, numVerts, &dest);
|
||||
dMemcpy(dest, data, vertSize * numVerts);
|
||||
buf->unlock();
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
GFXPrimitiveBuffer *GFXGLDevice::allocPrimitiveBuffer( U32 numIndices, U32 numPrimitives, GFXBufferType bufferType )
|
||||
GFXPrimitiveBuffer *GFXGLDevice::allocPrimitiveBuffer( U32 numIndices, U32 numPrimitives, GFXBufferType bufferType, void* data )
|
||||
{
|
||||
GFXPrimitiveBuffer* buf;
|
||||
|
||||
if(bufferType == GFXBufferTypeVolatile)
|
||||
return findVolatilePBO(numIndices, numPrimitives);
|
||||
|
||||
GFXGLPrimitiveBuffer* buf = new GFXGLPrimitiveBuffer(GFX, numIndices, numPrimitives, bufferType);
|
||||
buf->registerResourceWithDevice(this);
|
||||
{
|
||||
buf = findVolatilePBO(numIndices, numPrimitives);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = new GFXGLPrimitiveBuffer(GFX, numIndices, numPrimitives, bufferType);
|
||||
buf->registerResourceWithDevice(this);
|
||||
}
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
buf->lock(0, numIndices, &dest);
|
||||
dMemcpy(dest, data, sizeof(U16) * numIndices);
|
||||
buf->unlock();
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
@ -803,9 +835,9 @@ GFXShader* GFXGLDevice::createShader()
|
|||
return shader;
|
||||
}
|
||||
|
||||
void GFXGLDevice::setShader( GFXShader *shader )
|
||||
void GFXGLDevice::setShader(GFXShader *shader, bool force)
|
||||
{
|
||||
if(mCurrentShader == shader)
|
||||
if(mCurrentShader == shader && !force)
|
||||
return;
|
||||
|
||||
if ( shader )
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
virtual F32 getPixelShaderVersion() const { return mPixelShaderVersion; }
|
||||
virtual void setPixelShaderVersion( F32 version ) { mPixelShaderVersion = version; }
|
||||
|
||||
virtual void setShader(GFXShader* shd);
|
||||
virtual void setShader(GFXShader *shader, bool force = false);
|
||||
|
||||
/// @attention GL cannot check if the given format supports blending or filtering!
|
||||
virtual GFXFormat selectSupportedFormat(GFXTextureProfile *profile,
|
||||
|
|
@ -173,8 +173,9 @@ protected:
|
|||
virtual GFXVertexBuffer *allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType );
|
||||
virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices, U32 numPrimitives, GFXBufferType bufferType );
|
||||
GFXBufferType bufferType,
|
||||
void* data = NULL);
|
||||
virtual GFXPrimitiveBuffer *allocPrimitiveBuffer( U32 numIndices, U32 numPrimitives, GFXBufferType bufferType, void* data = NULL );
|
||||
|
||||
// NOTE: The GL device doesn't need a vertex declaration at
|
||||
// this time, but we need to return something to keep the system
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ void GFXGLEnumTranslate::init()
|
|||
GFXGLBufferType[GFXBufferTypeStatic] = GL_STATIC_DRAW;
|
||||
GFXGLBufferType[GFXBufferTypeDynamic] = GL_DYNAMIC_DRAW;
|
||||
GFXGLBufferType[GFXBufferTypeVolatile] = GL_STREAM_DRAW;
|
||||
GFXGLBufferType[GFXBufferTypeImmutable] = GL_STATIC_DRAW;
|
||||
|
||||
// Primitives
|
||||
GFXGLPrimType[GFXPointList] = GL_POINTS;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public:
|
|||
};
|
||||
|
||||
GFXGLShaderConstHandle::GFXGLShaderConstHandle( GFXGLShader *shader )
|
||||
: mShader( shader ), mSamplerNum(-1), mInstancingConstant(false)
|
||||
: mShader( shader ), mLocation(0), mOffset(0), mSize(0), mSamplerNum(-1), mInstancingConstant(false)
|
||||
{
|
||||
mValid = false;
|
||||
}
|
||||
|
|
@ -929,7 +929,7 @@ char* GFXGLShader::_handleIncludes( const Torque::Path& path, FileStream *s )
|
|||
dFree(includedText);
|
||||
manip.insert(q-buffer, sItx);
|
||||
char* manipBuf = dStrdup(manip.c_str());
|
||||
p = manipBuf + (p - buffer);
|
||||
p = manipBuf + (q - buffer);
|
||||
dFree(buffer);
|
||||
buffer = manipBuf;
|
||||
}
|
||||
|
|
@ -952,13 +952,6 @@ bool GFXGLShader::_loadShaderFromStream( GLuint shader,
|
|||
buffers.push_back( dStrdup( versionDecl ) );
|
||||
lengths.push_back( dStrlen( versionDecl ) );
|
||||
|
||||
if(gglHasExtension(EXT_gpu_shader4))
|
||||
{
|
||||
const char *extension = "#extension GL_EXT_gpu_shader4 : enable\r\n";
|
||||
buffers.push_back( dStrdup( extension ) );
|
||||
lengths.push_back( dStrlen( extension ) );
|
||||
}
|
||||
|
||||
if(gglHasExtension(ARB_gpu_shader5))
|
||||
{
|
||||
const char *extension = "#extension GL_ARB_gpu_shader5 : enable\r\n";
|
||||
|
|
|
|||
|
|
@ -260,7 +260,10 @@ GFXGLTextureTarget::GFXGLTextureTarget() : mCopyFboSrc(0), mCopyFboDst(0)
|
|||
|
||||
GFXGLTextureTarget::~GFXGLTextureTarget()
|
||||
{
|
||||
GFXTextureManager::removeEventDelegate( this, &GFXGLTextureTarget::_onTextureEvent );
|
||||
GFXTextureManager::removeEventDelegate(this, &GFXGLTextureTarget::_onTextureEvent);
|
||||
|
||||
glDeleteFramebuffers(1, &mCopyFboSrc);
|
||||
glDeleteFramebuffers(1, &mCopyFboDst);
|
||||
}
|
||||
|
||||
const Point2I GFXGLTextureTarget::getSize()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ GFXGLWindowTarget::GFXGLWindowTarget(PlatformWindow *win, GFXDevice *d)
|
|||
win->appEvent.notify(this, &GFXGLWindowTarget::_onAppSignal);
|
||||
}
|
||||
|
||||
GFXGLWindowTarget::~GFXGLWindowTarget()
|
||||
{
|
||||
if(glIsFramebuffer(mCopyFBO))
|
||||
{
|
||||
glDeleteFramebuffers(1, &mCopyFBO);
|
||||
}
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::resetMode()
|
||||
{
|
||||
if(mWindow->getVideoMode().fullScreen != mWindow->isFullscreen())
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ class GFXGLWindowTarget : public GFXWindowTarget
|
|||
public:
|
||||
|
||||
GFXGLWindowTarget(PlatformWindow *win, GFXDevice *d);
|
||||
~GFXGLWindowTarget();
|
||||
|
||||
const Point2I getSize()
|
||||
{
|
||||
return mWindow->getClientExtent();
|
||||
|
|
@ -64,4 +66,4 @@ private:
|
|||
void _WindowPresent();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ void GFXGLDevice::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
|
|||
);
|
||||
|
||||
SDL_ClearError();
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
|
||||
SDL_GLContext tempContext = SDL_GL_CreateContext( tempWindow );
|
||||
if( !tempContext )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace GL
|
|||
{
|
||||
void gglPerformBinds()
|
||||
{
|
||||
glewExperimental = GL_TRUE;
|
||||
GLenum err = glewInit();
|
||||
AssertFatal(GLEW_OK == err, avar("Error: %s\n", glewGetErrorString(err)) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,13 @@
|
|||
#define T_GL_H
|
||||
#include "GL/glew.h"
|
||||
|
||||
#if defined (TORQUE_OS_WIN)
|
||||
// This doesn't work on Mesa drivers.
|
||||
#define gglHasExtension(EXTENSION) GLEW_##EXTENSION
|
||||
#else
|
||||
// Slower but reliably detects extensions on Mesa.
|
||||
#define gglHasExtension(EXTENSION) glewGetExtension("GL_" # EXTENSION)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -297,8 +297,6 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
|
|||
|
||||
loadGLCore();
|
||||
loadGLExtensions(hdcGL);
|
||||
|
||||
wglSwapIntervalEXT(0);
|
||||
|
||||
// It is very important that extensions be loaded
|
||||
// before we call initGLState()
|
||||
|
|
|
|||
|
|
@ -132,6 +132,11 @@ void DebugDrawer::setupStateBlocks()
|
|||
|
||||
d.setZReadWrite(false);
|
||||
mRenderZOffSB = GFX->createStateBlock(d);
|
||||
|
||||
d.setCullMode(GFXCullCCW);
|
||||
d.setZReadWrite(true, false);
|
||||
d.setBlend(true);
|
||||
mRenderAlpha = GFX->createStateBlock(d);
|
||||
}
|
||||
|
||||
void DebugDrawer::render()
|
||||
|
|
@ -158,10 +163,13 @@ void DebugDrawer::render()
|
|||
|
||||
// Set up the state block...
|
||||
GFXStateBlockRef currSB;
|
||||
if(p->useZ)
|
||||
if(p->type==DebugPrim::Capsule){
|
||||
currSB = mRenderAlpha;
|
||||
}else if(p->useZ){
|
||||
currSB = mRenderZOnSB;
|
||||
else
|
||||
}else{
|
||||
currSB = mRenderZOffSB;
|
||||
}
|
||||
GFX->setStateBlock( currSB );
|
||||
|
||||
Point3F d;
|
||||
|
|
@ -180,6 +188,47 @@ void DebugDrawer::render()
|
|||
|
||||
PrimBuild::end();
|
||||
break;
|
||||
case DebugPrim::DirectionLine:
|
||||
{
|
||||
const static F32 ARROW_LENGTH = 0.2f, ARROW_RADIUS = 0.035f, CYLINDER_RADIUS = 0.008f;
|
||||
Point3F &start = p->a, &end = p->b;
|
||||
Point3F direction = end - start;
|
||||
F32 length = direction.len();
|
||||
if( length>ARROW_LENGTH ){
|
||||
//cylinder with arrow on end
|
||||
direction *= (1.0f/length);
|
||||
Point3F baseArrow = end - (direction*ARROW_LENGTH);
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), baseArrow, end, ARROW_RADIUS, p->color);
|
||||
GFX->getDrawUtil()->drawCylinder(currSB->getDesc(), start, baseArrow, CYLINDER_RADIUS, p->color);
|
||||
}else if( length>0 ){
|
||||
//short, so just draw arrow
|
||||
GFX->getDrawUtil()->drawCone(currSB->getDesc(), start, end, ARROW_RADIUS, p->color);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DebugPrim::Capsule:
|
||||
GFX->getDrawUtil()->drawCapsule(currSB->getDesc(), p->a, p->b.x, p->b.y, p->color);
|
||||
break;
|
||||
case DebugPrim::OutlinedText:
|
||||
{
|
||||
GFXTransformSaver saver;
|
||||
Point3F result;
|
||||
if (MathUtils::mProjectWorldToScreen(p->a, &result, GFX->getViewport(), GFX->getWorldMatrix(), GFX->getProjectionMatrix()))
|
||||
{
|
||||
GFX->setClipRect(GFX->getViewport());
|
||||
Point2I where = Point2I(result.x, result.y);
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color2);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x-1, where.y), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x+1, where.y), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x, where.y-1), p->mText);
|
||||
GFX->getDrawUtil()->drawText(mFont, Point2I(where.x, where.y+1), p->mText);
|
||||
|
||||
GFX->getDrawUtil()->setBitmapModulation(p->color);
|
||||
GFX->getDrawUtil()->drawText(mFont, where, p->mText);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DebugPrim::Box:
|
||||
d = p->a - p->b;
|
||||
GFX->getDrawUtil()->drawCube(currSB->getDesc(), d * 0.5, (p->a + p->b) * 0.5, p->color);
|
||||
|
|
@ -262,6 +311,63 @@ void DebugDrawer::drawLine(const Point3F &a, const Point3F &b, const ColorF &col
|
|||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const ColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
||||
DebugPrim *n = mPrimChunker.alloc();
|
||||
|
||||
n->useZ = true;
|
||||
n->dieTime = 0;
|
||||
n->a = a;
|
||||
n->b.x = radius;
|
||||
n->b.y = height;
|
||||
n->color = color;
|
||||
n->type = DebugPrim::Capsule;
|
||||
|
||||
n->next = mHead;
|
||||
mHead = n;
|
||||
|
||||
}
|
||||
|
||||
void DebugDrawer::drawDirectionLine(const Point3F &a, const Point3F &b, const ColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
||||
DebugPrim *n = mPrimChunker.alloc();
|
||||
|
||||
n->useZ = true;
|
||||
n->dieTime = 0;
|
||||
n->a = a;
|
||||
n->b = b;
|
||||
n->color = color;
|
||||
n->type = DebugPrim::DirectionLine;
|
||||
|
||||
n->next = mHead;
|
||||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawOutlinedText(const Point3F& pos, const String& text, const ColorF &color, const ColorF &colorOutline)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
return;
|
||||
|
||||
DebugPrim *n = mPrimChunker.alloc();
|
||||
|
||||
n->useZ = false;
|
||||
n->dieTime = 0;
|
||||
n->a = pos;
|
||||
n->color = color;
|
||||
n->color2 = colorOutline;
|
||||
dStrncpy(n->mText, text.c_str(), 256);
|
||||
n->type = DebugPrim::OutlinedText;
|
||||
|
||||
n->next = mHead;
|
||||
mHead = n;
|
||||
}
|
||||
|
||||
void DebugDrawer::drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const ColorF &color)
|
||||
{
|
||||
if(isFrozen || !isDrawing)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,10 @@ public:
|
|||
void drawLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawTri(const Point3F &a, const Point3F &b, const Point3F &c, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
void drawText(const Point3F& pos, const String& text, const ColorF &color = ColorF(1.0f,1.0f,1.0f));
|
||||
|
||||
void drawCapsule(const Point3F &a, const F32 &radius, const F32 &height, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f));
|
||||
void drawDirectionLine(const Point3F &a, const Point3F &b, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f));
|
||||
void drawOutlinedText(const Point3F& pos, const String& text, const ColorF &color = ColorF(1.0f, 1.0f, 1.0f), const ColorF &colorOutline = ColorF(0.0f, 0.0f, 0.0f));
|
||||
|
||||
/// Render a wireframe view of the given polyhedron.
|
||||
void drawPolyhedron( const AnyPolyhedron& polyhedron, const ColorF& color = ColorF( 1.f, 1.f, 1.f ) );
|
||||
|
||||
|
|
@ -161,6 +164,7 @@ private:
|
|||
{
|
||||
/// Color used for this primitive.
|
||||
ColorF color;
|
||||
ColorF color2;
|
||||
|
||||
/// Points used to store positional data. Exact semantics determined by type.
|
||||
Point3F a, b, c;
|
||||
|
|
@ -168,7 +172,10 @@ private:
|
|||
Tri,
|
||||
Box,
|
||||
Line,
|
||||
Text
|
||||
Text,
|
||||
DirectionLine,
|
||||
OutlinedText,
|
||||
Capsule,
|
||||
} type; ///< Type of the primitive. The meanings of a,b,c are determined by this.
|
||||
|
||||
SimTime dieTime; ///< Time at which we should remove this from the list.
|
||||
|
|
@ -188,6 +195,7 @@ private:
|
|||
|
||||
GFXStateBlockRef mRenderZOffSB;
|
||||
GFXStateBlockRef mRenderZOnSB;
|
||||
GFXStateBlockRef mRenderAlpha;
|
||||
|
||||
Resource<GFont> mFont;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class TheoraTextureFrame
|
|||
F32 mFrameDuration;
|
||||
|
||||
TheoraTextureFrame()
|
||||
: mLockedRect( NULL )
|
||||
: mLockedRect( NULL ), mFrameNumber(0), mFrameTime(0.0f), mFrameDuration(0.0f)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class VideoEncoderTheora : public VideoEncoder, public Thread
|
|||
|
||||
public:
|
||||
VideoEncoderTheora() :
|
||||
mLastFrame(NULL)
|
||||
mCurrentFrame(0), td(NULL), mLastFrame(NULL)
|
||||
{
|
||||
setStatus(false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue