开发者

Java: BufferUtil?

I'm trying to 开发者_StackOverflow中文版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?


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)


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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