Thread: OpenGL Depth Problems

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Question OpenGL Depth Problems

    It draws only black. I'm almost completely sure that it's a depth problem. So this would be the code.


    Code:
    GLvoid ReSizeGLScene(GLsizei width, GLsizei height)	
    {
    	if (height==0)									
    	{
    		height=1;									
    	}
    
    	glViewport(0,0,width,height);						
    
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();							
    	
    	glFrustum(-1.0, 1.0, -1.0, 1.0, 0.0, 1.0);
    	glTranslatef(-2.5,2.5,3.0);
    
    	glMatrixMode(GL_MODELVIEW);					
    	glLoadIdentity();							
    }
    
    int InitGL(GLvoid)							
    {
    	loadtexture();
    	glEnable(GL_TEXTURE_2D);
    	glShadeModel(GL_SMOOTH);						
    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);			
    	glClearDepth(1.0);								
    	glEnable(GL_DEPTH_TEST);														
    	return TRUE;									
    }

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you could try using gluPerspective...

    Code:
    void gluPerspective(GLdouble fovy,
                                    GLdouble aspect,
                                    GLdouble zNear,
                                    GLdouble zFar)

  3. #3
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    gluperspective doesn't perform frustum clipping

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Originally posted by Silvercord
    gluperspective doesn't perform frustum clipping
    zNear and zFar specify the distance to the near and far clipping planes. so if its a depth problem (as droid thinks it is) the near/far clipping planes could be part of it.

  5. #5
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    I thought he had glfrustum in there because he wanted frustum clipping

  6. #6
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Originally posted by Silvercord
    I thought he had glfrustum in there because he wanted frustum clipping
    he can still have it..

    http://www.cevis.uni-bremen.de/~uwe/...rspective.html

    DESCRIPTION
    gluPerspective specifies a viewing frustum into the world coordinate system.

  7. #7
    drdroidhere
    Guest
    I tried changing it to perspective... it didn't change anything.

  8. #8
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Could you post your drawing code? It could be that you aren't swapping your buffers, or if you are using single buffered mode are you calling glFlush() at the end of your drawing routine?

    Also, make sure you are in RGBA mode, texture mapping only works in RGBA mode, and check that your texture size is a power of 2.
    Last edited by dalek; 06-19-2003 at 07:42 AM.

  9. #9
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    he got it fixed I gave him some help over IM.........it was just a matter of using perspective view over orthographic.....

  10. #10
    Registered User dalek's Avatar
    Join Date
    May 2003
    Posts
    135
    Ah cool.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Shadow Mapping Issues
    By animeaholic in forum Game Programming
    Replies: 0
    Last Post: 06-05-2007, 09:49 AM
  2. debuging help with opengl coding
    By efret in forum C++ Programming
    Replies: 2
    Last Post: 01-18-2007, 02:23 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. Problems with rotations with OpenGL and GLUT
    By darcome in forum Game Programming
    Replies: 13
    Last Post: 07-05-2002, 12:12 AM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM