Depth buffer problem?
Hiya,
I was wondering if anyone could help me out. Ive been having some strange problems with what I can only guess is depth buffer.
Here is a picture of the problem:
As you can see, everything is visible, through everything else, some stuff is ontop and some isnt, its a very wierd effect.
Im using OpenGL and SDL together. Its the first time Ive tried SDL so maybe its something ive missed?
Yes I am clearing and enabling the depth buffer, so im not sure whats causing this problem. Can anyone help please?
Cheers,
-wolfman
That looks bad, post some code.
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
[ My Site ]
''I wish life was not so short,'' he thought. ''Languages take such a time, and so do all the things one wants to know about.'' - J.R.R Tolkien
/*ilici*/
quote:Original post by OstsolMaybe 2...and 4 bits for color? Seriously, why is this thing looking so bad? Did you convert into a 4bpp GIF? Or is it really looking that way?
Also, what is the bit depth for your depth-buffer?
Some code would be most helpful. are loading that as a model? for example from 3D Studio Max? or is it a list of vertices? if its verticies maybe you have to tell your engine to not draw surfaces that are blocked by other faces (i.e. - not veiwable thru the present frustrum) just a guess, but without code its hard to say.
r3alityc0d3r
icq: 252463839
r3alityc0d3r@hotmail.com
"I am the Architect. I created the Matrix...Your life is the sum of a remainder of an unbalanced equation inherent to the programming of the Matrix. Which has led you, inexorably... here." Great Architect - Matrix Reloaded
r3alityc0d3r
icq: 252463839
r3alityc0d3r@hotmail.com
"I am the Architect. I created the Matrix...Your life is the sum of a remainder of an unbalanced equation inherent to the programming of the Matrix. Which has led you, inexorably... here." Great Architect - Matrix Reloaded
Well I know its not in my rendering code because if I draw 2 simple quads 10 units away from eachother and rotate the scene so they overlap I get this:
Here is the code I use to setup the window:
And for setting up opengl I use:
Ive got gluPerspective running each frame because I have 2D elements as well that are drawing to the screen. However I have stopped them drawing and the same thing happens anyway so its not that interfering. Any ideas now?
-wolfman
Here is the code I use to setup the window:
CWindow::CWindow(){ if(SDL_Init(SDL_INIT_VIDEO) < 0 ) { m_pLog->write("Video initialisation failed: %s", SDL_GetError()); // Write error to log SDL_Quit(); exit(0); } m_pInfo = SDL_GetVideoInfo(); if(!m_pInfo) { m_pLog->write("Video query failed: %s", SDL_GetError()); // Write error to log SDL_Quit(); exit(0); } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); m_iFlags = SDL_OPENGL | SDL_FULLSCREEN | SDL_HWSURFACE; resize(m_iScreenWidth, m_iScreenHeight, m_iScreenBPP);}void CWindow::resize(int width, int height, int bpp){ m_iScreenWidth = width; m_iScreenHeight = height; m_iScreenBPP = bpp; if(SDL_SetVideoMode(m_iScreenWidth, m_iScreenHeight, m_iScreenBPP, m_iFlags) == 0) { m_pLog->write("Video mode change failed: %s", SDL_GetError()); // Write error to log. SDL_Quit(); exit(0); }}
And for setting up opengl I use:
CGLRenderer3D::CGLRenderer3D(){ glClearColor(0, 0, 0, 0); // Set the clear colour! glEnable(GL_DEPTH_TEST);}void CGLRenderer3D::preRender(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60, 1.3, 0, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(30,30,30, 0,0,0, 0,1,0);}
Ive got gluPerspective running each frame because I have 2D elements as well that are drawing to the screen. However I have stopped them drawing and the same thing happens anyway so its not that interfering. Any ideas now?
-wolfman
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement