Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

TexWnd.cpp File Reference

#include "stdafx.h"
#include <assert.h>
#include "Radiant.h"
#include "TexWnd.h"
#include "qe3.h"
#include "io.h"
#include "PrefsDlg.h"
#include "shaderinfo.h"
#include "pakstuff.h"
#include "str.h"

Include dependency graph for TexWnd.cpp:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  SkinInfo

Defines

#define FONT_HEIGHT   10
#define MAX_TEXTUREDIRS   128
#define TYP_MIPTEX   68

Functions

 BEGIN_MESSAGE_MAP (CTexWnd, CWnd) ON_WM_CREATE() ON_WM_SIZE() ON_WM_PARENTNOTIFY() ON_WM_TIMER() ON_WM_KEYDOWN() ON_WM_KEYUP() ON_WM_PAINT() ON_WM_VSCROLL() ON_COMMAND(ID_TEXTURES_FLUSH
void Delay (float fSeconds)
void DemandLoadShaderTexture (qtexture_t *q, CShaderInfo *pShader)
bool DoesFileExist (const char *pBuff, long &lSize)
void FillTextureMenu (CStringArray *pArray)
HWND FindEditWindow ()
void FreeShaders ()
const char * GetTextureExtension (int nIndex)
int GetTextureExtensionCount ()
CShaderInfohasShader (const char *pName)
int imax (int iFloor, int i)
 IMPLEMENT_DYNCREATE (CTexWnd, CWnd)
void LoadShader (char *pFilename, qtexture_t *q)
void LoadShaders ()
void LoadShadersFromDir (const char *pPath)
OnTexturesFlush ON_BN_CLICKED (1200, OnShaderClick) END_MESSAGE_MAP() LONG WINAPI TexWndProc(HWND hWnd
void R_MipMap (byte *in, int &width, int &height)
void ReloadShaders ()
void ReplaceQTexture (qtexture_t *pOld, qtexture_t *pNew, brush_t *pList)
void SelectTexture (int mx, int my, bool bShift, bool bFitScale=false)
CShaderInfoSetNameShaderInfo (qtexture_t *q, const char *pPath, const char *pName)
void SetTexParameters (void)
bool ShaderQTextureExists (const char *pName)
void SortTextures (void)
void Texture_Cleanup (CStringList *pList)
void Texture_ClearInuse (void)
qtexture_tTexture_CreateSolid (const char *name)
void Texture_Draw2 (int width, int height)
void Texture_Flush (bool bReload)
void Texture_FlushUnused ()
qtexture_tTexture_ForName (const char *name, bool bReplace, bool bShader, bool bNoAlpha, bool bReload, bool makeShader)
qtexture_tTexture_ForNamePath (char *name, char *pFullPath)
void Texture_Init (bool bHardInit)
void Texture_InitPalette (byte *pal)
void Texture_LoadFromPlugIn (LPVOID vp)
int WINAPI Texture_LoadSkin (char *pName, int *pnWidth, int *pnHeight)
qtexture_tTexture_LoadTexture (miptex_t *qtex)
qtexture_tTexture_LoadTGATexture (unsigned char *pPixels, int nWidth, int nHeight, char *pPath)
qtexture_tTexture_LoadTGATexture (unsigned char *pPixels, int nWidth, int nHeight, char *pPath, int nFlags, int nContents, int nValue)
qtexture_tTexture_MakeDefault (void)
qtexture_tTexture_MakeNoshadertexture (const char *name)
void Texture_MakeNotexture (void)
void Texture_MouseDown (int x, int y, int buttons)
void Texture_MouseMoved (int x, int y, int buttons)
void Texture_MouseUp (int x, int y, int buttons)
qtexture_tTexture_NextPos (int *x, int *y)
void Texture_Remove (qtexture_t *q)
void Texture_ResetPosition ()
void Texture_SetInuse (void)
void Texture_SetMode (int iMenu)
void Texture_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, IPluginTexdef *pTexdef, bool bSetSelection)
void Texture_ShowAll ()
void Texture_ShowDirectory (char *pPath, bool bLinked)
void Texture_ShowDirectory (int menunum, bool bLinked)
void Texture_ShowInuse (void)
void Texture_StartPos (void)
void ViewShader (const char *pFile, const char *pName)

Variables

int current_row
qtexture_tcurrent_texture = NULL
int current_x
int current_y
bool g_bFilterEnabled = false
char g_cLastChar
qboolean g_dontuse = true
CPtrArray g_lstShaders
CPtrArray g_lstSkinCache
int g_nCurrentTextureMenuName
int g_nTextureOffset = 0
int g_nTimerHandle = -1
qtexture_tg_pluginTexture = NULL
CString g_strFilter
HFONT ghFont = NULL
Str m_gStr
qboolean nomips = false
qtexture_tnotexture = NULL
HDC s_hdcTexture = NULL
HGLRC s_hglrcTexture = NULL
unsigned tex_palette [256]
char texture_directory [128]
int texture_extension_number = 1
char texture_menunames [MAX_TEXTUREDIRS][128]
int texture_mode = GL_LINEAR_MIPMAP_LINEAR
int texture_nummenus
qboolean texture_showinuse
int textures_cursorx
int textures_cursory
OnTexturesFlush UINT uMsg
OnTexturesFlush UINT WPARAM wParam


Define Documentation

#define FONT_HEIGHT   10
 

Definition at line 54 of file TexWnd.cpp.

Referenced by Texture_Draw2(), Texture_NextPos(), and Texture_SetTexture().

#define MAX_TEXTUREDIRS   128
 

Definition at line 84 of file TexWnd.cpp.

#define TYP_MIPTEX   68
 

Definition at line 46 of file TexWnd.cpp.


Function Documentation

BEGIN_MESSAGE_MAP CTexWnd  ,
CWnd 
 

void Delay float  fSeconds  ) 
 

