• 14
• 12
• 9
• 10
• 9

# depth problem

This topic is 4789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I just started moving my cube arround and it will clip of parts of the object when I decrease my z cord. The farther I get back it gets clipped off. Like it I move it to 0.5f then parts of this is getting clipped. I looked over my code and couldn't find a problem. I have my depth buffers set up correctly. Anyone know something I should check that could be the problem? thanks vbuser

##### Share on other sites
Quote:
 Original post by vbuser1338I just started moving my cube arround and it will clip of parts of the object when I decrease my z cord. The farther I get back it gets clipped off. Like it I move it to 0.5f then parts of this is getting clipped. I looked over my code and couldn't find a problem. I have my depth buffers set up correctly. Anyone know something I should check that could be the problem?thanks vbuser

Increase your near and far plane sizes.

##### Share on other sites
Could I use gluPerspective to do this? And what is the first parameter mean?
Fovy . It says 'the field of view angle,in degrees,in the y-direction.' What would I put under this?
Thanks vbuser

##### Share on other sites
Quote:
 Original post by vbuser1338Could I use gluPerspective to do this? And what is the first parameter mean?Fovy . It says 'the field of view angle,in degrees,in the y-direction.' What would I put under this?Thanks vbuser

Try this call
gluPerspective(60.0, screen_width / screen_height, .005, 1000.0);

HTH???

##### Share on other sites

There is something I'm not getting here. I'm not sure where to place this thing. It ether does nothing or nothing shows up at all. All searches on the function have the exact same blurb. Defines the function prams and says a little about what its for. No examples of it being used.

My little level dosn't look very big right now. Need to get some more room.

##### Share on other sites
I got it working by putting 45 for the first parameter. Are you talking about where to place gluPerspective? I put it right after my call to gl_projection for my matrix in my Init function.
Thanks for the help
vbuser

##### Share on other sites
Quote:
 Original post by vbuser1338I got it working by putting 45 for the first parameter. Are you talking about where to place gluPerspective? I put it right after my call to gl_projection for my matrix in my Init function.Thanks for the help vbuser

Ok I may have to upgrade this "issue" to "problem." I'm still getting squat using the gluPerspective. It doesn't seem to care what I put in. Degrees, starting/ending depth, aspect all seem to affect nothing.

Most of my setup init code is just NeHe clepto code. I've compaired to to everything else I can find and I don't see what the diff is. So behold my init code.

int initGL(GLvoid)					{         	glMatrixMode(GL_PROJECTION);    glLoadIdentity();		    	gluPerspective(60.0f, SCREEN_WIDTH / SCREEN_HEIGHT,0.1f,500.0f);  	  	glMatrixMode(GL_MODELVIEW);					              // Select The Modelview Matrix	glLoadIdentity();							              // Reset The Modelview Matrix	        glEnable(GL_TEXTURE_2D);									// Enable Texture Mapping ( NEW )	glEnable(GL_BLEND);    glShadeModel(GL_SMOOTH);									// Enable Smooth Shading	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);						// Black Background	glClearDepth(1.0f);											// Depth Buffer Setup	glEnable(GL_DEPTH_TEST);									// Enables Depth Testing	glDepthFunc(GL_LEQUAL);										// The Type Of Depth Testing To Do	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);			// Really Nice Perspective Calculations	   	BuildDisLists();                                            //build long term lists		return TRUE;												// Initialization Went OK}//end InitGL[\source]

##### Share on other sites
Quote:
Original post by Goober King
Quote:
 Original post by vbuser1338I got it working by putting 45 for the first parameter. Are you talking about where to place gluPerspective? I put it right after my call to gl_projection for my matrix in my Init function.Thanks for the help vbuser

Ok I may have to upgrade this "issue" to "problem." I'm still getting squat using the gluPerspective. It doesn't seem to care what I put in. Degrees, starting/ending depth, aspect all seem to affect nothing.

Most of my setup init code is just NeHe clepto code. I've compaired to to everything else I can find and I don't see what the diff is. So behold my init code.

*** Source Snippet Removed ***

Where is your rendering code? If you are doing immediate mode you might have your windings wrong try CCW or CW rotations.

##### Share on other sites
Quote:
Original post by MARS_999
Quote:
Original post by Goober King
Quote:
 Original post by vbuser1338I got it working by putting 45 for the first parameter. Are you talking about where to place gluPerspective? I put it right after my call to gl_projection for my matrix in my Init function.Thanks for the help vbuser

Ok I may have to upgrade this "issue" to "problem." I'm still getting squat using the gluPerspective. It doesn't seem to care what I put in. Degrees, starting/ending depth, aspect all seem to affect nothing.

Most of my setup init code is just NeHe clepto code. I've compaired to to everything else I can find and I don't see what the diff is. So behold my init code.

*** Source Snippet Removed ***

Where is your rendering code? If you are doing immediate mode you might have your windings wrong try CCW or CW rotations.

Well here's some of it. What would matter anyway. Most of the rest is tied up in convenience functions. I really only need the simplest things. Strait on view with a little zooming in and out.

As I'm trying to look into it and seeing how it renders I'm forced to think I'm doing something wrong. Like the on high pics show it clipping at some odd angles.

Anyway some pics and code if it helps.
void DrawMainGame(void){  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);      glLoadIdentity();      glTranslatef(CameraX,CameraY,CameraZ); //set camera   glRotatef (CameraHorzRot, 0, 1, 0);   glRotatef (CameraVertRot, 1, 0, 0);           SetGL_Color(&SystemColor); //set overal color brightness.      switch(CurrentStage)   {    case LYCANROOM: DrawLycanRoom();break;    default: DrawLycanRoom();break;   }//end switch on stage               DisplayAnimeTable(SpriteBox,32);         if(CameraMode==DEBUG)glPrint(15,15 ,"Debug Camera" ,  0,0);           /* Draw it to the screen */    SDL_GL_SwapBuffers( );   }//end draw main game

Theres not much there. The levels are simple so they are just hardcoded. Drawn in its own function for clarity and Called within the switch statement. The DisplayAnimeTable is fairly complicated. Its basicly just a list of animations running. The only drawing it does is a set of quads put together to build a frame from sprites.

I didn't know I even had a problem until I started trying to build the first level. I figured I just needed to find out how to set the depth farther. Turns out thats a bit of an issue for whatever reason.