Beispiel #1
0
/**
 * @brief Convert string value to desired type.
 * @param [in, out] value Value to convert.
 * @param [in] nType Type to convert to.
 * @return true if conversion succeeded, false otherwise.
 * @note Only supports converting to integer and boolean at the moment.
 * @todo Add other conversions (float?).
  */
bool COption::ConvertString(varprop::VariantValue & value, varprop::VT_TYPE nType)
{
	String svalue = value.GetString();
	switch(nType)
	{
	case varprop::VT_INT:
		// Convert string to integer
		{
			int val=0;
			if (!GetAsInt(svalue.c_str(), val))
				return false;
			value.SetInt(val);
			return true;
		}
	case varprop::VT_BOOL:
		// Convert string to boolean
		{
			std::transform(svalue.begin(), svalue.end(), svalue.begin(), ::tolower);
			if (svalue == _T("1") || !svalue.compare(_T("yes"))
				|| !svalue.compare(_T("true")))
			{
				value.SetBool(true);
				return true;
			}
			if (svalue == _T("0") || !svalue.compare(_T("no"))
				|| !svalue.compare(_T("false")))
			{
				value.SetBool(false);
				return true;
			}
			return false;
		}
	}
	return false;
}
Beispiel #2
0
String __fastcall TObjFrm::GetAsString(int n)
{
String res="";
if (CompList->Items[n])
    {
    TCustomEdit *m=dynamic_cast<TCustomEdit*>((TObject*)CompList->Items[n]);
    if (m)
        res=m->Text;
    else
        res=String(GetAsInt(n));
    }
return res;
}
Beispiel #3
0
void DiGLTextureDrv::Bind(uint32 samplerIndex)
{
    if (!mTextureID)
    {
        glBindTexture(mGLTextureType, 0);
    }
    else
    {
        glEnable(mGLTextureType);
        glActiveTextureARB(GL_TEXTURE0 + samplerIndex);
        glBindTexture(mGLTextureType, mTextureID);

        glTexParameteri(mGLTextureType, GL_TEXTURE_WRAP_S, DiGLTypeMappings::GLAddressMode[mParent->GetAddressingU()]);
        glTexParameteri(mGLTextureType, GL_TEXTURE_WRAP_T, DiGLTypeMappings::GLAddressMode[mParent->GetAddressingV()]);

        if (mParent->GetAddressingU() == AM_BORDER ||
                mParent->GetAddressingV() == AM_BORDER)
        {
            glTexParameterfv(mGLTextureType, GL_TEXTURE_BORDER_COLOR, mParent->GetBorderColor().Ptr());
        }

        DiFilterType filter = mParent->GetFilter();
        if (filter == FILTER_DEFAULT)
        {
            auto filterVar = CommandMgr->GetConsoleVar("def_filter");
            if (filterVar)
                filter = (DiFilterType)filterVar->GetAsInt();
            else
                filter = FILTER_BILINEAR;
        }

        // Filtering
        switch (filter)
        {
        case FILTER_NEAREST:
            glTexParameteri(mGLTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
            glTexParameteri(mGLTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
            break;

        case FILTER_BILINEAR:
            if (mParent->GetNumLevels() < 2)
                glTexParameteri(mGLTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            else
                glTexParameteri(mGLTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
            glTexParameteri(mGLTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            break;

        case FILTER_ANISOTROPIC:
        case FILTER_TRILINEAR:
            if (mParent->GetNumLevels() < 2)
                glTexParameteri(mGLTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
            else
                glTexParameteri(mGLTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
            glTexParameteri(mGLTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
            break;

        default:
            break;
        }

#ifndef GL_ES_VERSION_2_0
        //if (support anisotropy)   //TODO, detect the caps
        {
            glTexParameterf(mGLTextureType, GL_TEXTURE_MAX_ANISOTROPY_EXT, filter == FILTER_ANISOTROPIC ?
                            CommandMgr->GetConsoleVar("tex_anisotropy")->GetAsFloat() : 1.0f);
        }
#endif
    }
}