forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSPGL and DepthTesting problem.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Wed Jul 05, 2006 1:02 am    Post subject: PSPGL and DepthTesting problem. Reply with quote

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 :



Why? Here is my code :

Code:

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 (float a=0;a<10;a++)
         {
         glPushMatrix();            
            glRotatef(360.0 * float(a) / 10.f,1,0,0);   
            glTranslatef(0,2,0);
            Tube01();
         glPopMatrix();
         }
      glPopMatrix();
   glPopMatrix();   


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
Back to top
View user's profile Send private message Visit poster's website
ffelagund



Joined: 16 Mar 2006
Posts: 14

PostPosted: Wed Jul 05, 2006 2:59 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Wed Jul 05, 2006 3:12 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
memon



Joined: 03 Oct 2005
Posts: 63

PostPosted: Wed Jul 05, 2006 3:37 am    Post subject: Reply with quote

Do you set glDepthMask? Try setting it to GL_TRUE.
Back to top
View user's profile Send private message
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Wed Jul 05, 2006 4:31 am    Post subject: Reply with quote

yes, that did nothing. :(

/lar
Back to top
View user's profile Send private message Visit poster's website
ffelagund



Joined: 16 Mar 2006
Posts: 14

PostPosted: Wed Jul 05, 2006 5:22 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Wed Jul 05, 2006 5:51 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Wed Jul 05, 2006 7:54 am    Post subject: Reply with quote

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

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Wed Jul 05, 2006 9:17 am    Post subject: Reply with quote

No, its uses olny GL_TRIANGLES.

/lar
Back to top
View user's profile Send private message Visit poster's website
ffelagund



Joined: 16 Mar 2006
Posts: 14

PostPosted: Wed Jul 05, 2006 5:41 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Thu Jul 06, 2006 12:29 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Thu Jul 06, 2006 11:46 pm    Post subject: Reply with quote

Anyone? Please - its very important to me.

/lar
Back to top
View user's profile Send private message Visit poster's website
ffelagund



Joined: 16 Mar 2006
Posts: 14

PostPosted: Fri Jul 07, 2006 3:30 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message Visit poster's website
LarryTM



Joined: 04 Jul 2006
Posts: 30

PostPosted: Fri Jul 07, 2006 3:34 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
dot_blank



Joined: 28 Sep 2005
Posts: 498
Location: Brasil

PostPosted: Sat Jul 08, 2006 11:19 am    Post subject: Reply with quote

also note you have 1000000 constants
for your tube
_________________
10011011 00101010 11010111 10001001 10111010
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group