Definition at line 2148 of file TexWnd.cpp.

References DWORD.

Referenced by ViewShader().

02149 {
02150   DWORD dw = ::GetTickCount();
02151   DWORD dwTil = dw + (fSeconds * 1000);
02152   while (::GetTickCount() < dwTil)
02153   {
02154     MSG msg;
02155     if (::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) 
02156     { 
02157       TranslateMessage(&msg);
02158       DispatchMessage(&msg);
02159     }
02160   }
02161 }

void DemandLoadShaderTexture qtexture_t q,
CShaderInfo pShader
 

Definition at line 816 of file TexWnd.cpp.

References qtexture_s::bFromShader, QEGlobals_t::d_project_entity, qtexture_s::fTrans, g_qeglobals, CShaderInfo::m_fTransValue, CShaderInfo::m_nFlags, CShaderInfo::m_pQTexture, CShaderInfo::m_strName, CShaderInfo::m_strShaderName, CShaderInfo::m_strTextureName, qtexture_s::name, qtexture_s::nShaderFlags, NULL, q, qtexture_t, qtexture_s::shadername, sprintf(), strcpy(), StripExtension(), Sys_Printf(), Texture_ForName(), Texture_ForNamePath(), and ValueForKey().

Referenced by LoadShader(), LoadShadersFromDir(), and Texture_ForName().

00817 {
00818   char cWork[1024];
00819   char cWork2[1024];
00820   strcpy(cWork, (pShader->m_strTextureName.GetLength() > 0) ? pShader->m_strTextureName  : pShader->m_strName);
00821   StripExtension(cWork);
00822   // TTimo: if the shader has a m_fTransValue != 1.0f, ignore the alpha channel when loading the texture
00823   // in some cases (common/weapclip) the 32bit .tga has an empty alpha channel,
00824   // causing a display bug in the camera view (brush does not seemed drawn since alpha==0 for the texture)
00825   // NOTE: the workaround is not perfect, the same texture may have been loaded earlier with it's alpha channel
00826   q = Texture_ForName (cWork, false, true, pShader->m_fTransValue != 1.0f, true, false);
00827 
00828   if (q == NULL || q == notexture) {
00829     sprintf(cWork2, "%s/%s",ValueForKey(g_qeglobals.d_project_entity, "basepath"), cWork);
00830     q = Texture_ForNamePath( cWork, cWork2);
00831 
00832     if (q == NULL || q == notexture) {
00833       q = Texture_ForName (cWork, false, true, pShader->m_fTransValue != 1.0f, true, true);
00834     }
00835   }
00836 
00837   if (q != NULL && q != notexture)
00838   {
00839     pShader->m_pQTexture = q;
00840     strcpy(q->shadername, pShader->m_strShaderName);
00841     q->bFromShader = true;
00842     q->fTrans = pShader->m_fTransValue;
00843     q->nShaderFlags = pShader->m_nFlags;
00844     strcpy(q->name, pShader->m_strName );
00845   }
00846   else
00847   {
00848     Sys_Printf("Could not load shader editor image %s\n", cWork);
00849   }
00850 }

