Results 1 to 3 of 3

Thread: loadtexture prob

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Location
    poole,england
    Posts
    15

    loadtexture prob

    I'm having trouble loading in a texture in .raw so I can paste it an object. I changedd this line of the tut so I could load my own image:

    load_texture ( "C:\Documents and Settings\User\My Documents\My Pictures\aaliyah.raw", 640, 320, 3, GL_RGB, GL_LINEAR );

    but I get the following errors:

    23 C:\Program Files\c++\Dev-Cpp\ben-prog\texturesphere.cpp:60
    [Warning] unknown escape sequence '\D'
    23 C:\Program Files\c++\Dev-Cpp\ben-prog\texturesphere.cpp:60
    non-hex digit 's' in universal-character-name
    23 C:\Program Files\c++\Dev-Cpp\ben-prog\texturesphere.cpp:60
    [Warning] unknown escape sequence '\M'

    Anyone know what's wrong?

    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 );

    glTexEnvf ( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    gluBuild2DMipmaps ( GL_TEXTURE_2D, colour_type, width, height, colour_type, GL_UNSIGNED_BYTE, raw_bitmap );
    free ( raw_bitmap );
    }


    void init(void)
    {

    glShadeModel(GL_FLAT);
    glEnable ( GL_DEPTH_TEST );

    glEnable ( GL_LIGHTING );
    glLightModelfv ( GL_LIGHT_MODEL_AMBIENT, ambient_light );
    glLightfv ( GL_LIGHT0, GL_DIFFUSE, source_light );
    glLightfv ( GL_LIGHT0, GL_POSITION, light_pos );
    glEnable ( GL_LIGHT0 );
    glEnable ( GL_COLOR_MATERIAL );
    glColorMaterial ( GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
    glEnable ( GL_TEXTURE_2D );
    glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
    load_texture ( "C:\Documents and Settings\User\My Documents\My Pictures\aaliyah.raw", 640, 320, 3, GL_RGB, GL_LINEAR );
    glEnable ( GL_CULL_FACE );
    glClearColor ( 0.0, 0.0, 0.0, 0.0 );

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: loadtexture prob

    In C++, \ is used as an escape character, which takes into account the next craracter in the string aswell. For example a \ followed by n ("\n") means new line, "\t" is a tab, and so on. \D, \U, \M which occurs in your string are not legal escape cratacters, but \a is. If you want a \ in your string, you need to escape the slash using a double slash, \\.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    680

    Re: loadtexture prob

    you can also use the unix version of path names ("/" instand of "\") in a windows program, might be a good idea because of better portability.

    Jan

Similar Threads

  1. Prob with cam
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-17-2004, 11:41 AM
  2. BIG PROB
    By in forum OpenGL: User Software
    Replies: 2
    Last Post: 10-22-2003, 11:46 PM
  3. Got a prob
    By JediFan89 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-29-2002, 05:25 AM
  4. 2d prob
    By Nial in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 03-26-2002, 01:00 AM
  5. OpenGL && MFC??? glReadPixels prob... || GL_SELECT prob
    By Jestor in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-17-2001, 09:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean