   glbind prob
  With this source I''m just trying to bind a 2d texture to a square, but all I get is a blank white square, anyone know what I''m doing wrong?#include <stdio.h>#include <windows.h>#include <gl\glut.h>#include <gl\gl.h>#include <gl\glu.h>#include <stdlib.h>void load_texture ( char *file_name, int width, int height, int depth, GLenum colour_type, GLenum filter_type ){ GLubyte *raw_bitmap ;FILE *file;if ((file = fopen(file_name, "rb"))==NULL){printf("File Not Found : %s\n",file_name);system("pause");exit (1);} raw_bitmap = (GLubyte *) malloc ( width * height * depth * ( sizeof ( GLubyte )) );if ( raw_bitmap == NULL ){printf ( "Cannot allocate memory for texture\n" );system("pause");fclose ( file );exit ( 1 );} fread ( raw_bitmap , width * height * depth, 1 , file );fclose ( file); //glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter_type );//glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter_type );glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); gluBuild2DMipmaps ( GL_TEXTURE_2D, colour_type, width, height, colour_type, GL_UNSIGNED_BYTE, raw_bitmap ); free ( raw_bitmap );}void init ( void ){glEnable ( GL_DEPTH_TEST );glClearColor ( 0.0, 0.0, 0.0, 0.0 );glEnable ( GL_TEXTURE_2D );glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );load_texture ( "C:/Documents and Settings/User/My Documents/My Pictures/aaliyah.raw", 332, 425, 3, GL_RGB, GL_LINEAR ); }void square (void){//glColor3f (1.0,1.0,1.0);glBindTexture(GL_TEXTURE_2D, 13);glBegin (GL_QUADS);glTexCoord2f (0.0, 0.0);glVertex3f (0.0, 0.0, 0.0);glTexCoord2f (1.0, 0.0);glVertex3f (10.0, 0.0, 0.0);glTexCoord2f (1.0, 1.0);glVertex3f (10.0, 10.0, 0.0);glTexCoord2f (0.0, 1.0);glVertex3f (0.0, 10.0, 0.0);glEnd ();//glutWireCube(1.0) ; }void display ( void ){glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );glPushMatrix ( );square();glPopMatrix ( );glutSwapBuffers ( );}void reshape(int w, int h){glViewport ( 0, 0, w, h );glMatrixMode ( GL_PROJECTION );glLoadIdentity ( ); if ( h==0 )gluPerspective ( 80, ( float ) w, 1.0, 5000.0 );elsegluPerspective ( 80, ( float ) w / ( float ) h, 1.0, 5000.0 );glMatrixMode ( GL_MODELVIEW );glLoadIdentity ( );}int main(int argc,char* argv[]){glutInit(&argc,argv);glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);glutInitWindowSize (800,500);glutInitWindowPosition (100,100);glutCreateWindow ("Ben''s window");init();//glutReshapeFunc(reshape);glutDisplayFunc(display);glutMainLoop();return 0;} 