Here is the call graph for this function:

bool DoesFileExist const char *  pBuff,
long &  lSize
 

Definition at line 78 of file QE3.CPP.

References file.

Referenced by Map_Snapshot().

00079 {
00080   CFile file;
00081   if (file.Open(pBuff, CFile::modeRead | CFile::shareDenyNone))
00082   {
00083     lSize += file.GetLength();
00084     file.Close();
00085     return true;
00086   }
00087   return false;
00088 }

void FillTextureMenu CStringArray *  pArray  ) 
 

Definition at line 1485 of file TexWnd.cpp.

References AddToDirListAlphabetized(), ClearDirList(), CMD_TEXTUREWAD, QEGlobals_t::d_hwndMain, QEGlobals_t::d_project_entity, DIRLIST, FROMDISK, g_pParentWnd, g_qeglobals, GetPackTextureDirs(), CMainFrame::GetPlugInMgr(), CPlugInManager::GetTextureInfo(), i, _QERTextureInfo::m_bWadStyle, MENU_TEXTURE, DirListStruct::next, sprintf(), strcat(), strcpy(), texture_menunames, texture_nummenus, and ValueForKey().

Referenced by CDialogTextures::OnInitDialog(), QE_LoadProject(), and CMainFrame::SetButtonMenuStates().

01486 {
01487     HMENU   hmenu;
01488     int     i;
01489     struct _finddata_t fileinfo;
01490     int     handle;
01491     char    dirstring[1024];
01492     char    *path;
01493     DIRLIST *list = NULL, *temp;
01494 
01495   if (g_pParentWnd->GetPlugInMgr().GetTextureInfo() != NULL)
01496   {
01497     if (g_pParentWnd->GetPlugInMgr().GetTextureInfo()->m_bWadStyle)
01498       return;
01499   }
01500 
01501     hmenu = GetSubMenu (GetMenu(g_qeglobals.d_hwndMain), MENU_TEXTURE);
01502 
01503     // delete everything
01504     for (i=0 ; i<texture_nummenus ; i++)
01505         DeleteMenu (hmenu, CMD_TEXTUREWAD+i, MF_BYCOMMAND);
01506 
01507   texture_nummenus = 0;
01508 
01509     // add everything
01510   if (g_qeglobals.d_project_entity)
01511   {
01512     //--if (g_PrefsDlg.m_bUseShaders)
01513     //--{
01514       //--  path = ValueForKey (g_qeglobals.d_project_entity, "basepath");
01515       //--  sprintf (dirstring, "%s/scripts/*.shader", path);
01516     //--
01517     //--}
01518     //--else
01519     //--{
01520         path = ValueForKey (g_qeglobals.d_project_entity, "texturepath");
01521         sprintf (dirstring, "%s/*.*", path);
01522     //--}
01523 
01524       handle = _findfirst (dirstring, &fileinfo);
01525       if (handle != -1)
01526     {
01527         do
01528         {
01529         //--if (g_PrefsDlg.m_bUseShaders)
01530         //--{
01531             //--  if ((fileinfo.attrib & _A_SUBDIR))
01532         //--    continue;
01533         //--}
01534         //--else
01535         //--{
01536               if (!(fileinfo.attrib & _A_SUBDIR))
01537                 continue;
01538               if (fileinfo.name[0] == '.')
01539                 continue;
01540         //--}
01541         // add this directory to the menu
01542           AddToDirListAlphabetized(&list, fileinfo.name, FROMDISK);
01543         } while (_findnext( handle, &fileinfo ) != -1);
01544 
01545         _findclose (handle);
01546     }
01547 
01548     //--if (!g_PrefsDlg.m_bUseShaders)
01549     //--{
01550       GetPackTextureDirs(&list);
01551     //--}
01552 
01553       for(temp = list; temp; temp = temp->next)
01554       {
01555           AppendMenu (hmenu, MF_ENABLED|MF_STRING, CMD_TEXTUREWAD+texture_nummenus, (LPCTSTR)temp->dirname);
01556           strcpy (texture_menunames[texture_nummenus], temp->dirname);
01557       //--if (!g_PrefsDlg.m_bUseShaders)
01558       //--{
01559             strcat (texture_menunames[texture_nummenus], "/");
01560       //--}
01561       if (pArray)
01562         pArray->Add(temp->dirname);
01563           if (++texture_nummenus == MAX_TEXTUREDIRS)
01564            break;
01565       }
01566 
01567       ClearDirList(&list);
01568   }
01569 
01570 
01571 }

