Hi all,
I am trying to write some cross-platform code, in which I update a texture by some software manipulation, and trying to display that texture each frame. I have not optimized the code yet, but I am seeing the following difference between Cygwin and VC++: in Cygwin, everything works as I am expecting, but in VC++ with the same code, nothing is shown. Ps: my texture is mainly black at the moment, and a black window is shown. If I display another (mainly white) texture, a white window is shown.
I am using glut for initialization and window creation.
void screeninit(void)
{
...
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &glTexNum);
glBindTexture(GL_TEXTURE_2D, glTexNum);
}
void screendraw(void)
{
glBindTexture(GL_TEXTURE_2D, glTexNum);
glTexImage2D(GL_TEXTURE_2D, 0, 3, aTextures[0].iSizeX, aTextures[0].iSizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, aTextures[0].pData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glBindTexture(GL_TEXTURE_2D, glTexNum);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2i(0, 0);
glTexCoord2f(1.0, 0.0);
glVertex2i(aTextures[0].iSizeX, 0);
glTexCoord2f(1.0,1.0);
glVertex2i(aTextures[0].iSizeX, aTextures[0].iSizeY);
glTexCoord2f(0.0, 1.0);
glVertex2i(0, aTextures[0].iSizeY);
glEnd();
glFlush();
}
For completeness, the glut initialization:
int prgRun(int x, int y)
{
int argc = 1;
char * argv[1] = { "test" };
glutInit(&argc, argv);
screeninit(x, y);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(x, y);
glutCreateWindow("title");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutIdleFunc(idle);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutPassiveMotionFunc(mousemove);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, x, 0, y, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutMainLoop();
return 0;
}
I am puzzled of why this goes wrong. As far as I know, the glEnable(GL_TEXTURE_2D) makes sure the texture is shown, and that works under Cygwin.
(I will try under Suse linux soon)
Thanks in advance,
Beluvius