Depth Test dont work

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Depth Test dont work

Martin128890435
Hello guys, I asked this Question in a other Thread, but because I still dont know how to fix this problem im doing a new Thread so more people can see  it and it may could help other people too. So my problem is that Depth Test is not working (and btw I switched from my old Gameloop to a Fps Animator it still dont works.) and I dont know where the problem is in the following im trying to show you the important parts of my code:
http://pastebin.com/aA60cwav 
http://de.pastebin.de/40869
Its not the whole Game but I think these are the most important parts atm I dont use Shaders Light or something like that only Triangles and Quads.
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

gouessej
Administrator
Hi

Don't call glClear and the rest of the OpenGL code several times in display(GLAutoDrawable). Good luck.

Edit.: Please don't name your variables in German otherwise only a very few people will understand your source code except maybe Sven, Mickael (native speakers) and me (non native speakers). Promise me to show me your zombies here and maybe on Java-Gaming.org.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

Martin128890435
I feel like a retard, but I cant solve the problem you say I should not call glclear etc several times in display but I only call them once per frame?
And btw if im finished I will post the game.
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

gouessej
Administrator
You call the OpenGL methods several times per frame as they are in your while loop (line 146):
while (frameMillis>frameTime){
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

Martin128890435
But if I do it like this with just an FPS Animator, or with my own game loop it still dont works :(
http://pastebin.com/NGBKQCeT
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

gouessej
Administrator
Then, I advise you to start from something very simple, use my example on Wikipedia:
http://en.wikipedia.org/wiki/Java_OpenGL#Code_example

Run it as is. Check that it works. Inject your modifications piece by piece, step by step and check each time it still works in order to find which thing breaks your game. If you directly start with something complicated, it will never work, you'll never find what is wrong.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

Martin128890435
Thank you very much this time I got it. Depth test works now I dont know the exactly reason but it looks like //gl.glMatrixMode(GL2.GL_PROJECTION); and something in my init and reshape method caused this.
:)
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

gouessej
Administrator
You called gluLookAt on the projection matrix :s weird...
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Depth Test dont work

Wade Walker
Administrator
In reply to this post by gouessej
gouessej wrote
Run it as is. Check that it works. Inject your modifications piece by piece, step by step and check each time it still works in order to find which thing breaks your game. If you directly start with something complicated, it will never work, you'll never find what is wrong.
This is extremely good advice :)