Here is the call graph for this function:

HWND FindEditWindow  ) 
 

Definition at line 2133 of file TexWnd.cpp.

References NULL.

Referenced by ViewShader().

02134 {
02135   HWND hwnd = FindWindow("TEditPadForm", NULL);
02136   HWND hwndEdit = NULL;
02137   if (hwnd != NULL)
02138   {
02139     HWND hwndTab = FindWindowEx(hwnd, NULL, "TTabControl", NULL);
02140     if (hwndTab != NULL)
02141     {
02142       hwndEdit = FindWindowEx(hwndTab, NULL, "TRicherEdit", NULL);
02143     }
02144   }
02145   return hwndEdit;
02146 }

void FreeShaders  ) 
 

Definition at line 3085 of file TexWnd.cpp.

References g_lstShaders, and i.

Referenced by CMainFrame::OnDestroy(), and ReloadShaders().

03086 {
03087   int nSize = g_lstShaders.GetSize();
03088   for (int i = 0; i < nSize; i++)
03089   {
03090     CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));
03091     delete pInfo;
03092   }
03093 
03094   g_lstShaders.RemoveAll();
03095 }

const char* GetTextureExtension int  nIndex  ) 
 

Definition at line 152 of file TexWnd.cpp.

References g_pParentWnd, g_PrefsDlg, CMainFrame::GetPlugInMgr(), CPlugInManager::GetTextureInfo(), CPrefsDlg::m_bHiColorTextures, and _QERTextureInfo::m_TextureExtension.

Referenced by Texture_ForName(), and Texture_ShowDirectory().

00153 {
00154   if ( nIndex == 0)
00155   {
00156     _QERTextureInfo *pInfo = g_pParentWnd->GetPlugInMgr().GetTextureInfo();
00157     const char *pTex = (pInfo != NULL) ? pInfo->m_TextureExtension : NULL;
00158     return (pTex == NULL) ? (g_PrefsDlg.m_bHiColorTextures == FALSE) ? "wal" : "tga" : pTex;
00159   }
00160   // return jpg for 2nd extension
00161   return "jpg";
00162 }

Here is the call graph for this function:

int GetTextureExtensionCount  ) 
 

Definition at line 147 of file TexWnd.cpp.

Referenced by Texture_ShowDirectory().

00148 {
00149   return 2;
00150 }

CShaderInfo* hasShader const char *  pName  ) 
 

Definition at line 126 of file TexWnd.cpp.

References g_lstShaders, i, and CShaderInfo::m_strName.

Referenced by QERApp_HasShader(), SetNameShaderInfo(), and Texture_ForName().

00127 {
00128   int nSize = g_lstShaders.GetSize();
00129   for (int i = 0; i < nSize; i++)
00130   {
00131     CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));
00132     if (pInfo != NULL)
00133     {
00134       if (pInfo->m_strName.CompareNoCase(pName) == 0)
00135       {
00136         return pInfo;
00137       }
00138     }
00139   }
00140   return NULL;
00141 }

int imax int  iFloor,
int  i
 

Definition at line 2355 of file TexWnd.cpp.

References i.

02355 { if (i>iFloor) return iFloor; return i; }

IMPLEMENT_DYNCREATE CTexWnd  ,
CWnd 
 

void LoadShader char *  pFilename,
qtexture_t q
 

Definition at line 853 of file TexWnd.cpp.

References atof(), copystring(), DemandLoadShaderTexture(), FindReplace(), free(), g_lstShaders, g_PrefsDlg, GetToken(), LoadFile(), CShaderInfo::m_fTransValue, CShaderInfo::m_nFlags, CPrefsDlg::m_nShader, CShaderInfo::m_strName, CShaderInfo::m_strShaderName, CShaderInfo::m_strTextureName, n, PakLoadAnyFile(), q, QE_ConvertDOSToUnixName(), qtexture_t, CShaderInfo::setName(), ShaderQTextureExists(), StartTokenParsing(), strcmp(), strstr(), and Sys_Printf().

Referenced by LoadShaders().

