Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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  
  opengl.util.BufferUtil and VBO  (Read 3577 times)
0 Members and 1 Guest are viewing this topic.
Offline blizzard

Senior Newbie





« Posted 2011-10-13 08:50:19 »

Hello

I start using VBO´s and saw different ways to initialize the buffers.
One is using the opengl.util.BufferUtil classes.

Is this the best way and where do I get it ?
thanks
Offline theagentd
« Reply #1 - Posted 2011-10-13 09:30:16 »

Yes. BufferUtil ensures that the byte buffer created is direct and that the correct byte order (native byte order) is used. It's basically equal to:
1  
ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());

Myomyomyo.
Offline blizzard

Senior Newbie





« Reply #2 - Posted 2011-10-13 10:26:08 »

Ok, thanks

but where can I download it ? It was not in the packages that I have downloaded for using jogl.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2011-10-13 13:17:38 »

Ah, you're using JOGL. BufferUtil is part of LWJGL, which is an alternative to JOGL. Personally I prefer LWJGL, but you can just make your own utility class for buffer creation. To create other buffers (FloatBuffer for example) just create a ByteBuffer (with the code I posted) with 4 times the size (as you'll need 4 bytes per float) and use asFloatBuffer().

Myomyomyo.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #4 - Posted 2011-10-13 15:56:41 »

If you're using JOGL, you don't use ByteBuffers.  You should be able to use a plain-jane array.

Offline Z-Knight

Senior Member


Medals: 1



« Reply #5 - Posted 2011-10-13 16:26:07 »

Ah, you're using JOGL. BufferUtil is part of LWJGL, which is an alternative to JOGL. Personally I prefer LWJGL, but you can just make your own utility class for buffer creation. To create other buffers (FloatBuffer for example) just create a ByteBuffer (with the code I posted) with 4 times the size (as you'll need 4 bytes per float) and use asFloatBuffer().

wait, what?!?  BufferUtil is part of JOGL... it is in: com.sun.opengl.util.BufferUtil

So this is what I usually do:
1  
vertices = ByteBuffer.allocateDirect(totalBuffer * BufferUtil.SIZEOF_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();


You also need to remember to 'rewind' the buffer, I think:

1  
vertices.rewind();
Offline ra4king

JGO Kernel


Medals: 347
Projects: 3
Exp: 5 years


I'm the King!


« Reply #6 - Posted 2011-10-13 21:35:55 »

No you don't rewind the buffer, you flip it:
1  
vertices.flip();

Offline gouessej
« Reply #7 - Posted 2011-10-13 22:13:04 »

Hi

Ok, thanks

but where can I download it ? It was not in the packages that I have downloaded for using jogl.
I assume you use an obsolete version of JOGL (JOGL 1.1.1a?). In JOGL 2.0, this class has been renamed Buffers:
http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/nio/Buffers.html

I'm sorry, I was busy and many people here gave you confusing answers. I advise you to ask questions specific to JOGL on the official JogAmp forum. Best regards.

Offline theagentd
« Reply #8 - Posted 2011-10-14 02:17:26 »

Ignore me, listen to the JOGL expert!  Yawn

Myomyomyo.
Offline blizzard

Senior Newbie





« Reply #9 - Posted 2011-10-14 07:23:03 »

Ok I ignore you ;-)

thanks for all your answers
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2011-10-14 10:08:27 »

Hi

Ignore me, listen to the JOGL expert!  Yawn
Sorry, I didn't want to be harsh with you and the class Buffers from JOGL works like the class used by our competitor you quoted.

blizzard, I hope you now understand that you don't need to download another JAR to use the class Buffers. Actually, I assume you were speaking about com.sun.opengl.utils.BufferUtils which was in JOGL 1.1.1a and renamed com.jogamp.common.nio.Buffers in JOGL 2.0.

Offline theagentd
« Reply #11 - Posted 2011-10-14 11:10:49 »

Nonono, I wasn't insulted at all, I just felt a little ashamed because I was talking out of my ass! xD

Myomyomyo.
Offline blizzard

Senior Newbie





« Reply #12 - Posted 2011-10-14 11:46:00 »

Yes I understand, I found everything  and at the moment my first VBO test programms  are running well :-)
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.

Riven (7 views)
2014-10-02 14:36:20

Pippogeek (41 views)
2014-09-24 16:13:29

Pippogeek (32 views)
2014-09-24 16:12:22

Pippogeek (22 views)
2014-09-24 16:12:06

Grunnt (47 views)
2014-09-23 14:38:19

radar3301 (30 views)
2014-09-21 23:33:17

BurntPizza (65 views)
2014-09-21 02:42:18

BurntPizza (37 views)
2014-09-21 01:30:30

moogie (44 views)
2014-09-21 00:26:15

UprightPath (53 views)
2014-09-20 20:14:06
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!