// ////////////////////////////////////////////////////////////////////
    //
    // ////////////////////////////////////////////////////////////////////
    void DirectSound8AudioBuffer::VSetVolume(I32 volume)
    {
        if(!g_audioPtr || !g_audioPtr->VActive()) {
            GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VSetVolume()", "The sound system is not active");
            return;
        }

        LPDIRECTSOUNDBUFFER pDSB = static_cast<LPDIRECTSOUNDBUFFER>(VGet());
        if(!pDSB) {
            GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VSetVolume()", "Failed to cast the buffer to a DirectSound buffer");
            return;
        }

        if(volume < 0) {
            GF_LOG_TRACE_INF("DirectSound8AudioBuffer::VSetVolume()", "Volume cannot be less than 0 so we are setting it to 0");
            volume = 0;
        } else if(volume > 100) {
            GF_LOG_TRACE_INF("DirectSound8AudioBuffer::VSetVolume()", "The volume cannot be greater than 100 so we are setting it to 100");
            volume = 100;
        }

        // convert volume from 0-100 into range for DirectX - don't forget to use a logarithmic scale!
        F32 coeff = (F32)volume / 100.0f;
        F32 logarithmicProportion = coeff > 0.1f  ? 1 + log10(coeff)  : 0;
        F32 range = (DSBVOLUME_MAX - GCC_DSBVOLUME_MIN);
        F32 fvolume = (range * logarithmicProportion) + GCC_DSBVOLUME_MIN;
        assert(fvolume >= GCC_DSBVOLUME_MIN && fvolume <= DSBVOLUME_MAX);

        HRESULT hr = pDSB->SetVolume(LONG(fvolume));
        if(hr != S_OK) {
            GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VSetVolume()", "Failed to set the volum of the DirectSound Buffer");
        }
    }
示例#2
0
	// /////////////////////////////////////////////////////////////////
	//
	// /////////////////////////////////////////////////////////////////
	GLint TextureManager::GetMaxTextureSize(const GLenum texType) const
	{
		if((texType != GL_MAX_TEXTURE_SIZE) || (texType != GL_MAX_CUBE_MAP_TEXTURE_SIZE))
		{
            GF_LOG_TRACE_INF("TextureManager::GetMaxTextureSize()", "Invalid parameters");
			return (-1);
		}

		GLint maxSize;
        GF_CLEAR_GL_ERROR();
		glGetIntegerv(texType, &maxSize);
        if(!GF_CHECK_GL_ERROR_TRC("TextureManager::GetMaxTextureSize(): "))
        {
            return (0);
        }
		return (maxSize);
	}