Exemple #1
0
RESULT 
GradientEffect::InitScratchSurfaces( Rectangle& sourceRect, Rectangle& textureRect )
{
    RESULT rval = S_OK;
    
    // We render a mesh in place of the (likely) quad sent down from the caller.
    // This allows for more fine-grained gradients, while still keeping the math in
    // the vertex shader.
    //
    // Create the new mesh with the same position and dimensions, 
    // and a reasonable number of number of triangles (so the gradient looks smooth.
    
    float uStart    = textureRect.x;
    float uEnd      = textureRect.x + textureRect.width;
    float vStart    = textureRect.y;
    float vEnd      = textureRect.y + textureRect.height;
    
    SAFE_ARRAY_DELETE(m_pGradientVertices);
    
    CHR(Util::CreateTriangleList( &sourceRect, 5, 5, &m_pGradientVertices, &m_numGradientVertices, uStart, uEnd, vStart, vEnd  ));

    // TODO: create a VBO.
    
Exit:
    return rval;
}
Exemple #2
0
RESULT 
RippleEffect::InitScratchSurfaces( Rectangle& sourceRect, Rectangle& textureRect )
{
    RESULT rval = S_OK;

    // We render an animated mesh in place of the triangle mesh sent down from the caller.
    //
    // Create the new mesh with the same position and dimensions (plus optional padding), 
    // and a reasonable number of number of triangles (so the ripples look fluid).
    
    Rectangle paddedRect = sourceRect;
    paddedRect.x        -= m_padding;
    paddedRect.y        -= m_padding;
    paddedRect.width    += m_padding*2;
    paddedRect.height   += m_padding*2;
    
//    Rectangle paddedTextureRect = textureRect;
//    paddedTextureRect.x  -= sourceRect.width - paddedRect.width;
      

    float uStart    = textureRect.x;
    float uEnd      = textureRect.x + textureRect.width;
    float vStart    = textureRect.y;
    float vEnd      = textureRect.y + textureRect.height;
    
    SAFE_ARRAY_DELETE(m_pRippledVertices);
    
    CHR(Util::CreateTriangleList( &paddedRect, m_rows, m_columns, &m_pRippledVertices, &m_numRippledVertices, uStart, uEnd, vStart, vEnd  ));

    // TODO: create a VBO.

Exit:
    return rval;
}
    void CascadedShadowMapper::Destroy(void)
    {
        for(UCHAR i = 0; i < m_cascades; ++i)
        {
            SAFE_DELETE(m_ppTargets[i]);
            SAFE_DELETE(m_ppBlurredTargets[i]);
            SAFE_DELETE(m_ppBlurChain[i]);
        }

        SAFE_ARRAY_DELETE(m_ppTargets);

        SAFE_ARRAY_DELETE(m_ppBlurredTargets);

        SAFE_ARRAY_DELETE(m_ppBlurChain);

        SAFE_ARRAY_DELETE(m_pCascadesSettings);
    }
Exemple #4
0
	void MOFMesh::release()
	{
		for(int i=0; i<this->m_numMeshes; ++i)
		{
			SAFE_DELETE(this->m_meshes[i]);
		}

		SAFE_ARRAY_DELETE(this->m_meshes);
	}
