PSPGL and DepthTesting problem.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

PSPGL and DepthTesting problem.

Post by LarryTM »

Hi,

I've enabled gl_depth_test, gl_cull_face, disabled blending, and when i try to display few objects placed one after another i have no depth testing at all. Here is the screenshot :

Image

Why? Here is my code :

Code: Select all

glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
	glShadeModel(GL_FLAT);	

	glColor4f(1,1,1,1);
	glDepthFunc(GL_LESS);
	glDisable(GL_BLEND);
	glBindTexture(GL_TEXTURE_2D,mojetekstury[4]);	
	
	glPushMatrix();		
		glRotatef(ile,0,0,1);
		glColor4f(1,1,1,1);		
		glPushMatrix();
			glTranslatef(0,2,0);
			glRotatef(-ile*4,1,0,0);	
			for &#40;float a=0;a<10;a++&#41;
			&#123;
			glPushMatrix&#40;&#41;;				
				glRotatef&#40;360.0 * float&#40;a&#41; / 10.f,1,0,0&#41;;	
				glTranslatef&#40;0,2,0&#41;;
				Tube01&#40;&#41;;
			glPopMatrix&#40;&#41;;
			&#125;
		glPopMatrix&#40;&#41;;
	glPopMatrix&#40;&#41;;	
Tube01() is just a object drawing rutine (object converted with polytrans to opengl code).

Can anyone knows why i dont have eny depth testing?

/lar
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Post by ffelagund »

Hello,

Have you cleared the depth buffer at the beginning of each frame?
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
I dont know... flight casual!
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

Yes, and i've noticed another strange problem :

When i display an object - everything looks fine, but when i rotate this object (about 180 degrees) it looks very messy - like when the gl_cull_face is disabled.

/lar
memon
Posts: 63
Joined: Mon Oct 03, 2005 10:51 pm

Post by memon »

Do you set glDepthMask? Try setting it to GL_TRUE.
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

yes, that did nothing. :(

/lar
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Post by ffelagund »

I dont know if this is implemented in PSPGL, but try: glGetIntegerv(GL_DEPTH_BITS,&a); to see if you truly have a depth buffer.
I dont know... flight casual!
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

glGetIntegerv(GL_DEPTH_BITS,&a) returns 16;

edit: I've rotated all the objects (in 180 degrees) and now it looks good - with depth testing, but thats doesnt solve the problem with cullfacing. :/ maybe its something with normals? but on PC (radeon 9800 pro) those objects looks fine.

/lar
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Is Tube01() using GL_QUADS with more than one quad between glBegin and glEnd? GL_QUADS isn't supported properly.

Jim
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

No, its uses olny GL_TRIANGLES.

/lar
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Post by ffelagund »

I think that the error should be in the Tube01 function, because the rest seems to be ok. Could you paste here that func? (it is not neccesary to paste the data arrays)
I dont know... flight casual!
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

Ok, here is test source file with one rotating object - compiled & src. Its the same error with cull facing.

http://www.temporary.art.pl/test.zip

/lar
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

Anyone? Please - its very important to me.

/lar
ffelagund
Posts: 14
Joined: Thu Mar 16, 2006 9:44 pm
Contact:

Post by ffelagund »

Sorry LarryTM, currently I lost my RHEL4 partition (viva linux!) due a filesystem corruption error, so I cant test your app. Now I'm installing cygwin and the pspsdk (again). As soon as I have the dev environment running, I'll check your sources.
I dont know... flight casual!
LarryTM
Posts: 30
Joined: Tue Jul 04, 2006 4:05 am
Contact:

Post by LarryTM »

I will be very thankful to you.

edit: I think i solved the problem.

I have bad gluPerspective definition :

gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.0f,100.0f);

the correct one is

gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);

Anyway - thanks for your support and help.

/lar
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

also note you have 1000000 constants
for your tube
10011011 00101010 11010111 10001001 10111010
Post Reply