View Full Version : Moving vertices in Programmable Pipeline
08-22-2012, 02:43 PM
So I have a simple OpenGL program up and running that draws a square using the programmable pipeline. How do I actually tell the vertices to change their location? Do I edit the vertices in the VBO? If so, how exactly would I do this?
08-22-2012, 06:36 PM
...draws a square using the programmable pipeline. How do I actually tell the vertices to change their location? Do I edit the vertices in the VBO? If so, how exactly would I do this?
It would help to know what the cause of the location change was to advise you best.
Some of your choices include: modify the input OBJECT-SPACE vertex position attributes in the VBO, or analytically modify the vertex positions in a shader. The latter might be accomplished by changing your MODELVIEW transform (MODELING and/or VIEWING transform) and/or your PROJECTION transform, or performing some kind of analytical OBJECT-SPACE movement, animation, or instancing on your object vertices in the shaders such as particle system behavior, geometry instancing, extrusion, decaling, morphing, skinning, etc.
08-23-2012, 03:55 PM
So, I did a little research, and I guess I should be using a translation Matrix. The issue I have is that I don't want to move a set amount, I want to be able to hand OpenGL it's new coordinates. So instead of telling it to move 10 units on the X axis, I want to tell it to move a specific point. Essentially, I am getting the final location from my physics engine. I suppose I could compute the necessary units to move by doing something like (finalPosition = oldPosition - newPosition), but it seems like there would be a simpler way than to do that.
08-23-2012, 08:59 PM
If all the vertices are to be translated by a fixed amount a translation matrix is a good option. If each vertex is to change a different amount, modifying or re-creating the VBO will be better. If the vertex has a lot of other information you can save bus time by having a separate buffer that has the offsets.
08-23-2012, 09:27 PM
Basically, I have a aphysics engine (Box2D) that does my physics calculations. Any time an object moves in Box2D, I want to translate the corresponding square in OpenGL. I realize that a translation is the way to go, but for a translation you essentially move an object a certain distance in a certain direction IE using a vector. Is there an efficient way to force a new location?
08-24-2012, 05:15 AM
Doesn't your physics engine give you a matrix so that you can pass it along to GL? That's what other physics engines do such as Newton Dynamics and ODE. I though it was a pretty common thing for all physics engines.
Anyway, if you want to update vertices in your VBO, here are some tips
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.