Exemple #5
0
Animation::~Animation()
{
    DEBUGMSG(ZONE_OBJECT, "\t~Animation( %4d, \"%s\" )", m_ID, m_name.c_str());
    
    SAFE_DELETE(m_pCallbackOnFinished);
    SAFE_DELETE(m_pInterpolator);
    SAFE_DELETE(m_pTargetProperty);
    SAFE_ARRAY_DELETE(m_pKeyFrames);
}
Exemple #6
0
//===========================================================================
int cGenericShader::loadFragmentShaderFromFile(const char* a_filename)
{
    char* contents = (char*)readFile(a_filename,true);
    if (contents == 0) return -1;

    uninitializeFragmentShader();
    SAFE_ARRAY_DELETE(m_fragmentShaderFilename);
    SAFE_ARRAY_DELETE(m_fragmentShaderString);

    m_fragmentShaderFilename = new char[strlen(a_filename)+1];
    strcpy(m_fragmentShaderFilename,a_filename);
    m_fragmentShaderString = contents;

    int retval = initializeFragmentShader();

    // Don't necessarily delete; we may try again at render time...

    return retval;
}
Exemple #7
0
void CMiniMap::Destroy()
{
	if (m_TerrainTexture)
	{
		glDeleteTextures(1, &m_TerrainTexture);
		m_TerrainTexture = 0;
	}

	SAFE_ARRAY_DELETE(m_TerrainData);
}
Exemple #8
0
void CCircleBuffer::CreateBuffer(int nBytes, int nMaxDirectWriteBytes)
{
    SAFE_ARRAY_DELETE(m_pBuffer)
    
    m_nMaxDirectWriteBytes = nMaxDirectWriteBytes;
    m_nTotal = nBytes + 1 + nMaxDirectWriteBytes;
    m_pBuffer = new unsigned char [m_nTotal];
    m_nHead = 0;
    m_nTail = 0;
    m_nEndCap = m_nTotal;
}
Exemple #9
0
template<class T> void Stack<T>::expandCapacity()
{
	unsigned int  newCapacity = m_capacity == 0 ? INITIAL_SIZE : m_capacity * 2;
	T* newArray = allocArray(newCapacity);
	for (unsigned int  i = 0; i < m_size; i++) {
		newArray[i] = m_array[i];
	}
	SAFE_ARRAY_DELETE(m_array);
	m_array = newArray;
	m_capacity = newCapacity;
}
Exemple #10
0
template<class T> void Stack<T>::resize(unsigned int newSize)
{
	if (newSize > m_size) {
		T* newArray = allocArray(newSize);
		for (unsigned int  i = 0; i < min(m_size,newSize); i++) {
			newArray[i] = m_array[i];
		}
		SAFE_ARRAY_DELETE(m_array);
		m_array = newArray;
		m_capacity = newSize;
	}
	m_size = newSize;
}
Exemple #11
0
RippleEffect::~RippleEffect()
{
    RETAILMSG(ZONE_OBJECT | ZONE_VERBOSE, "\t~RippleEffect( %4d )", m_ID);

    SAFE_ARRAY_DELETE(m_pRippledVertices);

    // Delete the shaders when the last instance is freed
    if (0 == ATOMIC_DECREMENT( RippleEffect::s_NumInstances ))
    {
        RETAILMSG(ZONE_INFO, "~RippleEffect: last instance deleted, freeing Ripple shaders");
        Deinit();
    }
}
Exemple #12
0
template<class T> void Stack<T>::reserve(unsigned int newCapacity)
{
	if (newCapacity > m_capacity) {
		T* newArray = allocArray(newCapacity);
		for (unsigned int  i = 0; i < m_size; i++) {
			newArray[i] = m_array[i];
		}
		SAFE_ARRAY_DELETE(m_array);
		m_array = newArray;
		m_capacity = newCapacity;
	}

}
Exemple #13
0
string DXDiagNVUtil::lpcwstrToString( const LPCWSTR in_lpcwstr )
{
	//@ consider using windows.h  WideCharToMultiByte(..)
	char * mbBuf;
	size_t sz;
	sz = 2 * wcslen( in_lpcwstr );
	mbBuf = new char[sz];
	wcstombs( mbBuf, in_lpcwstr, sz );		// convert the string 
	string outstr;
	outstr = mbBuf;
	SAFE_ARRAY_DELETE( mbBuf );
	return( outstr );
}
int CAPECompress::StartEx(CIO * pioOutput, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
{
    m_pioOutput = pioOutput;
    m_bOwnsOutputIO = FALSE;

    m_spAPECompressCreate->Start(m_pioOutput, pwfeInput, nMaxAudioBytes, nCompressionLevel,
        pHeaderData, nHeaderBytes);

    SAFE_ARRAY_DELETE(m_pBuffer)
    m_nBufferSize = m_spAPECompressCreate->GetFullFrameBytes();
    m_pBuffer = new unsigned char [m_nBufferSize];
    memcpy(&m_wfeInput, pwfeInput, sizeof(WAVEFORMATEX));

    return ERROR_SUCCESS;
}
Exemple #15
0
    void ResourceCache::Free(std::shared_ptr<IResHandle> handle) 
    {
        m_lock.Lock();

        char* d = handle->VBuffer();
        SAFE_ARRAY_DELETE(d);

        MemoryHasBeenFreed(handle->VSize());

        m_handlesmap.erase(handle->VGetResource().m_name);
        m_handlesList.remove(handle);
        SAFE_DELETE(m_locks[handle->VGetResource().m_name]);
        m_locks.erase(handle->VGetResource().m_name);
        m_lock.Unlock();
    }
Exemple #16
0
	Texture::~Texture()
	{
		if( m_filePath != "" )
		{
			stbi_image_free( m_texels );
		}
		else
		{		
			SAFE_ARRAY_DELETE( m_texels );
		}

		if( m_textureID != 0 )
		{
			glDeleteTextures( 1, &m_textureID );
		}		
	}
Exemple #17
0
template<class T> Stack<T>& Stack<T>::operator=(const Stack<T>& other) 
{
	if (this == &other) return *this;

	if (m_capacity < other.m_size)
	{
		SAFE_ARRAY_DELETE(m_array);
		m_capacity = other.m_size;
		m_array = allocArray(m_capacity);
	}	
	m_size = other.m_size;
	for (unsigned int  i = 0; i < other.m_size; i++) 
	{
		m_array[i] = other.m_array[i];
	}
	return *this;
}
Exemple #18
0
RippleEffect& 
RippleEffect::operator=( const RippleEffect& rhs )
{
    // Avoid self-assignment.
    if (this == &rhs)
        return *this;
    

    // Copy base class (is there a cleaner syntax?)
    OpenGLESEffect::operator=(rhs);


    // SHALLOW COPY:
    m_numRippledVertices            = rhs.m_numRippledVertices;
    m_rows                          = rhs.m_rows;
    m_columns                       = rhs.m_columns;
    m_padding                       = rhs.m_padding;
    m_fAmplitude                    = rhs.m_fAmplitude;
    m_fSpeed                        = rhs.m_fSpeed;
    m_fRadius                       = rhs.m_fRadius;
    m_fWaveLength                   = rhs.m_fWaveLength;
    m_fNumWaves                     = rhs.m_fNumWaves;
    m_origin                        = rhs.m_origin;
    m_color                         = rhs.m_color;
    

    // DEEP COPY: vertices
    if (rhs.m_pRippledVertices)
    {
        SAFE_ARRAY_DELETE(m_pRippledVertices);
        m_pRippledVertices = new Vertex[ rhs.m_numRippledVertices ];
        memcpy(m_pRippledVertices, rhs.m_pRippledVertices, sizeof(Vertex)*rhs.m_numRippledVertices);
    }

    
    // Give it a new name with a random suffix
    char instanceName[MAX_NAME];
    sprintf(instanceName, "%s_%X", rhs.m_name.c_str(), (unsigned int)Platform::Random());
    m_name = string(instanceName);
    
    return *this;
}
int CAPECompress::Start(const wchar_t * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
{
    m_pioOutput = new IO_CLASS_NAME;
    m_bOwnsOutputIO = TRUE;
    
    if (m_pioOutput->Create(pOutputFilename) != 0)
    {
        return ERROR_INVALID_OUTPUT_FILE;
    }
        
    m_spAPECompressCreate->Start(m_pioOutput, pwfeInput, nMaxAudioBytes, nCompressionLevel,
        pHeaderData, nHeaderBytes);
    
    SAFE_ARRAY_DELETE(m_pBuffer)
    m_nBufferSize = m_spAPECompressCreate->GetFullFrameBytes();
    m_pBuffer = new unsigned char [m_nBufferSize];
    memcpy(&m_wfeInput, pwfeInput, sizeof(WAVEFORMATEX));

    return ERROR_SUCCESS;
}
Exemple #20
0
    std::shared_ptr<IResHandle> ResourceCache::VGetHandle(CMResource& r) 
    {
        m_lock.Lock();
    
        auto it = m_locks.find(r.m_name.c_str());

        if(it == m_locks.end())
        {
            m_locks[r.m_name] = new util::Locker();
        }

        m_lock.Unlock();

        m_locks[r.m_name]->Lock();

        m_lock.Lock();

        std::shared_ptr<IResHandle> handle = Find(r);

        if(handle) 
        {
            if(handle->VIsReady())
            {
                m_locks[r.m_name]->Unlock();
                Update(handle);
                m_lock.Unlock();
                return handle;
            }
            m_handlesmap.erase(handle->VGetResource().m_name);
            m_handlesList.remove(handle);
            char* d = handle->VBuffer();
            SAFE_ARRAY_DELETE(d);
            MemoryHasBeenFreed(handle->VSize());
        }

        handle = Load(r);

        return handle;
    }
Exemple #21
0
GradientEffect& 
GradientEffect::operator=( const GradientEffect& rhs )
{
    // Avoid self-assignment.
    if (this == &rhs)
        return *this;
    

    // Copy base class (is there a cleaner syntax?)
    OpenGLESEffect::operator=(rhs);


    // SHALLOW COPY:
    m_numGradientVertices       = rhs.m_numGradientVertices;
    m_startColor                = rhs.m_startColor;
    m_endColor                  = rhs.m_endColor;
    m_startPoint                = rhs.m_startPoint;
    m_endPoint                  = rhs.m_endPoint;


    // DEEP COPY: vertices
    if (rhs.m_pGradientVertices)
    {
        SAFE_ARRAY_DELETE(m_pGradientVertices);
        m_pGradientVertices = new Vertex[ rhs.m_numGradientVertices ];
        memcpy(m_pGradientVertices, rhs.m_pGradientVertices, sizeof(Vertex)*rhs.m_numGradientVertices);
    }
    

    // Give it a new name with a random suffix
    char instanceName[MAX_NAME];
    sprintf(instanceName, "%s_%X", rhs.m_name.c_str(), (unsigned int)Platform::Random());
    m_name = string(instanceName);
    
    return *this;
}
Exemple #22
0
cBlockMgr::~cBlockMgr(){

	SAFE_ARRAY_DELETE(this->ChildBlock);
	SAFE_ARRAY_DELETE(this->Map);
	SAFE_ARRAY_DELETE(this->CS);
}
void CEvaluationEngine::onTerminate(IN void *pArg)
{
    intptr_t *pData = (intptr_t *)pArg;
    SAFE_ARRAY_DELETE(pData);
}
///////////////////////////////////////////////////////////////////////////////
//
// Method: SetKIDStrings
// Description: Copies the array of KID strings.
// Parameters: ppKIDStrings - Pointer to the array of strings.
//             NumKIDs - Number of strings in the array.
// Returns: S_OK - String copy succeeded.
//          E_INVALIDARG - Either the array pointer is NULL or the number of
//           KIDs is set to 0.
//          E_FAIL - The object needs to be initialized.
//          E_OUTOFMEMORY - Could not copy one of the strings.
//
// Notes: If a single string fails to copy, all strings are cleared and an 
//  error code is returned. This method treats all SysAllocString failures as
//  out of memory errors. However, if one of the KID strings is NULL the same
//  result occurs. None of the KID strings should be NULL, but if one is it 
//  will cause an error.
// 
///////////////////////////////////////////////////////////////////////////////
HRESULT CRightsReporter::SetKIDStrings(WCHAR** ppKIDStrings, int NumKIDs)
{
    HRESULT hr = S_OK;

    // Check parameters.
    if (ppKIDStrings == NULL || NumKIDs == 0)
    {
        hr = E_INVALIDARG;
    }

    // Check to ensure that the object has been initialized.
    if (SUCCEEDED(hr))
    {
        if (m_pLicenseQuery == NULL)
        {
            hr = E_FAIL;
        }
    }

    // Check to see if there is an existing array to delete.
    if (SUCCEEDED(hr))
    {
        if (m_KIDStrings != NULL)
        {
            // Free the strings in the old array.
            for (int i = 0; i < m_NumKIDs; i++)
            {
                SysFreeString(m_KIDStrings[i]);
            }

            SAFE_ARRAY_DELETE(m_KIDStrings);

            m_NumKIDs = 0;
        }
    }

    // Allocate the internal array to hold the KID strings.
    if (SUCCEEDED(hr))
    {
        m_NumKIDs = NumKIDs;
        m_KIDStrings = new BSTR[m_NumKIDs];
        
        if (m_KIDStrings == NULL)
        {
            hr = E_OUTOFMEMORY;
        }
        else
        {
            // Initialize the new array.
            ZeroMemory(m_KIDStrings, m_NumKIDs * sizeof(BSTR));
        }
    }

    // Copy the strings to the new array.
    if (SUCCEEDED(hr))
    {
        for (int i = 0; i < m_NumKIDs; i++)
        {
            // Creat a new BSTR from the next KID string.
            m_KIDStrings[i] = SysAllocString(ppKIDStrings[i]);

            if (m_KIDStrings[i] == NULL)
            {
                hr = E_OUTOFMEMORY;
                break;
            }
        }
    }

    // Clean up.
    if (FAILED(hr))
    {
        // Delete any allocated strings.
        for (int i = 0; i < m_NumKIDs; i++)
        {
            if (m_KIDStrings[i] != NULL)
            {
                SysFreeString(m_KIDStrings[i]);
            }
        }
    }

    return hr;
}
Exemple #25
0
#include "All.h"
#include "CircleBuffer.h"

CCircleBuffer::CCircleBuffer()
{
    m_pBuffer = NULL;
    m_nTotal = 0;
    m_nHead = 0;
    m_nTail = 0;
    m_nEndCap = 0;
    m_nMaxDirectWriteBytes = 0;
}

CCircleBuffer::~CCircleBuffer()
{
    SAFE_ARRAY_DELETE(m_pBuffer)
}

void CCircleBuffer::CreateBuffer(int nBytes, int nMaxDirectWriteBytes)
{
    SAFE_ARRAY_DELETE(m_pBuffer)
    
    m_nMaxDirectWriteBytes = nMaxDirectWriteBytes;
    m_nTotal = nBytes + 1 + nMaxDirectWriteBytes;
    m_pBuffer = new unsigned char [m_nTotal];
    m_nHead = 0;
    m_nTail = 0;
    m_nEndCap = m_nTotal;
}

int CCircleBuffer::MaxAdd()
Exemple #26
0
template<class T> Stack<T>::~Stack()
{
	SAFE_ARRAY_DELETE(m_array);
}
Exemple #27
0
cBallMgr::~cBallMgr(){
	SAFE_ARRAY_DELETE(this->ChildBall);
}
HRESULT CASFManager::EnumerateStreams (WORD** ppwStreamNumbers, 
                                       GUID** ppguidMajorType, 
                                       DWORD* pcbTotalStreams)
{
    if (!ppwStreamNumbers || !ppguidMajorType || !pcbTotalStreams)
    {
        return E_INVALIDARG;
    }

    if (!m_pContentInfo)
    {
        return MF_E_NOT_INITIALIZED;
    }

    HRESULT hr = S_OK;

    IMFASFStreamConfig* pStream = NULL;
    IMFASFProfile* pProfile = NULL;

    *pcbTotalStreams =0;

    WORD* pwStreamNumbers; 
    GUID* pguidMajorType;   

    CHECK_HR(hr =  m_pContentInfo->GetProfile(&pProfile));

    CHECK_HR(hr = pProfile->GetStreamCount(pcbTotalStreams));

    if (*pcbTotalStreams == 0)
    {
        SAFE_RELEASE(pProfile);

        return E_FAIL;
    }

    //create an array of stream numbers and initialize elements swith 0
    pwStreamNumbers = new WORD[*pcbTotalStreams*sizeof(WORD)];

    if (!pwStreamNumbers)
    {
        hr = E_OUTOFMEMORY;
        goto done;
    }

    ZeroMemory (pwStreamNumbers, *pcbTotalStreams*sizeof(WORD));

    //create an array of guids and initialize elements with GUID_NULL.
    pguidMajorType = new GUID[*pcbTotalStreams*sizeof(GUID)];
    
    if (!pguidMajorType)
    {
        hr = E_OUTOFMEMORY;
        goto done;
    }

    ZeroMemory (pguidMajorType, *pcbTotalStreams*sizeof(GUID));

    //populate the arrays with stream numbers and guids from the profile object
    for (unsigned index = 0; index < *pcbTotalStreams; index++)
    {
        CHECK_HR(hr = pProfile->GetStream(index, &pwStreamNumbers[index], &pStream));

        CHECK_HR(hr = pStream->GetStreamType(&pguidMajorType[index]));

        SAFE_RELEASE(pStream);
    }


    *ppwStreamNumbers = pwStreamNumbers;
    *ppguidMajorType = pguidMajorType;

    TRACE((L"Enumerated streams.\n"));

done:

    LOG_MSG_IF_FAILED(L"CASFManager::EnumerateStreams failed.\n", hr);

    SAFE_RELEASE(pProfile);
    SAFE_RELEASE(pStream);

    if (FAILED (hr))
    {
        SAFE_ARRAY_DELETE(pwStreamNumbers);
        SAFE_ARRAY_DELETE(pguidMajorType);
    }

    return hr;
}
    m_pTempData = new int [pAPEDecompress->GetInfo(APE_INFO_BLOCKS_PER_FRAME) + 16];

    m_nBlocksProcessed = 0;
    
    // check to see if MMX is available
    m_bMMXAvailable = FALSE;
}

CAPEDecompressCore::~CAPEDecompressCore()
{
    SAFE_DELETE(m_pUnBitArray)
        
    SAFE_DELETE(m_pAntiPredictorX)
    SAFE_DELETE(m_pAntiPredictorY)
    
    SAFE_ARRAY_DELETE(m_pDataX)
    SAFE_ARRAY_DELETE(m_pDataY)
    SAFE_ARRAY_DELETE(m_pTempData)
}

void CAPEDecompressCore::GenerateDecodedArrays(int nBlocks, int nSpecialCodes, int nFrameIndex, int nCPULoadBalancingFactor)
{
    CUnBitArray * pBitArray = (CUnBitArray *) m_pUnBitArray;
    
    if (m_pAPEDecompress->GetInfo(APE_INFO_CHANNELS) == 2)
    {
        if ((nSpecialCodes & SPECIAL_FRAME_LEFT_SILENCE) && (nSpecialCodes & SPECIAL_FRAME_RIGHT_SILENCE)) 
        {
            memset(m_pDataX, 0, nBlocks * 4);
            memset(m_pDataY, 0, nBlocks * 4);
        }
// ----------------------------------------------------------------------------
// Name : ~CUISelectList()
// Desc : Destructor
// ----------------------------------------------------------------------------
CUISelectList::~CUISelectList()
{
	Destroy();

	SAFE_ARRAY_DELETE(m_pstrState);
}