PDA

View Full Version : Black quadrangle instead of textured one!!! Why???



sansan
04-03-2003, 02:33 AM
I'm trying to draw a textured quadrangle - quite a trivial task itself. But I'm doing it within a large visualization library that behaves quite "texture-unfriendly": I'm constantly getting a black quadrangle instead of a textured one.

I use the code below (really standard one):

...

glGenTextures(1, &texname);
glBindTexture(GL_TEXTURE_2D, texname);
makeTexture(); // here pixel colors are calculated
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_LINEAR);

glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height,
0, GL_RGB, GL_UNSIGNED_BYTE,
&image[0][0][0]); //
glEnable(GL_TEXTURE_2D);

...

glBindTexture(GL_TEXTURE_2D, texname);
drawPolygon(); // glTexCoord2 is used here in conjunction with glVertex

It looks like that large library sets some OpenGL parameters that prevent textures from being displayed.

Does anybody have an idea what the problem is and how it can be solved?

Thanks in advance!

sansan
04-03-2003, 02:42 AM
By the way, that code works pretty well in a small test application. Texture dimensions are powers of 2, naturally.

oliii
04-03-2003, 05:18 PM
try to force textures by calling glEnable(GL_TEXTURE_2D); just before the glBind(). YOu never know, perhaps the app disable it by simply calling glDisable(GL_TEXTURE_2D);

I don't see anything wrong with your ccode, if that's reassuring.

oliii
04-03-2003, 05:19 PM
you sure your texcoords() are set and at the right place? http://www.opengl.org/discussion_boards/ubb/biggrin.gif

also, make sure that you load the texture after performing openGL initialisation. It got me once as I loaded the textures in a static object, initialised before the opengl context was created.


[This message has been edited by oliii (edited 04-03-2003).]

sansan
04-07-2003, 11:20 PM
Thanks for your suggestions! Unfortunately, I am likely to do right things (I triple-checked it just to make sure). But OpenGL still refuses to use my texture and displays a black quadrangle http://www.opengl.org/discussion_boards/ubb/frown.gif Moreover, I inserted glGetError() calls after each texture-related OpenGL call, and it always returns 0 (NO_ERROR).

oliii
04-08-2003, 12:01 AM
you could try to email technical support for the visualisation library or something. Or find examples where the library was used and texture mapping worked.

Running out of ideas... TECHNICAL SUPPORT HELP ME! http://www.opengl.org/discussion_boards/ubb/biggrin.gif