Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problems with hidden surface removal  (Read 2944 times)
0 Members and 1 Guest are viewing this topic.
Offline karatemarkel

Junior Devvie





« Posted 2004-03-18 11:28:08 »

I posted this last night then promptly deleted it after I realized I didn't call glEnable(GL_DEPTH_TEST) Roll Eyes, but after just having another go today I still can't seem to get the depth test to work properly, so I'm getting pixels that should be obscured from view being drawn to the screen. I tried the same code in jogl and it works fine and draws the model correctly. I had the same problem with JCD lwjgl buda demo.

Any ideas what's causing this, is it something I'm doing wrong or is it a problem with lwjgl?

Thanks for your help
Offline Orangy Tang

JGO Kernel


Medals: 57
Projects: 11


Monkey for a head


« Reply #1 - Posted 2004-03-18 11:41:41 »

1. Check glGetInteger with GL11.GL_DEPTH_BITS to check you're actually getting a depth buffer.
2. Perhaps check you've got your face culling correct, both for the mode you've set and whatever model you're rendering.
3. You might be getting z-fighting from lack of precision. Try pushing your front plane outwards somewhat to see if that helps (or request a greater accuracy in your depth buffer).
4. Check you're actually clearing the depth buffer at the start of the frame.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline karatemarkel

Junior Devvie





« Reply #2 - Posted 2004-03-18 13:07:13 »

Ok here's the code I'm using, I used the FullScreenWindowedTest that came with lwjgl for the main setup stuff, the main bulk of the original code hasn't been changed, except that the window now only loads up at 800/600.

The parts that have been changed now look like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
         private void glInit() 
       {
                  GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                  GL11.glViewport(0, 0, 800, 600);
                  GL11.glEnable(GL11.GL_CULL_FACE);
                  GL11.glEnable(GL11.GL_DEPTH_TEST);
                  GL11.glCullFace(GL11.GL_BACK);
                  GL11.glMatrixMode(GL11.GL_PROJECTION);
                  GL11.glLoadIdentity();
                  GL11.glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 300.0f);
                  GL11.glMatrixMode(GL11.GL_MODELVIEW);
            }

        private void render()
        {
                 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
                 GL11.glLoadIdentity();
                 GL11.glTranslatef(x, y, z);
                 GL11.glScalef(scaleValue, scaleValue, scaleValue);
                 GL11.glRotatef(angle, 0.0f, 1.0f, 0.0f);
                 drawModel(GL11.GL_POLYGON);
        }

The draw model method is nothing fancy, it just draws a model. I've tried the same code in a jogl using JCD's jogl work frame and the model is drawn without any problems.

cheers
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

« JGO Spiffy Duke »


Medals: 976
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2004-03-18 13:31:04 »

What about the window init code?

Cas Smiley

Offline karatemarkel

Junior Devvie





« Reply #4 - Posted 2004-03-18 16:02:56 »

Sorry, the window init code is exactly the same as in the FullScreenWindowedTest example, I had changed it earlier and though I was still using that version but I'm not.
Offline Java Cool Dude

Senior Devvie




Java forever


« Reply #5 - Posted 2004-03-18 16:08:30 »

GL11.glCullFace(GL11.GL_BACK);
Try taking that bit out
Offline karatemarkel

Junior Devvie





« Reply #6 - Posted 2004-03-18 16:22:32 »

Just tried it, no joy, its seems to be drawing the screen in a certain order as some objects do draw on top of others, even when there behind them Smiley

Its just like the GL11.GL_DEPTH_BUFFER_BIT isn't being called?
Offline elias

Senior Devvie





« Reply #7 - Posted 2004-03-18 16:58:10 »

Well, the FullscreenWindowedTest use 0 for stencil, alpha and depth. Try passing something != 0 for the depth argument. It should work then.

- elias

Offline karatemarkel

Junior Devvie





« Reply #8 - Posted 2004-03-18 18:01:48 »

Nice one elias, down in one Wink

I had no idea the window creation was that tied into the opengl system, should of looked through the source  Roll Eyes

Btw, what's the recommended value for depth, is one satisfactory for most cases?

Cheers

I can now return to the red book with an annoyingly happy face Grin
Offline princec

« JGO Spiffy Duke »


Medals: 976
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2004-03-18 20:52:05 »

16

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline karatemarkel

Junior Devvie





« Reply #10 - Posted 2004-03-19 10:56:48 »

Cheers Cas, is I wasn't such an impatient git I'd probably be able to answer my own questions, well, some anyway  Smiley
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (17 views)
2017-11-21 16:21:00

xxMrPHDxx (11 views)
2017-11-21 16:14:31

xxMrPHDxx (14 views)
2017-11-21 16:10:57

Ecumene (114 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (248 views)
2017-08-02 12:28:51

cybrmynd (247 views)
2017-08-02 12:19:43

cybrmynd (244 views)
2017-08-02 12:18:09

Sralse (258 views)
2017-07-25 17:13:48

Archive (878 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!