Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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  
  Hits and Depth Question (JOGL/OpenGL)  (Read 1301 times)
0 Members and 1 Guest are viewing this topic.
Offline Zed Gimbal

Innocent Bystander

« Posted 2009-01-23 17:43:34 »

Hi! I'm not only a new forum member, but also a new OpenGL programmer.

I'm writing a Java/JOGL application which has selecting and picking functionality, and I'm finding that, when processing hits, all of the hit objects are coming back with zero minDepth and maxDepth.

When retrieving the minDepth and maxDepth from the select buffer, I'm getting depthInt = -2147483648, which converts to a float value of 0.0 when using this algorithm:

depthFloat = 1f + (float)((long)depthInt)/0x7fffffff

(The algorithm above is borrowed from page 469 of Andrew Davison's Pro Java 6 3D Game Development.)

My understanding is that, if minDepth is 0.0, then the hit object is thought to be at the near clipping plane, and if minDepth is 1.0, then the object is thought to be at the far clipping plane.

My first thought was that perhaps the camera's frustum spans too much Z space, resulting in lower-than-needed precision when OpenGL tries to determine their depths. This doesn't seem to be a problem, though, because:

* the meshes that I'm displaying have been glScalefed to fit within a 4x4x4 cube
* the meshes all reside within the camera's frustum
* the camera's frustum has a near clipping plane distance of 1.5, and a far clipping plane distance of 20.0

After searching this forum, I stumbled across this post, which suggests that I should ensure that my select buffer should use native byte order.  My buffer is declared as follows:

IntBuffer selectBuffer = BufferUtil.newIntBuffer(4096);

According to the JOGL API JavaDoc, "the returned buffer will have its byte order set to the host platform's native byte order."  So this doesn't seem to be the problem.

The problem seems to occur regardless of the number of meshes that I display.

Does anyone have any suggestions about what I might be doing incorrectly?

Thanks in advance!
Offline Z-Knight

Senior Devvie

Medals: 2

« Reply #1 - Posted 2009-01-30 16:57:29 »

Welcome to the forum.

I can't answer your question but I wanted to give you a link to another forum that might also be of interest since you mentioned you are new to OpenGL and this might be an OpenGL issue.

Here is the forum for OpenGL that is pretty popular and I would also post there if you think an OpenGL issue is the root cause.

Good luck.
Pages: [1]
  ignore  |  Print  

EgonOlsen (47 views)
2018-06-10 19:43:48

EgonOlsen (29 views)
2018-06-10 19:43:44

EgonOlsen (49 views)
2018-06-10 19:43:20

DesertCoockie (214 views)
2018-05-13 18:23:11

nelsongames (130 views)
2018-04-24 18:15:36

nelsongames (129 views)
2018-04-24 18:14:32

ivj94 (870 views)
2018-03-24 14:47:39

ivj94 (131 views)
2018-03-24 14:46:31

ivj94 (782 views)
2018-03-24 14:43:53

Solater (146 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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 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‑
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!