Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (803)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
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  
  Trouble understanding VBOs  (Read 8880 times)
0 Members and 1 Guest are viewing this topic.
Offline shadowstryker
« Posted 2015-07-05 02:31:31 »

I'm finally getting into the rendering of my MORPG, but I'm having a lot of trouble with learning how to use VBOs...

I just have a couple questions when it comes to VBOs:

First question: when I get to monsters/players and stuff, I will have many objects that all need to render the same texture/model/etc. However, they will all have different positions and such. As a result, do I need to create separate VBOs for every entity I have in the game, or is there a way to use a single VBO for the objects using the same texture/model/etc.? If so, how?

Second, how would I do animation with VBOs? Do I just have a VBO for each frame of the animation and iterate through them? Seems inefficient, but I don't know...
Offline LukeD

Senior Newbie


Medals: 1



« Reply #1 - Posted 2015-07-05 02:32:47 »

What is a VBO? I'm not all that familiar with terminology.

Are you making a 2D, or 3D game?
Offline Jesse

JGO Coder


Medals: 23



« Reply #2 - Posted 2015-07-05 02:46:17 »

What is a VBO? I'm not all that familiar with terminology.

'Vertex buffer object'. The term is used in reference to OpenGL, although the same concept (and maybe the term as well) is used elsewhere as well.

First question: when I get to monsters/players and stuff, I will have many objects that all need to render the same texture/model/etc. However, they will all have different positions and such. As a result, do I need to create separate VBOs for every entity I have in the game, or is there a way to use a single VBO for the objects using the same texture/model/etc.? If so, how?

This was just being discussed in another thread. A way to use the same VBO(s) and a single draw call for a large group of entities is to pre-transform the geometry. For 2-d games, where entity geometry tends to consist of simple quads, this is fairly straightforward. But, you mentioned animation with respect to VBOs, so maybe you have something else in mind. So as LukeD asked, maybe you could provide some more info on what you're doing exactly.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #3 - Posted 2015-07-05 02:48:13 »

It's completely normal to upload data to a VBO each frame and only use it once. There's a hint you can use while creating/uploading data to the VBO using glBufferData(), GL_STREAM_DRAW, just for this purpose.

Myomyomyo.
Offline shadowstryker
« Reply #4 - Posted 2015-07-05 03:12:32 »

What is a VBO? I'm not all that familiar with terminology.

Are you making a 2D, or 3D game?

It's a 3D game, however it will have 2D graphics that are used in the GUIs. I'm trying to make a game similar to Runescape, if you know what that is.
Offline Jesse

JGO Coder


Medals: 23



« Reply #5 - Posted 2015-07-05 03:22:41 »

It's a 3D game, however it will have 2D graphics that are used in the GUIs. I'm trying to make a game similar to Runescape, if you know what that is.

What kind of animation are you doing? (E.g. keyframes, interpolated keyframes, skeletal, etc...)
Offline shadowstryker
« Reply #6 - Posted 2015-07-05 05:31:03 »

I have no clue yet, I've never done animation before. I took up this project of mine because it'd be (and so far has definitely proven to be!) a great learning experience for me. Would you recommend a specific style? I was thinking I'd use Blender (I parse my models from blender .obj files) to create the animation, and then modify my parser to accommodate for Blender animation. I have no clue how I will go about this, but right now I just need to get VBOs sorted out. Smiley
Offline Jesse

JGO Coder


Medals: 23



« Reply #7 - Posted 2015-07-05 06:19:57 »

I have no clue yet, I've never done animation before. I took up this project of mine because it'd be (and so far has definitely proven to be!) a great learning experience for me. Would you recommend a specific style? I was thinking I'd use Blender (I parse my models from blender .obj files) to create the animation, and then modify my parser to accommodate for Blender animation. I have no clue how I will go about this, but right now I just need to get VBOs sorted out. Smiley

Here's a possible starting point. (This is just what first comes to mind - others may offer different advice.)

- Simple keyframe animation might be the simplest place to start, if you're comfortable generating that sort of content. (Later you could look into interpolation if you want a smoother effect.)

- Don't worry about batching or grouping multiple meshes in the same VBO to begin with. Just use a separate VBO for each animation frame, and bind the correct one as needed, as you mentioned in your first post.

This would be a good start, and would allow you to get VBOs working without too much complexity.

Once you've got that working, there are some improvements you could make. First, even with no other changes, grouping draw calls by render state (textures, shaders, etc.) can be a worthwhile optimization even if the number of draw calls is the same, due to the reduced state changes. As for number of draw calls, unless you're targeting limited platforms or will have many entities rendered each frame, you might be able to get away with no further batching (that is, each entity can still be a separate draw call).

You may find that a VBO per animation frame leaves you with a lot of VBOs, which can introduce both memory and performance overhead. To address this, you can store multiple meshes in a single VBO. Here's the first thing I found on Google - no guarantees it's a good reference (it's a few years old), but those are the kinds of techniques you'd use, I think.

There are other more complicated approaches, but it seems like the above would be a good start (others may offer different suggestions though).

Edit: Note also that if the texture coordinates for all frames of an animation are the same, you can use a single VBO for the texture coordinates, and then one VBO per frame for the positions.
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (397 views)
2019-09-04 15:33:17

hadezbladez (5280 views)
2018-11-16 13:46:03

hadezbladez (2204 views)
2018-11-16 13:41:33

hadezbladez (5544 views)
2018-11-16 13:35:35

hadezbladez (1150 views)
2018-11-16 13:32:03

EgonOlsen (4584 views)
2018-06-10 19:43:48

EgonOlsen (5462 views)
2018-06-10 19:43:44

EgonOlsen (3119 views)
2018-06-10 19:43:20

DesertCoockie (4015 views)
2018-05-13 18:23:11

nelsongames (4708 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04: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!