Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  tiny mistake in an example using LWJGL on nehe.gamedev.net  (Read 1934 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej

« In padded room »



TUER


« Posted 2010-09-25 12:12:58 »

Hi

I'm sorry to disturb you with this, the email address of the author of this port is no more valid. You can find the example here:
http://nehe.gamedev.net/data/lessons/lwjgl/lesson32.jar

The depth values in the select buffer are unsigned 32-bits integer and are stored into signed 32-bits integer. Of course, when the depth is greater than 2^31, the source code stores a negative value.

The actual code is:
1  
2  
3  
temp = ByteBuffer.allocateDirect(2048).asIntBuffer();
GL11.glSelectBuffer(temp);                                // Tell OpenGL To Use Our Array For Selection
temp.get(buffer);

1  
2  
3  
4  
5  
hits = GL11.glRenderMode(GL11.GL_RENDER);                               // Switch To Render Mode, Find Out How Many
// Objects Were Drawn Where The Mouse Was
if(hits > 0) {                                               // If There Were More Than 0 Hits
    int choose = buffer[3];                                 // Make Our Selection The First Object
    int depth = buffer[1];


The last line should be modified:
1  
long depth = buffer[1] & 0xffffffffL;


Best regards.

Offline Spasi
« Reply #1 - Posted 2010-09-25 12:42:55 »

That buffer allocation should also include an order call, like so:

1  
temp = ByteBuffer.allocateDirect(2048).order(ByteOrder.nativeOrder()).asIntBuffer();


Anyway, I can't see how that code could work, since it's doing a temp.get(buffer) immediately after glSelectBuffer and before rendering anything. Or am I missing something?
Offline bobjob

JGO Knight


Medals: 10
Projects: 6


David Aaron Muhar


« Reply #2 - Posted 2010-09-25 13:25:47 »

the official nehe site LWJGL source code (AFAIK) has not been updated in a while.

I submitted a fix to lesson27 stencil shadows ages ago. and it never got updated.

My Projects
Games, Webcam chat, Video screencast, PDF tools.

Javagaming.org with chat room
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej

« In padded room »



TUER


« Reply #3 - Posted 2010-09-25 14:54:00 »

That buffer allocation should also include an order call, like so:

1  
temp = ByteBuffer.allocateDirect(2048).order(ByteOrder.nativeOrder()).asIntBuffer();


Anyway, I can't see how that code could work, since it's doing a temp.get(buffer) immediately after glSelectBuffer and before rendering anything. Or am I missing something?
This source code seems outdated and may contain other errors. If I had some time, I would have a deeper look at this example. I only noticed the common errors that I fixed several times somewhere else.

the official nehe site LWJGL source code (AFAIK) has not been updated in a while.

I submitted a fix to lesson27 stencil shadows ages ago. and it never got updated.
Maybe updating all lessons and putting the source code directly somewhere onto the official website of LWJGL would be better.

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 70
Projects: 15


★★★★★


« Reply #4 - Posted 2010-09-25 20:05:19 »

if you need a better lwjgl source code port of the nehe tutorials you can find them here. The source there is much nicer and better looking.
Offline kulpae

Senior Newbie





« Reply #5 - Posted 2010-09-25 21:19:17 »

unfortunately I can't start the webstart examples from the site, as the lwjgl-1.1.4-extension.jnlp doesn't specify lwjgl natives for linux x86_64.
Offline gouessej

« In padded room »



TUER


« Reply #6 - Posted 2010-09-25 23:11:42 »

if you need a better lwjgl source code port of the nehe tutorials you can find them here. The source there is much nicer and better looking.
You're right but there are only 25 lessons, lots of lessons are missing. Thank you for the pointer.

unfortunately I can't start the webstart examples from the site, as the lwjgl-1.1.4-extension.jnlp doesn't specify lwjgl natives for linux x86_64.
You're right. It works with 32 bits linux but when I leave the application, the process is still up.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!