Why its black and white?

Every time I use texture or lightning everything comes whith no color… why?

How are you using them?
Could you show us some code?

-nemesis-

Here is the code:

void texscene(void)
{
makeCheckImage();
glTexImage2D(GL_TEXTURE_2D, 0, 3, checkImageWidth,
checkImageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
&checkImage[0][0][0]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
}

void litscene(void)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}

int InitGL(GLvoid)
{
litscene();
texscene();
// BuildFont();
loadskydome();
loadground();
LoadRawFile(“Terrain.raw”, MAP_SIZE * MAP_SIZE, g_HeightMap);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
return TRUE;
}

You’ve enabled lighting, but do you actually have any lights defined?

Doesnt LIGHT0 (which is enabled) have default values? So it wouldnt be that…

change decal -> modulate

you need to do one of two things. When you use lighting glColor commands don’t work, you need to use
glMaterial(…)
this lets you set all the properties for the polygons, I believe the proper call is
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE_AND_AMBIENT, C);
where C is a vector containing the color you want, I might have the parameters in the wrong order so check with some other source

if you have a small simple project you can also just use
glEnable(GL_COLOR_MATERIAL);
and the glColor commands will work as you expect. Its simpler, but offers less control

hello!

You are using mipmapping but…
have you build your mipmaps?
I think it should be something like this:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB8, imageW, imageH, GL_BGR_EXT, GL_UNSIGNED_BYTE, imageDATA);

I hope it helps. Tell us the solution once you’ve solved it
-nemesis-

[This message has been edited by nemesis (edited 01-04-2002).]

You are using mipmapping but…
have you build your mipmaps?

He doesn’t use mipmaps. Take a look at this line (from the texscene function).

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

It’s a non-mipmap minification filter, in other words, mipmaps not in use.

Ups!! you are right!
It seems I need glasses.

-nemesis-

[This message has been edited by nemesis (edited 01-05-2002).]

The problem could be texture, if there’s an issue with texture like an incorrect or illegal parameter it turns white. If it was lighting you’d still see the texture.

zed has a good suggestion, decal is not what you want, especially with a 3 component texture, but it wouldn’t turn white, the texture alpha would be a constant 1.0 and you would never see the polygon color, so the effect would be equivalent to GL_REPLACE, i.e. your lighting would have no effect, and all you’d see is the texture colors.

Beyond this the description of the problem seems too ambiguous to draw any more conclusions.

Make sure your texture is 2^n on each side in dimension, make sure your everything else in the glTexImage2D is legal.

If you want better advice you’re probably going to have to post more information about the symptoms. What happens with & without texture and with & without lighting.

I suspect zed has hit the nail on the head, but I can’t be sure from your description.

[This message has been edited by dorbie (edited 01-06-2002).]