00854 {
00855   char* pBuff = NULL;
00856   CString strTexture;
00857   int nSize = LoadFile(pFilename, reinterpret_cast<void**>(&pBuff));
00858   if (nSize == -1)
00859   {
00860     nSize = PakLoadAnyFile(pFilename, reinterpret_cast<void**>(&pBuff));
00861   }
00862   if (nSize > 0)
00863   {
00864     StartTokenParsing(pBuff);
00865     while (GetToken(true))
00866     {
00867       // first token should be the path + name.. (from base)
00868       CShaderInfo *pShader = new CShaderInfo();
00869       pShader->setName(token);
00870       pShader->m_strShaderName = pFilename;
00871       strTexture = token;
00872       bool bGood = true;
00873       float fTrans = 1.0;
00874       GetToken(true);
00875       if (strcmp(token, "{"))
00876       {
00877         bGood = false;
00878         break;
00879       }
00880       else
00881       {
00882         // we need to read until we hit a balanced }
00883         int nMatch = 1;
00884         while (nMatch > 0 && GetToken(true))
00885         {
00886           if (strcmp(token, "{") == 0)
00887           {
00888             nMatch++;
00889           }
00890           else if (strcmp(token, "}") == 0)
00891           {
00892             nMatch--;
00893           }
00894           else if (strcmpi(token, "qer_nocarve") == 0)
00895           {
00896             pShader->m_nFlags |= QER_NOCARVE;
00897           }
00898           else if (strcmpi(token, "qer_trans") == 0)
00899           {
00900             if (GetToken(true))
00901             {
00902               fTrans = atof(token);
00903             }
00904             pShader->m_nFlags |= QER_TRANS;
00905           }
00906           else if (strcmpi(token, "qer_editorimage") == 0)
00907           {
00908             if (GetToken(true))
00909             {
00910               char* pTex = copystring(token);
00911                 QE_ConvertDOSToUnixName( pTex, pTex );
00912               CString str = pTex;
00913               free (pTex);
00914               FindReplace(str, "textures/", "");
00915               FindReplace(str, ".tga", "");
00916               int nPos = str.Find('/');
00917               if (nPos == -1)
00918               {
00919                 nPos = str.Find('\\');
00920               }
00921               if (nPos >= 0)
00922               {
00923                 pShader->m_strTextureName = str;
00924                               pShader->m_strTextureName.MakeLower();    //avoid problems with case
00925 /*
00926                 else
00927                 {
00928                   CString strPath = str.Left(nPos+1);
00929                   DeferredShaderLoad *deferred = new DeferredShaderLoad(str, pShader->m_strName, strPath); 
00930                   g_lstDeferred.Add(deferred);
00931                 }
00932 */
00933               }
00934             }
00935           }
00936           else if (strcmpi(token, "surfaceparm") == 0)
00937           {
00938             //--while (GetToken(false))
00939             //--{
00940             //--
00941             //--}
00942             if (GetToken(true))
00943             {
00944               // next token should be a surface parm
00945               //--if (strcmpi(token, "trans") == 0)
00946               //--{
00947               //--  fTrans = 0.33;
00948               //--}
00949               if (strcmpi(token, "fog") == 0)
00950               {
00951                 if (fTrans == 1.0) // has not been explicitly set by qer_trans
00952                 {
00953                   fTrans = 0.35;
00954                 }
00955               }
00956             }
00957           }
00958         }
00959         if (nMatch != 0)
00960         {
00961           bGood = false;
00962           break;
00963         }
00964       }
00965       //--if (bGood && q)
00966       if (bGood)
00967       {
00968         pShader->m_fTransValue = fTrans;
00969         g_lstShaders.Add(pShader);
00970 
00971         int n = g_PrefsDlg.m_nShader;
00972         if (g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_ALL || (g_PrefsDlg.m_nShader == CPrefsDlg::SHADER_COMMON && strstr(pShader->m_strName, "common" )))
00973         {
00974 // new 
00975           if (pShader->m_strTextureName.GetLength() > 0)
00976           {
00977             if (!ShaderQTextureExists(pShader->m_strName))
00978             {
00979               DemandLoadShaderTexture(q, pShader);
00980             }
00981           }
00982         }
00983 // end new 
00984         //--q->bFromShader = true;
00985         //--q->fTrans = fTrans;
00986 
00987         //--// good texture here
00988         //--//Sys_Printf("Test load texture %s\n", strTexture);
00989         //--// FIXME.. this is a load of crap
00990         //--strcpy(dirstring, strTexture);
00991         //--QE_ConvertDOSToUnixName(dirstring, dirstring);
00992         //--strTexture = dirstring;
00993         //--FindReplace(strTexture, "textures/", "");
00994             //--qtexture_t *q = Texture_ForName (strTexture.GetBuffer(0));
00995         //--if (q != NULL)
00996         //--{
00997         //--  q->bFromShader = true;
00998         //--  q->fTrans = fTrans;
00999         //--}
01000       }
01001       else
01002       {
01003         Sys_Printf("Error parsing shader at texture %s\n", strTexture);
01004       }
01005 
01006     }
01007     free (pBuff);
01008   }
01009   else
01010   {
01011     Sys_Printf("Unabled to read shader %s\n", pFilename);
01012   }
01013 }

