예제 #1
0
// will free all GL binded qtextures and shaders
// NOTE: doesn't make much sense out of Radiant exit or called during a reload
void WINAPI QERApp_FreeShaders()
{
	int i;
	brush_t	*b;

	// store the shader names used by the patches
	for(i=0; i<PatchShaders.GetSize(); i++)
		delete PatchShaders.GetAt(i);
	PatchShaders.RemoveAll();
	for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next)
  {
    if (b->patchBrush)
			PushPatch(b->pPatch);
  }
	for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next)
  {
    if (b->patchBrush)
			PushPatch(b->pPatch);
  }

	// reload shaders
	// empty the actives shaders list
	g_ActiveShaders.ReleaseAll();
	g_Shaders.ReleaseAll();
	// empty the main g_qeglobals.d_qtextures list
	// FIXME: when we reload later on, we need to have the shader names
	// for brushes it's stored in the texdef
	// but patches don't have texdef
	// see bug 104655 for details
	// so the solution, build an array of patchMesh_t* and their shader names
#ifdef _DEBUG
	Sys_Printf("FIXME: bug 104655 workaround\n");
#endif

	// NOTE: maybe before we'd like to set all qtexture_t in the shaders list to notex?
	// NOTE: maybe there are some qtexture_t we don't want to erase? For plain color faces maybe?
	// NOTE: the GL textures are freed later on
  if (g_qeglobals.d_qtextures)
  {
	  qtexture_t* pTex = g_qeglobals.d_qtextures->next;
    while (pTex != NULL && pTex != g_qeglobals.d_qtextures)
    {
      qtexture_t* pNextTex = pTex->next;
  	  if (g_qeglobals.bSurfacePropertiesPlugin)
	    {
		    // Timo
		    // Surface properties plugin
#ifdef _DEBUG
  		  if ( !pTex->pData )
	  		  Sys_Printf("WARNING: found a qtexture_t* with no IPluginQTexture\n");
#endif
  		  if ( pTex->pData )
	  		  GETPLUGINTEXDEF(pTex)->DecRef();
  	  }
	    free(pTex);
      pTex = pNextTex;
    }
  }
	// free GL bindings
  GLuint* pGln = new GLuint[texture_extension_number-1];
  qglGenTextures(texture_extension_number-1, pGln);
  QE_CheckOpenGLForErrors();
  qglDeleteTextures(texture_extension_number-1, pGln);
  QE_CheckOpenGLForErrors();
  delete []pGln;
  texture_extension_number = 1;
	g_qeglobals.d_qtextures = NULL;
  // free the map
  g_qeglobals.d_qtexmap->RemoveAll();
}
예제 #2
0
// will free all GL binded qtextures and shaders
// NOTE: doesn't make much sense out of Radiant exit or called during a reload
void WINAPI QERApp_FreeShaders ()
{
  int i;
  brush_t *b;
  brush_t *active_brushes;
  brush_t *selected_brushes;
  brush_t *filtered_brushes;
  qtexture_t **d_qtextures;

  active_brushes = g_DataTable.m_pfnActiveBrushes ();
  selected_brushes = g_DataTable.m_pfnSelectedBrushes ();
  filtered_brushes = g_DataTable.m_pfnFilteredBrushes ();
  d_qtextures = g_ShadersTable.m_pfnQTextures ();

  // store the shader names used by the patches
  for (i = 0; i < PatchShaders.GetSize (); i++)
    delete static_cast < patchMesh_t * >(PatchShaders.GetAt (i));
  PatchShaders.RemoveAll ();

  for (b = active_brushes->next; b != NULL && b != active_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }
  for (b = selected_brushes->next; b != NULL && b != selected_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }
  for (b = filtered_brushes->next; b != NULL && b != filtered_brushes; b = b->next)
  {
    if (b->patchBrush)
      PushPatch (b->pPatch);
  }

  // reload shaders
  // empty the actives shaders list
  g_ActiveShaders.ReleaseAll ();
  g_Shaders.ReleaseAll ();
  // empty the main g_qeglobals.d_qtextures list
  // FIXME: when we reload later on, we need to have the shader names
  // for brushes it's stored in the texdef
  // but patches don't have texdef
  // see bug 104655 for details
  // so the solution, build an array of patchMesh_t* and their shader names
#ifdef _DEBUG
  Sys_Printf ("FIXME: patch shader reload workaround (old fenris? bug 104655)\n");
#endif

  //GtkWidget *widget = g_QglTable.m_pfn_GetQeglobalsGLWidget ();
  GHashTable *texmap = g_ShadersTable.m_pfnQTexmap ();

  // NOTE: maybe before we'd like to set all qtexture_t in the shaders list to notex?
  // NOTE: maybe there are some qtexture_t we don't want to erase? For plain color faces maybe?
  while (*d_qtextures)
  {
    qtexture_t *pTex = *d_qtextures;
    qtexture_t *pNextTex = pTex->next;

    //if (widget != NULL)
    g_QglTable.m_pfn_qglDeleteTextures (1, &pTex->texture_number);

    g_hash_table_remove (texmap, pTex->name);
      
    // all qtexture_t should be manipulated with the glib alloc handlers for now
    g_free (pTex);
    *d_qtextures = pNextTex;
  }

  g_QglTable.m_pfn_QE_CheckOpenGLForErrors ();
}