Java: BufferUtil?
Asked Answered
A

4

10

I'm trying to use this class with JOGL. It references BufferUtil, which I can't find anywhere. I found documentation, but no actual code. Eclipse doesn't suggest to import it from anywhere. What do I have to do to be able to use this code?

Aubreyaubrie answered 19/9, 2010 at 17:43 Comment(4)
Have you added a reference to the jogl.jar file to your project?Pantechnicon
Yes. Other JOGL classes, like GL2, work fine.Aubreyaubrie
There's no jogl.jar in JOGL 2.0, it's named jogl.all.jar. There's another JAR with no AWT dependency.Frame
jogl.all.jar has been renamed jogl-all.jarFrame
E
10

In NeHe tutorials for JOGL, there are many places using BufferUtil to create the buffers. With JOGL 2.0 we can use com.jogamp.common.nio.Buffers instead.

For example,

BufferUtil.newIntBuffer(BUFSIZE) becomes Buffers.newDirectIntBuffer(BUFSIZE) BufferUtil.newByteBuffer(BUFSIZE) becomes Buffers.newDirectByteBuffer(BUFSIZE)

Equivocal answered 8/5, 2011 at 6:43 Comment(2)
Rather use com.jogamp.common.nio.Buffers to do that. GLBuffers is mostly for internal use, it should even not be in the public API.Frame
I updated this answer according to @gouessej's comment that we should not use com.jogamp.opengl.util.GLBuffers class.Algie
F
2

JOGL doc is rather here and here.

Use Buffers instead of BufferUtil: com.jogamp.common.nio.Buffers

TextureIO has been moved into the package com.jogamp.opengl.util.texture.TextureIO in JOGL 2.0. It is not a new class, it was already in JOGL 1.1.0.

Frame answered 25/9, 2010 at 13:24 Comment(0)
C
1

I ran into the same problem while porting a JOGL 1.x app to JOGL 2 and found BufferUtil equivalent methods in the new gluegen library: com.jogamp.common.nio.Buffers

JavaDoc: http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/nio/Buffers.html

Catenary answered 16/12, 2010 at 5:59 Comment(0)
D
-1

I think they pulled BufferUtil a while back (it looks like it never did anything super useful anyway) but since the code just allocates a new ByteBuffer, you don't need it. Just do a ByteBuffer unpackedPixels = ByteBuffer.allocate(packedPixels.length * bytesPerPixel); instead.

There's also a newer JOGL class that does something similar called com.jogamp.opengl.util.texture.TextureIO with a few newTexture(...) methods.

Danedanegeld answered 20/9, 2010 at 12:47 Comment(2)
TextureIO absolutely replaces exactly what this class is trying to do. Just ignore this class and use the built-in TextureIO.Intertidal
Your suggestion is wrong because you create an indirect byte buffer potentially not respecting the native order. We should always use the helper class Buffers to avoid doing it. Badly allocated buffers may cause problems, some methods only supports direct NIO buffers.Frame

© 2022 - 2024 — McMap. All rights reserved.