   Problem with Texture - White Quad issue
  I''m trying to texture a quad with a PCX file I load from disk. When the quad is drawn, however, it is displayed as a white instead of textured.After searching, I''ve checked the following:-GL_TEXTURE_2D is enabled and stays enabled throughout program execution-Texture is a power of 2 (256x256x8, to be exact)Below are the functions I use to load and display the PCX file. There is something missing, I''m sure, but what it is escapes me. Any insight would be greatly appreciated.   #include "pcx.h"typedef struct tagImage{UINTuTexNum;charname[64];intnWidth;intnHeight;} IMAGE;IMAGEg_Textures[1];intg_NumTex= 0;intg_nWidth= 640;intg_nHeight= 480;IMAGE* FindPic(char *name){IMAGE *pImage;int x;for(x = 0, pImage = g_Textures; x<g_NumTex; x++, pImage++){if(!strcmpi(g_Textures[x].name, name)){return pImage;}}byte *pic, *palette;int width, height;int len = strlen(name);if(!strcmpi(name+len-4, ".pcx")){LoadPCX(name, &pic, &palette, &width, &height);pImage = &g_Textures[x];strcpy(pImage->name, name);pImage->nHeight= height;pImage->nWidth= width;pImage->uTexNum= g_NumTex;return pImage;}return NULL;}void DrawPic(int x, int y, char *name){IMAGE *pImage = FindPic(name);int width = pImage->nWidth;int height = pImage->nHeight;glDisable(GL_DEPTH_TEST);glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho(0, g_nWidth, g_nHeight, 0, -1, 1);glMatrixMode(GL_MODELVIEW);glPushMatrix();glLoadIdentity();glBindTexture(GL_TEXTURE_2D, g_Textures[0].uTexNum);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);glBegin(GL_QUADS);glTexCoord2f(0.0f, 1.0f);glVertex2f(x, y);glTexCoord2f(1.0f, 1.0f);glVertex2f(x+width, y);glTexCoord2f(1.0f, 0.0f);glVertex2f(x+width, y+height);glTexCoord2f(0.0f, 0.0f);glVertex2f(x, y+height);glEnd();glMatrixMode(GL_PROJECTION);glPopMatrix();glMatrixMode(GL_MODELVIEW);glPopMatrix();glEnable(GL_DEPTH_TEST);}void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height){byte*raw;PCXFILE*pcx;intx, y;intlen;intdataByte, runLength;byte*out, *pix;*pic = NULL;*palette = NULL;len = LoadFile (filename, (void **)&raw);pcx = (PCXFILE *)raw;raw = &pcx->data;out = (byte*)malloc ( (pcx->ymax+1) * (pcx->xmax+1) );*pic = out;pix = out;if (palette){*palette = (byte*)malloc(768);memcpy (*palette, (byte *)pcx + len - 768, 768);}if (width)*width = pcx->xmax+1;if (height)*height = pcx->ymax+1;for (y=0 ; y<=pcx->ymax ; y++, pix += pcx->xmax+1){for (x=0 ; x<=pcx->xmax ; ){dataByte = *raw++;if((dataByte & 0xC0) == 0xC0){runLength = dataByte & 0x3F;dataByte = *raw++;}elserunLength = 1;while(runLength-- > 0)pix[x++] = dataByte;}}}pcx.h only contains forward declarations and the PCXFILE struct (which consists of data elements for the PCX header plus an unsigned char for the PCX data)btw, LoadPCX() is a copy/paste job, so maybe I''m missing something there? Either way, this has me stumped.Thanks,//Serian 
  Do you ever call glTexImage2D or gluBuild2DMipmaps to actually create the texture?Enigma ;  heh, knew I was forgetting something I've added it (see below) to FindPic() (see above). Now I'm getting an illegal operation when that line of code is executed. if(!strcmpi(name+len-4, ".pcx")){LoadPCX(name, &pic, &palette, &width, &height);pImage = &g_Textures[x];strcpy(pImage->name, name);pImage->nHeight= height;pImage->nWidth= width;glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pic);return pImage;}Any idea as to what I'm doing wrong? Passing bad arguments, or maybe there's a better location to place the line?//Serian   [edited by - Serian on February 9, 2004 8:08:41 PM];  You''ll need to generate a texture ID and bind that texture first, but I wouldn''t expect that to fix your crash.  Are you sure your PCX loader is correct.  The memory allocation looks suspicious (ymax + 1) * (xmax + 1).  Shouldn''t that be multiplied by 3 for the colour channels?BTW. you shouldn''t be passing ''3'' as the third parameter to glTexImage2D.  That method will work but is deprecated.  Instead use GL_RGB.Enigma ;  With your advice on actually creating the texture, plus a new LoadPCX(), it''s working now.Thanks for your help, Enigma 