OpenGL Textures

This is a discussion on OpenGL Textures within the Game Programming forums, part of the General Programming Boards category; I've been playing about with Microsoft Kinect using the OpenNI SDK, and it has mostly been going well. I have ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    15

    OpenGL Textures

    I've been playing about with Microsoft Kinect using the OpenNI SDK, and it has mostly been going well. I have managed to implement a user tracker to remove the background and replace it with a bitmap image. Only problem is I'm new to textures so I don't think I have been doing it very efficiently, hence my program becomes very jittery.

    I have been trying to use glBindTexture() as I was previously usng glTexImage2D() each time in display which was causing the jittery display, but all I get at run time is a white screen.

    In main just before I call glutDisplayFunc:
    Code:
    glGenTextures(1, &background); 
    glBindTexture(GL_TEXTURE_2D, background);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
    Then in display:
    Code:
    glEnable(GL_TEXTURE_2D);
    
    if(g_nViewState != DISPLAY_MODE_IMAGE)
    {
    glBindTexture(GL_TEXTURE_2D, background);
    
    glDisable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
    
    glBegin(GL_QUADS);
    
    // upper left
    glTexCoord2f(0, 1);
    glVertex2f(0, 0);
    // upper right
    glTexCoord2f(1, 1);
    glVertex2f(GL_WIN_SIZE_X, 0);
    // bottom right
    glTexCoord2f(1,0);
    glVertex2f(GL_WIN_SIZE_X, GL_WIN_SIZE_Y);
    // bottom left
    glTexCoord2f(0,0);
    glVertex2f(0, GL_WIN_SIZE_Y);
    
    glEnd();
    }
    Thanks in advance,
    Will

  2. #2
    Registered User
    Join Date
    Feb 2010
    Posts
    15
    All sorted now, needed to apply a few texture properties before filling the texture with information

    Code:
    glGenTextures(1, &background); //Make room for our texture
    glBindTexture(GL_TEXTURE_2D, background);
    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); 
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image->width, image->height, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL; Using TGA Textures
    By cboard_member in forum Game Programming
    Replies: 6
    Last Post: 12-19-2005, 01:01 PM
  2. OpenGL Textures and TGAs
    By ay_okay in forum Game Programming
    Replies: 3
    Last Post: 06-13-2005, 09:06 PM
  3. OpenGL, loading BMP Textures?
    By Zeusbwr in forum Game Programming
    Replies: 12
    Last Post: 12-09-2004, 04:16 PM
  4. OpenGL Textures/Transparency
    By JaWiB in forum Game Programming
    Replies: 1
    Last Post: 06-06-2004, 01:12 PM
  5. OpenGL Textures
    By SyntaxBubble in forum Game Programming
    Replies: 5
    Last Post: 11-02-2001, 04:55 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21