IShader* WINAPI QERApp_Shader_ForName(const char* name) { //++timo FIXME: do we allow NULL and "" calling? // how does it deal with notexture? can we simply replace by "textures/radiant/notex"? if (name == NULL || strlen(name) == 0) { Sys_Printf("FIXME: name == NULL || strlen(name) == 0 in QERApp_Shader_ForName\n"); return QERApp_Shader_ForName("radiant/notex"); //++timo ??? } // entities that should be represented with plain colors instead of textures // request a texture name with (r g b) (it's stored in their class_t) if (name[0]=='(') { return QERApp_ColorShader_ForName(name); } CShader* pShader = static_cast<CShader*>(QERApp_Try_Shader_ForName( name )); if (pShader) { pShader->SetDisplayed( true ); return pShader; } // we don't know this shader, maybe it's a straight texture pShader = new CShader; pShader->CreateDefault( name ); // hook it into the shader list g_Shaders.Add( (LPVOID)pShader ); pShader->IncRef(); // if it can't find the texture, "textures/radiant/notex" will be used pShader->Activate(); pShader->SetDisplayed( true ); return pShader; }
IShader *WINAPI QERApp_CreateShader_ForTextureName( const char *name ){ CShader *pShader; pShader = new CShader; // CreateDefault expects a texture / shader name relative to the "textures" directory // (cause shader names are reletive to "textures/") pShader->CreateDefault( name ); // hook it into the shader list g_Shaders.Add( (void *) pShader ); pShader->IncRef(); // if it can't find the texture, SHADER_NOT_FOUND will be used // Hydra: display an error message, so the user can quickly find a list of missing // textures by looking at the console. if ( !pShader->Activate() ) { Sys_Printf( "WARNING: Activate shader failed for %s\n",pShader->getName() ); } pShader->SetDisplayed( true ); return pShader; }