Exemple #1
0
int loadTexture(const char* filename)
{
    H3DRes res;
    try
    {
        res = _loadResource(H3DResTypes::Texture, filename);
    }
    catch(...)
    {
        dumpMessages();
        throw;
    }
    int handle = TextureManager::addTexture(res);
    dumpMessages();
    return handle;
}
bool xGpuProgramManager::_loadResource(const xGpuProgramName&  strResName  , IGpuProgram* & pRes , int& ResSize, unsigned int arg)
{
	ds_wstring _vsName;
	ds_wstring _psName;
	ds_wstring _gsName;
	if(strResName.hasShader() == false)
	{
		ds_wstring _name;
		strResName.toName(_name);
		return _loadResource( _name.c_str() , pRes , ResSize, arg);
	}
	else
	{
		bool needDeletePRes = false;
		if(pRes == NULL)
		{
			needDeletePRes = true;
			pRes = m_pRenderApi->createGpuProgram( );
		}

		const wchar_t* shaderNames[eShader_Max]; 
		for(int i = 0 ; i < eShader_Max ; i ++)
			shaderNames[i] = NULL;
		strResName.toStdName(shaderNames);

		
		if( pRes->load( shaderNames , arg ) )
		{
			ResSize = 1;
			XEVOL_LOG(eXL_DEBUG_TIPS, L"Load a gpu program package\n" );
			return true;
		}

		//如果是创建出来的就删除掉
		if(needDeletePRes)
		{
			pRes->KillObject();
			pRes = NULL;
		}
		return false;


	}
	return true;
}
Exemple #3
0
void setGeo(const char* filename)
{
    H3DRes res;
    try
    {
        res = _loadResource(H3DResTypes::Geometry, filename);
    }
    catch(...)
    {
        dumpMessages();
        throw;
    }
    if(_geometry) h3dUnloadResource(_geometry);
    _geometry = res;

    if(_geometry != 0 && _shader != 0)
        Viewer::newModel(_geometry, _mat_builder->getRes());
    dumpMessages();
}
Exemple #4
0
void setShader(const char* filename)
{
    H3DRes res;
    char res_name[64];
    snprintf(res_name, 64, "_res%i", _res_loaded++);
    try
    {
        res = _loadResource(res_name, H3DResTypes::Shader, filename);
    }
    catch(...)
    {
        dumpMessages();
        throw;
    }
    if(_shader) h3dUnloadResource(_shader);
    _shader = res;

    _mat_builder->setShader(res_name);
    _mat_builder->build();
    dumpMessages();
}