void WINAPI QERApp_ReloadShaderFile( const char* name ) { brush_t *b; face_t *f; #ifdef _DEBUG // check the shader name is a reletive path // I hacked together a few quick tests to make sure :-) if (strstr( name, ":\\" ) || !strstr( name, "scripts" )) Sys_Printf("WARNING: is %s a reletive path to a shader file? (QERApp_ReloadShaderFile\n"); #endif // in the actives and global shaders lists, decref and unhook the shaders //++timo NOTE: maybe we'd like to keep track of the shaders we are unhooking? g_ActiveShaders.ReleaseForShaderFile( name ); g_Shaders.ReleaseForShaderFile( name ); // go through a reload of the shader file QERApp_LoadShaderFile( name ); // scan all the brushes, replace all the old ones by refs to their new equivalents for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next) { if (b->patchBrush && !strcmp(b->pPatch->pShader->getShaderFileName(), name)) SetShader(b->pPatch); else for (f=b->brush_faces ; f ; f=f->next) if (!strcmp(f->pShader->getShaderFileName(), name)) SetShader(f); } for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next) { if (b->patchBrush && !strcmp(b->pPatch->pShader->getShaderFileName(), name)) SetShader(b->pPatch); else for (f=b->brush_faces ; f ; f=f->next) if (!strcmp(f->pShader->getShaderFileName(), name)) SetShader(f); } // call Texture_ShowInUse to clean and display only what's required Texture_ShowInuse(); // Texture_SortTextures(); QERApp_SortActiveShaders(); Sys_UpdateWindows (W_TEXTURE); }
void WINAPI QERApp_ReloadShaderFile( const char *name ){ brush_t *b; face_t *f; brush_t *active_brushes; brush_t *selected_brushes; brush_t *filtered_brushes; // Sys_Printf("TODO: QERApp_ReloadShaderFile\n"); active_brushes = g_DataTable.m_pfnActiveBrushes(); selected_brushes = g_DataTable.m_pfnSelectedBrushes(); filtered_brushes = g_DataTable.m_pfnFilteredBrushes(); #ifdef _DEBUG // check the shader name is a reletive path // I hacked together a few quick tests to make sure :-) if ( strstr( name, ":\\" ) || !strstr( name, "scripts" ) ) { Sys_Printf( "WARNING: is %s a reletive path to a shader file? (QERApp_ReloadShaderFile\n" ); } #endif // in the actives and global shaders lists, decref and unhook the shaders //++timo NOTE: maybe we'd like to keep track of the shaders we are unhooking? g_ActiveShaders.ReleaseForShaderFile( name ); g_Shaders.ReleaseForShaderFile( name ); // go through a reload of the shader file QERApp_LoadShaderFile( name ); // scan all the brushes, replace all the old ones by refs to their new equivalents for ( b = active_brushes->next; b != NULL && b != active_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } for ( b = selected_brushes->next; b != NULL && b != selected_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } // do that to the filtered brushes as well (we might have some region compiling going on) for ( b = filtered_brushes->next; b != NULL && b != filtered_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } // call Texture_ShowInUse to clean and display only what's required g_ShadersTable.m_pfnTexture_ShowInuse(); QERApp_SortActiveShaders(); g_FuncTable.m_pfnSysUpdateWindows( W_TEXTURE ); }