Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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  
  Slice()ing a Buffer doesn't preserve byte ordering  (Read 843 times)
0 Members and 1 Guest are viewing this topic.
Offline elias

Senior Member





« Posted 2003-06-23 21:47:09 »

I stumpled upon the problem while porting lwjgl to Buffers instead of pointers. The bug is described here

http://developer.java.sun.com/developer/bugParade/bugs/4715166.html

(the emphasis is on duplicate() but slice is mentioned too)

At first I simply used the workaround mentioned (set the order after each slicing), but the really annoying part comes when you want to slice your Int-Float-Whatever-else-than-ByteBuffers; byte order can't be changed on those! It forces me to stash the original ByteBuffers and slice those instead, ordering and then converting to the right type. And this is annoying when you just wanted to index into an existing buffer the way you could do address + offset in the pointer-lwjgl days.

- elias

Offline princec
« League of Dukes »

JGO Kernel


Medals: 196
Projects: 3


Eh? Who? What? ... Me?


« Reply #1 - Posted 2003-06-23 23:59:13 »

Yeah, I came across this major fecking annoyance as well. And let me tell you how long it takes to discover why nothing is rendering. GRRRRRRRRRRR. It's no big deal to remember to call order(ByteOrder.nativeOrder()) on all your sliced/duped buffers of course - until you forget once and it all goes pear shaped.

What price security eh?

Cas :|

Offline elias

Senior Member





« Reply #2 - Posted 2003-06-24 12:30:13 »

Forgetting is one thing, but how about those Int or FloatBuffers that can't change byte ordering? What is one to do about those?

- elias

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

JGO Kernel


Medals: 196
Projects: 3


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-06-24 14:10:01 »

Well, don't forget that you only do this slicing business once, at resource initialisation, so fiddly it might be but at least it's not common. And it's probably easily wrappable in a class to handle the details for you. It shouldn't be this way of course but it's only a minor grumble.

Cas Smiley

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

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (89 views)
2013-05-17 21:29:12

alaslipknot (98 views)
2013-05-16 21:24:48

gouessej (128 views)
2013-05-16 00:53:38

gouessej (123 views)
2013-05-16 00:17:58

theagentd (134 views)
2013-05-15 15:01:13

theagentd (121 views)
2013-05-15 15:00:54

StreetDoggy (163 views)
2013-05-14 15:56:26

kutucuk (185 views)
2013-05-12 17:10:36

kutucuk (187 views)
2013-05-12 15:36:09

UnluckyDevil (194 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.104 seconds with 20 queries.