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