Object is translucent. Depth problem.

Okay, so I’m new here. I’m trying to load the f-16 obj file that Nate Robins provided with his examples. Here is how my code goes, very simple I believe.

	GLfloat lightpos[] = {-1, -1, -1, 0};
	glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

This is what I get.

I do ask glut for a depth buffer.


All I want to do is see the obj correctly, from any angle and in any way possible. Any help is much appreciated, Thank you.

Can’t find any problem with depth in your code
What’s wrong with this picture? Can you provide more details?

This is what it should look like. Sorry if I wasn’t detailed enough.

To my understanding, your first picture is just observing the model from another direction than the your second picture.

Yep. Your rotation is the the problem. It’s actually no observable translucency anywhere.

I differ. The view angle is same but careful observation shows parts of the plain ( especially the second rocket) visible instead the other way, as it comes just under the wing. Rotation would have affected the tail too.

@Waleed: Please check the drawmodel(). Are you drawing backface after the front face? Are you using blending function?


Here is my drawmodel() function,

void drawModel(void)
		pmodel = glmReadOBJ("f-16.obj");
		glmVertexNormals(pmodel, 90.0);
	glmDraw(pmodel, GLM_SMOOTH | GLM_MATERIAL);


It’s not translucent. I don’t know what it is. It’s the same angle and I should not be able to see the rocket in the middle. I should barely be able to see the tips of the second rockets as well. It’s driving me crazy!

How does it look when you leave out the rotation?


How are the triangles defined in the model file? Are there any entries for back faces, with negative values?

Most probable reason looks to be wrong lighting calculations. i.e calculation between face/vertex normal and light vector is still positive for a face that is facing away from you. If this is true then back faces will look to you as front faces.

As a test, do one thing, disable all lighting and check the quality of model drawn. If you get exactly what is desired it means there is some problem in lighting calculations.

I wasn’t specifying a viewing frustum whatsoever. That was my problem. I just added


right after


and everything worked perfectly.

Thank you thokra, awhig and excali for your help, much appreciated.