the texture isn''t loaded.  Sorry but I don''t have time to debug your code for u.;[edited by - benjamin1441 on July 29, 2003 6:20:24 PM] [edited by - benjamin1441 on August 1, 2003 7:57:25 AM];  what he meant was that (whether you have the bitmap or not) your program is not successfully loading the texture. otherwise it would display it when you enabled textures, bound it, and drew something.i recommend looking through your texture loading function, maybe loggin it to, to see where it goes wrong.you *****. ;  You miss-understand him. He is telling you that your texture is failing to load. Please try to control your temper, this is mostly a very civil forum - you will get out of it what you put in and a reaction like that can have quite an impact on how other people receive your questions.Perhaps you could check that your texture is of dimensions which are multiples of two?EDIT: This was directed at benjamin1441   Further examination of your code shows that you aren't actually generating a texture. Think this might be the problem?Look into the glGenTextures function and your problem should be solved.[edited by - MrP on July 29, 2003 6:44:31 PM] [edited by - MrP on July 29, 2003 6:50:20 PM];  generation would only return an index, if its just one it should be safe to just use 1.but: -no call to bind before creating the texture-texture isnt deleted in the end-where the heck is that 13 coming from?-no source tags-pretty rude ;  hi, i got pretty the same problem: only a blank rectangle is displayed, but i think my loading code is correct, because i used the one from the nehe tuts 6 and 32 (bmp and tga). i hope you can find the problemmy video device code:class cVideoDevice{private:typedef unsigned int uint;static cVideoDevice* g_VideoDevice;uint m_Width;uint m_Height;uint m_Bpp;bool m_Fullscreen;void initSDL(void);void initOGL(void);public:cVideoDevice(uint, uint, uint, bool);~cVideoDevice();void flip(void);void clear(void);static cVideoDevice* getVideoDevice(void);};cVideoDevice* cVideoDevice::g_VideoDevice = NULL;cVideoDevice::cVideoDevice(uint width, uint height, uint bpp, bool full){/***SINGLETON***/if(g_VideoDevice != NULL){delete this;return;}g_VideoDevice = this;m_Width = width;m_Height = height;m_Bpp = bpp;m_Fullscreen = full;try{initSDL();initOGL();}catch(cError* err){err->handle();throw;}}cVideoDevice::~cVideoDevice(){if(g_VideoDevice != this)return;g_VideoDevice = NULL;SDL_FreeSurface(SDL_GetVideoSurface());}void cVideoDevice::initSDL(){    if(m_Bpp != 32 && m_Bpp != 16)throw new cError("cVideoDevice::initSDL() : only 16 or 32 are allowed as bits per pixel";if(!SDL_WasInit(SDL_INIT_VIDEO)){if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)throw new cError("cVideoDevice::initSDL() : couldn''t init the sdl video subsystem";}if(m_Bpp == 16){SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 4 );SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 4 );SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 4 );SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 4 );SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 16);SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );}else if(m_Bpp == 32){SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );SDL_GL_SetAttribute( SDL_GL_BUFFER_SIZE, 32);SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 );}elsethrow new cError("cVideoDevice::initSDL() : only 16 or 32 bit as depth allowed";//everytime usedSDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );    int flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;//query the video info, whether there are specific advantages:{const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();if (videoInfo->hw_available)flags |= SDL_HWSURFACE;elseflags |= SDL_SWSURFACE;if (videoInfo->blit_hw)flags |= SDL_HWACCEL;}if(m_Fullscreen) flags |= SDL_FULLSCREEN;    if( SDL_SetVideoMode( m_Width, m_Height, m_Bpp, flags ) == 0 )throw new cError("cVideoDevice::initSDL() : call to SDL_SetVideoMode failed";}void cVideoDevice::initOGL(){    glShadeModel( GL_SMOOTH );    glClearColor( 0, 0, 0, 0 );glDisable(GL_DEPTH_TEST);//blending used for tgas with alpha channelglEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ONE);glEnable(GL_TEXTURE_2D);//set 2d projectionglMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0,640,0,480,-1,1);glMatrixMode( GL_MODELVIEW);}void cVideoDevice::flip(void){SDL_GL_SwapBuffers();}void cVideoDevice::clear(void){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);}cVideoDevice* cVideoDevice::getVideoDevice(){return g_VideoDevice;}  my texture code:class cTexture{private:bool loadTGA(char*);bool loadBMP(char*);bool loadJPG(char*);protected:GLuintm_Bpp;GLuintm_Width;GLuintm_Height;GLuintm_TexID;public:cTexture();cTexture(char*);~cTexture();bool load(char*);GLuint getWidth();GLuint getHeight();GLuint getBpp();void set(void);};#include <string.h>using namespace impact::video;cTexture::cTexture() : m_Width(0), m_Height(0), m_Bpp(0), m_TexID(0){}cTexture::cTexture(char* filename) : m_Width(0), m_Height(0), m_Bpp(0), m_TexID(0){if(load(filename) == false)m_TexID = 0;}cTexture::~cTexture(){if(m_TexID != 0){glDeleteTextures(1, &m_TexID);}}bool cTexture::load(char* filename){/*''.'' seperates the extension from the filename**but the filename can also contain dots, so**only the last ocuurence of a dot must be used */char* lastDot = filename;char* current = filename;while(*current != ''\0''){if(*current == ''.'')lastDot = current;current++;}if(!strcmp(lastDot, ".tga")return loadTGA(filename);else if(!strcmp(lastDot, ".bmp")return loadBMP(filename);else if(!strcmp(lastDot, ".jpg")return loadJPG(filename);elsereturn false;}bool cTexture::loadBMP(char* filename){//nehe tut 6 code - nehe.gamedev.netSDL_Surface *surf = SDL_LoadBMP("data/nehe.bmp"; if (surf){glGenTextures(1, &m_TexID);glBindTexture(GL_TEXTURE_2D, m_TexID);glTexImage2D(GL_TEXTURE_2D, 0,  GL_RGBA,surf->w, surf->h, 0, GL_BGR,GL_UNSIGNED_BYTE, surf->pixels);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);//set the member vars:m_Width = surf->w;m_Height = surf->h;m_Bpp = surf->format->BitsPerPixel;SDL_FreeSurface(surf);return true;}return false;}bool cTexture::loadJPG(char* filename){return true;}bool cTexture::loadTGA(char *filename){//nehe tut 32 code - nehe.gamedev.netGLubyteTGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};GLubyteTGAcompare[12];GLubyteheader[6];GLuintbytesPerPixel;GLuintimageSize;GLuinttemp;GLuinttype=GL_RGBA;GLubyte*imageData = NULL;GLuint i = 0;FILE *file = fopen(filename, "rb";if(file==NULL ||fread(TGAcompare,1,sizeof(TGAcompare),file)!=sizeof(TGAcompare) ||memcmp(TGAheader,TGAcompare,sizeof(TGAheader))!=0||fread(header,1,sizeof(header),file)!=sizeof(header))goto error;m_Width  = header[1] * 256 + header[0];m_Height = header[3] * 256 + header[2];    if(m_Width<=0||m_Height<=0||(header[4]!=24 && header[4]!=32))  goto error;m_Bpp= header[4];bytesPerPixel= m_Bpp/8;imageSize= m_Width*m_Height*bytesPerPixel;imageData = (GLubyte *)malloc(imageSize);if(imageData==NULL ||fread(imageData, 1, imageSize, file)!=imageSize)goto error;for(; i<(unsigned int)imageSize; i+=bytesPerPixel){temp=imageData;imageData = imageData;<br>imageData = temp;<br>}<br><br>fclose (file);<br><br>glGenTextures(1, &amp;m_TexID);<br><br>glBindTexture(GL_TEXTURE_2D, m_TexID);<br>glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);<br>glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br><br>if (m_Bpp==24)<br>{<br>type=GL_RGB;<br>}<br><br>glTexImage2D(GL_TEXTURE_2D, 0, type, m_Width, m_Height,<br>0, type, GL_UNSIGNED_BYTE, imageData);<br><br>free(imageData);<br><br>return true;<br><br>error:<br>if(imageData!=NULL)<br>{<br>free(imageData);<br>}<br><br>if (file != NULL)<br>fclose(file);<br><br>return false;<br>}<br><br>GLuint cTexture::getWidth()<br>{<br>return m_Width;<br>}<br><br>GLuint cTexture::getHeight()<br>{<br>return m_Height;<br>}<br><br>GLuint cTexture::getBpp()<br>{<br>return m_Bpp;<br>}<br><br>void cTexture::set()<br>{<br>glBindTexture(GL_TEXTURE_2D, m_TexID);<br>}<br> </pre> <br>and now my test code:<br><pre><br>int cGame::run(int, char**)<br>{<br>impact::core::Log(&quot;hello world&quot<img src="wink.gif" width=15 height=15 align=middle>;<br><br>impact::video::cTexture tex(&quot;test.bmp&quot<img src="wink.gif" width=15 height=15 align=middle>;<br>tex.load(test.bmp);<br><br>while(m_Active)<br>{<br>impact::core::cCore::getCore()-&gt;handleEvents();<br><br>impact::video::cVideoDevice::getVideoDevice()-&gt;clear();<br><br>//drawing takes place here<br>glLoadIdentity();<br><br>tex.set();<br><br>glColor4f(1.0f, 1.0f, 1.0f, 1.0f);<br><br>glBegin(GL_QUADS);// Use A Quad For Each Character<br><br>glTexCoord2f(0,0);// Texture Coord (Bottom Left)<br>glVertex2i(0,0);// Vertex Coord (Bottom Left)<br><br>glTexCoord2f(1,0);// Texture Coord (Bottom Right)<br>glVertex2i(200,0);// Vertex Coord (Bottom Right)<br><br>glTexCoord2f(1,1);// Texture Coord (Top Right)<br>glVertex2i(200,200);// Vertex Coord (Top Right)<br><br>glTexCoord2f(0,1);// Texture Coord (Top Left)<br>glVertex2i(0,200);// Vertex Coord (Top Left)<br>glEnd();<br><br>impact::video::cVideoDevice::getVideoDevice()-&gt;flip();<br>}<br><br>return 0;<br>}<br> </pre> <br><br>i think the code is quite understandable, but i anyone needs the complete code with a project file, just say a word and i will send via email.<br><br>ps hopefully i used the correct code tag, but i couldn''t find help concerning this  </i>  