Texture openGL

I tried the following code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
glClearColor(1.0, 0.0, 0.0, 0.0); // Colour to clear the scene
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



    glBindTexture(GL_TEXTURE_2D, 13);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);


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



    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, "Images\\test.jpg");

    //Draw
    glBindTexture (GL_TEXTURE_2D, 13);
    glBegin (GL_QUADS);
    glTexCoord2f (0.0, 0.0);
    glVertex2f(-0.5,-0.5);
    glTexCoord2f (0.0, 1.0);
    glVertex2f(-0.5,0.5);
    glTexCoord2f (1.0, 1.0);
    glVertex2f(0.5,0.5);
    glTexCoord2f (1.0, 0.0);
    glVertex2f(0.5,-0.5);
    glEnd();




but all that appears is the box with no texture.

what am I doing wrong?
Last edited on
The last parameter of glTexImage2D takes in a pointer to the pixel data, not the path to a file. You need to either write your own code to read in an image and put it in OpenGL's format (tedious, even for simple image formats), or use a library such as FreeImage, or SDL.
Topic archived. No new replies allowed.