Here is the call graph for this function:

void LoadShaders  ) 
 

Definition at line 3028 of file TexWnd.cpp.

References QEGlobals_t::d_project_entity, free(), g_qeglobals, GetToken(), LoadFile(), LoadShader(), PakLoadAnyFile(), POSITION, sprintf(), StartTokenParsing(), Sys_Printf(), and ValueForKey().

Referenced by ReloadShaders(), and Texture_Init().

03029 {
03030     char    dirstring[1024];
03031     char    *path;
03032     //struct _finddata_t fileinfo;
03033     //int       handle;
03034   path = ValueForKey (g_qeglobals.d_project_entity, "basepath");
03035   sprintf (dirstring, "%s/scripts/shaderlist.txt", path);
03036   char *pBuff = NULL;
03037   
03038   int nLen = LoadFile(dirstring, reinterpret_cast<void**>(&pBuff));
03039   if (nLen == -1)
03040   {
03041     nLen = PakLoadAnyFile(dirstring, reinterpret_cast<void**>(&pBuff));
03042   }
03043   if (nLen > 0)
03044   {
03045     CStringList lst;
03046     StartTokenParsing(pBuff);
03047     nLen = 0;
03048     while (GetToken(true))
03049     {
03050       // each token should be a shader filename
03051       sprintf(dirstring, "%s/scripts/%s.shader", path, token);
03052       lst.AddTail(dirstring);
03053       nLen++;
03054     }
03055     POSITION pos = lst.GetHeadPosition();
03056     while (pos != NULL)
03057     {
03058       LoadShader(lst.GetAt(pos).GetBuffer(0), NULL);
03059       lst.GetNext(pos);
03060     }
03061     free(pBuff);
03062   }
03063   else
03064   {
03065     Sys_Printf("Unable to load shaderlist.txt, shaders not loaded!");
03066   }
03067 
03068 /*
03069   handle = _findfirst (dirstring, &fileinfo);
03070   if (handle != -1)
03071   {
03072     do
03073     {
03074       if ((fileinfo.attrib & _A_SUBDIR))
03075         continue;
03076       sprintf(dirstring, "%s/scripts/%s", path, fileinfo.name);
03077       LoadShader(dirstring, NULL);
03078       } while (_findnext( handle, &fileinfo ) != -1);
03079 
03080       _findclose (handle);
03081   }
03082 */
03083 }

Here is the call graph for this function:

void LoadShadersFromDir const char *  pPath  ) 
 

Definition at line 1594 of file TexWnd.cpp.

References DemandLoadShaderTexture(), g_lstShaders, i, CShaderInfo::m_pQTexture, CShaderInfo::m_strName, NULL, q, qtexture_t, and strstr().

Referenced by Texture_ShowDirectory().

01595 {
01596   int nSize = g_lstShaders.GetSize();
01597   for (int i = 0; i < nSize; i++)
01598   {
01599     CShaderInfo *pInfo = reinterpret_cast<CShaderInfo*>(g_lstShaders.ElementAt(i));
01600     if (pInfo != NULL)
01601     {
01602       if (strstr(pInfo->m_strName, pPath) && pInfo->m_pQTexture == NULL && strstr(pInfo->m_strName, "models/player") == NULL)
01603       {
01604         qtexture_t *q = NULL;
01605         DemandLoadShaderTexture(q, pInfo);
01606       }
01607     }
01608   }
01609 }

Here is the call graph for this function:

OnTexturesFlush ON_BN_CLICKED 1200  ,
OnShaderClick 
 

void R_MipMap byte in,
int &  width,
int &  height
 

Definition at line 404 of file TexWnd.cpp.

References byte, height, i, in, j, and width.

Referenced by Texture_LoadSkin(), Texture_LoadTexture(), Texture_LoadTGATexture(), and Upload32().

00405 {
00406     int     i, j;
00407     byte    *out;
00408     int     row;
00409     
00410     row = width * 4;
00411     width >>= 1;
00412     height >>= 1;
00413     out = in;
00414     for (i=0 ; i<height ; i++, in+=row)
00415     {
00416         for (j=0 ; j<width ; j++, out+=4, in+=8)
00417         {
00418             out[0] = (in[0] + in[4] + in[row+0] + in[row+4])>>2;
00419             out[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2;
00420             out[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2;
00421             out[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2;
00422         }
00423     }
00424 }

void ReloadShaders  ) 
 

Definition at line 3097 of file TexWnd.cpp.

References QEGlobals_t::d_qtextures, FreeShaders(), g_qeglobals, LoadShaders(), qtexture_s::name, qtexture_s::next, NULL, qtexture_t, and SetNameShaderInfo().

Referenced by CMainFrame::OnTexturesReloadshaders().

03098 {
03099   FreeShaders();
03100   LoadShaders();
03101   qtexture_t* pTex = g_qeglobals.d_qtextures;
03102   while (pTex != NULL)
03103   {
03104     SetNameShaderInfo(pTex, NULL, pTex->name);
03105     pTex = pTex->next;
03106   }
03107 
03108 }

Here is the call graph for this function:

void ReplaceQTexture qtexture_t pOld,
qtexture_t pNew,
brush_t pList
 

Definition at line 1036 of file TexWnd.cpp.

References brush_s::brush_faces, brush_t, face_s::d_texture, face_t, face_s::next, brush_s::next, Patch_ReplaceQTexture(), brush_s::patchBrush, brush_s::pTerrain, qtexture_t, Terrain_ReplaceQTexture(), and brush_s::terrainBrush.

Referenced by Texture_ForName().

01037 { 
01038     for (brush_t* pBrush = pList->next ; pBrush != pList; pBrush = pBrush->next)
01039     {
01040         if (pBrush->patchBrush)
01041         {
01042             Patch_ReplaceQTexture(pBrush, pOld, pNew);
01043         }
01044         if (pBrush->terrainBrush)
01045         {
01046             Terrain_ReplaceQTexture(pBrush->pTerrain, pOld, pNew);
01047         }
01048 
01049         for (face_t* pFace = pBrush->brush_faces; pFace; pFace = pFace->next)
01050         {
01051             if (pFace->d_texture == pOld)
01052             {
01053             pFace->d_texture = pNew;
01054             }
01055         }
01056         
01057         //Brush_Build(pBrush);
01058     }
01059 }

Here is the call graph for this function:

void SelectTexture int  mx,
int  my,
bool  bShift,
bool  bFitScale = false
 

Definition at line 2218 of file TexWnd.cpp.

References bFitScale, brushprimit_texdef_t, qtexture_s::contents, QEGlobals_t::d_texturewin, qtexture_s::flags, g_pParentWnd, g_PrefsDlg, g_qeglobals, GETPLUGINTEXDEF, qtexture_s::height, texturewin_t::height, QEGlobals_t::m_bBrushPrimitMode, CPrefsDlg::m_bHiColorTextures, CPrefsDlg::m_nTextureScale, memset(), qtexture_s::name, texturewin_t::originy, q, qtexture_t, CMainFrame::SetStatusText(), qtexture_s::shadername, Sys_Status(), Texture_NextPos(), Texture_SetTexture(), Texture_StartPos(), qtexture_s::value, ViewShader(), qtexture_s::width, x, and y.

Referenced by Texture_MouseDown(), Texture_ResetPosition(), Texture_ShowDirectory(), and Texture_ShowInuse().

02219 {
02220     int     x, y;
02221     qtexture_t  *q;
02222     texdef_t    tex;
02223     brushprimit_texdef_t brushprimit_tex;
02224 
02225     my += g_qeglobals.d_texturewin.originy-g_qeglobals.d_texturewin.height;
02226     
02227     Texture_StartPos ();
02228     while (1)
02229     {
02230         q = Texture_NextPos (&x, &y);
02231         if (!q)
02232             break;
02233         int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;
02234         int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;
02235         if (mx > x && mx - x < nWidth
02236             && my < y && y - my < nHeight + FONT_HEIGHT)
02237         {
02238             if (bShift)
02239             {
02240                 if (g_PrefsDlg.m_bHiColorTextures && q->shadername[0] != 0)
02241                 {
02242                     //CString s = "notepad ";
02243                     //s += q->shadername;
02244                     //WinExec(s, SW_SHOWNORMAL);    
02245     
02246                     ViewShader(q->shadername, q->name);             
02247 
02248                 }
02249             }
02250             memset (&tex, 0, sizeof(tex));
02251             memset (&brushprimit_tex, 0, sizeof(brushprimit_tex));
02252             if (g_qeglobals.m_bBrushPrimitMode)
02253             {
02254                 // brushprimit fitted to a 2x2 texture
02255                 brushprimit_tex.coords[0][0] = 1.0f;
02256                 brushprimit_tex.coords[1][1] = 1.0f;
02257             }
02258             else
02259             {
02260                 tex.scale[0] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;
02261                 tex.scale[1] = (g_PrefsDlg.m_bHiColorTextures) ? 0.5 : 1;
02262             }
02263             tex.flags = q->flags;
02264             tex.value = q->value;
02265             tex.contents = q->contents;
02266             //strcpy (tex.name, q->name);
02267             tex.SetName(q->name);
02268             Texture_SetTexture ( &tex, &brushprimit_tex, bFitScale, GETPLUGINTEXDEF(q));
02269             CString strTex;
02270             CString strName = q->name;
02271             //int nPos = strName.Find('\\');
02272             //if (nPos == -1)
02273             //  nPos = strName.Find('/');
02274             //if (nPos >= 0)
02275             //  strName = strName.Right(strName.GetLength() - nPos - 1);
02276             strTex.Format("%s W: %i H: %i", strName.GetBuffer(0), q->width, q->height);
02277             g_pParentWnd->SetStatusText(3, strTex);
02278             return;
02279         }
02280     }
02281 
02282     Sys_Status("Did not select a texture\n", 0);
02283 }

Here is the call graph for this function:

CShaderInfo* SetNameShaderInfo qtexture_t q,
const char *  pPath,
const char *  pName
 

Definition at line 1017 of file TexWnd.cpp.

References qtexture_s::bFromShader, qtexture_s::fTrans, hasShader(), CShaderInfo::m_fTransValue, CShaderInfo::m_nFlags, CShaderInfo::m_strShaderName, qtexture_s::name, qtexture_s::nShaderFlags, q, qtexture_t, qtexture_s::shadername, strcpy(), StripExtension(), and strncpy().

Referenced by QERApp_TryTextureForName(), ReloadShaders(), and Texture_ForName().

01018 {
01019   CShaderInfo *pInfo = hasShader(pName);
01020   if (pInfo)
01021   {
01022     strcpy(q->shadername, pInfo->m_strShaderName);
01023     q->bFromShader = true;
01024     q->fTrans = pInfo->m_fTransValue;
01025     q->nShaderFlags = pInfo->m_nFlags;
01026   }
01027   else
01028   {
01029     q->shadername[0] = 0;
01030   }
01031   strncpy (q->name, pName, sizeof(q->name) - 1);
01032     StripExtension (q->name);
01033   return pInfo;
01034 }

Here is the call graph for this function:

void SetTexParameters void   ) 
 

Definition at line 269 of file TexWnd.cpp.

References qglTexParameteri, and texture_mode.

Referenced by Texture_CreateSolid(), Texture_LoadSkin(), Texture_LoadTexture(), Texture_LoadTGATexture(), Texture_MakeDefault(), Texture_MakeNoshadertexture(), and Texture_SetMode().

00270 {
00271     qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture_mode );
00272     
00273     switch ( texture_mode )
00274     {
00275     case GL_NEAREST:
00276     case GL_NEAREST_MIPMAP_NEAREST:
00277     case GL_NEAREST_MIPMAP_LINEAR:
00278         qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
00279         break;
00280     case GL_LINEAR:
00281     case GL_LINEAR_MIPMAP_NEAREST:
00282     case GL_LINEAR_MIPMAP_LINEAR:
00283         qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
00284         break;
00285     }
00286 }

bool ShaderQTextureExists const char *  pName  ) 
 

Definition at line