Problem with texture

I am loading a .jpg file as texture in the MFC application and a .ac model in my application and mapping a texture at the background.

Now the problem is when i do this the texture takes the colour of the model and turns dark.When i dont load the model the texture is fine.

////Following is the code for texture

glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f,0.0f,0.0f,0.5f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

////for Binding texture
glClearColor(1.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBindTexture(GL_TEXTURE_2D, texture[0]);

Code for loding .ac model is quite large so i cannot put it here.
hope i am clear with my problem.

plz give me some suggestions

Regards
Utkarsh

some renderstates that are used by your model are not reset for your background image, thus continuing to affect the rendering pipeline. some code on how you do model rendering would help. maybe glColor3f(1.0f,1.0f,1.0f) before the texture helps if you used this function elsewhere or disable lighting if your model is lit.

If you do not need lighting, try this before using your texture:

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

This prevent from multiplying the texture color with the current fragment color. (By default the last parameter is GL_MODULATE).

Yes, you shoud use GL_REPLACE.

Thnks every one for the reply.
I fixed the problem by disabling the lighting for the model.
but one more problem i am facing is that in the application the model dosen’t appear.
But when i moved the texture image slowly(by varying the mapping coordinates in glVertex3f(); )the model started appearing on the screen as the texture moves out and the model was having the texture of the image.

I hope the model is created at the background of the image or it is taking the texture of the image and hence is not visible.

Plz suggest me how to bring the model over the texture.

Regards

Utkarsh

If I understand you correctly, the texture is mapped on the object in the same manner this one is mapped on the background?

Use glBinTexture to map different texture on background and the object.
How texture coordinates are generated for the model and the background?

Note that you don’t move texture coordinates with glVertex but with glTexCoord.

I am not using any texture for the 3D model.texture is used only for the background of the model which i am binding through glBindTexture()
Hence its not clear where the problem is???

Also i cannot move texture with glTexCoord()because my background is a terrain image which has to be contineous.I have 3-4 images of the terrain and if i use glTextCoord() to move the texture only one image is repeated.

So i am mapping different images at diff ay different coordinates using glVertex() and varying those coordinates to get a contineous effect.

but my problem now is the model not appearing infront of the background.

Hope i am clear.

Regards
Utkarsh

the model started appearing on the screen as the texture moves out and the model was having the texture of the image.

I am not using any texture for the 3D model.texture is used only for the background of the model which i am binding through glBindTexture()

No, it is not clear at all.

Could you elaborate more about:

  1. What you want to do
  2. What you have achieved and how. + screenshots.
  3. issues you are experiencing.

but my problem now is the model not appearing infront of the background.

So now, the problem is not the same?
There could be many reasons why the model is not appearing… (object is behind, has the background color, is not in the camera frustum…)

  1. What you want to do

I am developing an application in which a 3D aircraft model is flying over a terrain. For this i an mapping texture for terrain and sky and them varying the coordinates in glVertex3f() so that the images moves and it appears that the 3d model is moving.

  1. What you have achieved and how. + screenshots.

The texture mapping is well and proper. Loading of 3D model is also fine but it dosen’t appear over the texture. The model appears only when the Texture is moved out of screen.

My screen shots are on my system and i didn’t get option to enter those so i couldn’t enter the screen shot.

So now, the problem is not the same?
There could be many reasons why the model is not appearing… (object is behind, has the background color, is not in the camera frustum…)

The object can be behind the image. How do i bring it to front???
Also it is inside the camera frustum because it appears when the images moves out of the screen.

Regards
utkarsh