PDA

View Full Version : why texture2d has no effect?



wilburn
09-29-2007, 01:21 AM
I cannot see any texture effect using code below:

//*****************************************
glDisable(GL_LIGHTING);
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

// bind the texture object
// draw rect that fill the screen

// unbind the texture object
//*****************************************

if I use glDisable(GL_TEXTURE_2D) and glColor3f(1, 0, 0) instead, the result is correct.

can anybody tell me what's going on with it?

Nicolai de Haan Brøgger
09-29-2007, 01:29 AM
What's your glTexParameters? In particular, do you use mipmapping and have you set up filtering parameters?

kind regards,
Nicolai de Haan Brøgger

wilburn
09-29-2007, 01:48 AM
Indeed I'd specified it to earlier as follows:
min filter GL_LINEAR
max filter GL_LINEAR

wilburn
09-29-2007, 01:57 AM
In fact, I'm using with osg, and there's no problem with some osg models,

wilburn
09-29-2007, 02:02 AM
I doubt the completeness of my texture completeness,and so it's affected by some scene graph nodes and not for the others, but I donn't know how to validate it

Overmind
09-29-2007, 06:02 AM
Do you set the texture coordinates correctly?

wilburn
09-29-2007, 08:49 AM
yes i did. any other reasons?

wilburn
09-29-2007, 08:59 AM
the problem is not come from common and the usual way of using texture. it comes from integrating common use of texture with the use of OSG, the use of CEGUI.

if i use glPushAttrib(GL_ALL_ATTRIB_BITS) together with glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS) before calling the draw method of OSG, and pop the attributes afterwards, the result seems good, except some objects loaded and processed, and rendered by OSG "disappeared" in the view.

and, if i do not save and restore any attributes for OSG rendering, but instead disable GL_TEXTURE_2D of my own texture outside of OSG, the result seems to be right.

So, the result I can get is that the problem is related with GL_TEXTURE_2D, and vertex array.

CAN anybody tell me, when using texture in OpenGL, what's the possible reason for cannot output any color from bound texture with lighting disabled and blended disabled, JUST as the code ABOVE showed?

Many thanks to you guys already answered ...

Ysaneya
09-30-2007, 04:13 AM
Has your texture dimensions of powers of 2 ?

wilburn
09-30-2007, 08:05 PM
yes it is 512*512

Nighthawk
10-16-2007, 06:47 AM
Does texturing work when you call gluBuild2DMipmaps() with a dummy texture after your glBindTexture() (just for debugging)?

If yes, the problem is likely texture completeness(mipmaps enabled but not specified).