Results 1 to 5 of 5

Thread: Texture mapping

  1. #1
    Guest

    Texture mapping

    I'm trying to do texture mapping in opengl with fltk.
    I can't seem to make texture mapping work

    I just followed some tutorial, and I don't know what the line does exactly.

    Here is my code

    Initialize part
    glEnable (GL_DEPTH_TEST);
    int width, height;

    unsigned char* data = readBMP("test.bmp", width, height);

    glBindTexture (GL_TEXTURE_2D, 1);
    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_DECAL);
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0 ,GL_RGB,GL_UNSIGNED_BYTE,data);

    reading BMP seems working because I can see that data has some reasonable values.

    Here is drawing part
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode (GL_MODELVIEW);
    glColor3f(0.5,1.0,1.0);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 1);
    glBegin (GL_QUADS);
    glTexCoord2f (0.0f,0.0f);
    glVertex3f (-0.5f, -0.5f, 0.0f);
    glTexCoord2f (1.0f, 0.0f);
    glVertex3f (0.5f, -0.5f, 0.0f);
    glTexCoord2f (1.0f, 1.0f);
    glVertex3f (0.5f, 0.5f, 0.0f);
    glTexCoord2f (0.0f, 1.0f);
    glVertex3f (-0.5f, 0.5f, 0.0f);
    glEnd ();
    glDisable(GL_TEXTURE_2D);
    glFlush();

    This is all I have for opengl code.

    Am I missing something here?

  2. #2
    Member Contributor
    Join Date
    Apr 2002
    Posts
    94

    Re: Texture mapping

    Do you call glGenTextures first?
    P4 2Ghz, GEFORCE4, 512 Meg RAM, WIN2000, VStudio 6.0

  3. #3
    Guest

    Re: Texture mapping

    Do I really need that code?
    I thought that if I have just one texture, then I can just use number 1 to designate the texture.
    Is the code required?

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Nov 2002
    Location
    Latvia
    Posts
    626

    Re: Texture mapping

    Take a look at NeHe tutorials. That should explain if not all, then most of your questions And I think, you should forget about standart textures, nowdays hw is huge enough to handle MipMaped textures with no problems

  5. #5
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Texture mapping

    "Standard" texture is not a good terminology for that. Here immediate mode texture vs. texture objects is meant, not mipmapping.
    Texture object _zero_ is the immediate mode texture for all texture targets. That's the one which can be used without texture object initialization. You don't need glBindTexture if you only have one texture.


    [This message has been edited by Relic (edited 11-29-2002).]

Similar Threads

  1. Texture mapping ::: 3D Face Mapping
    By 3render3 in forum OpenGL: General
    Replies: 2
    Last Post: 03-24-2013, 06:49 PM
  2. projective texture mapping and shadow mapping
    By phoenix_gl in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 10-08-2012, 08:00 PM
  3. Replies: 0
    Last Post: 01-09-2005, 05:53 PM
  4. Replies: 1
    Last Post: 01-09-2005, 05:50 PM
  5. Texture Mapping / Environmental Mapping.
    By imported_Andrew in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-09-2000, 01:20 PM

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