Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there an easy way to re-render dynamic vertices in OpenGL ES 2.0 so that one could, for example, make a modeling program?

I understand how to make a dynamic vertex array, but what I don't understand is how to re-render a dynamic array, I've only seen examples where you have to re-compile a shader each time you make an array.

I did find the function:

glBufferSubData();

does this update the data without having to recompile the shader?

share|improve this question
    
You can make a dynamic vertex with three floats. –  Byte56 Apr 27 '13 at 4:52
    
What Byte56 said. Making vertices dynamic is trivial. Maybe, @mathacka, you meant something else with this question? As for exporting, it depends on the structure of the file type. –  Attackfarm Apr 27 '13 at 21:47
    
What I was meaning by "Dynamic Vertices" is when, say you were to subdivide a cube, then you would add 6+4*6 vertices to the model, and anytime you'd add a face or edges to a model. I've just never seen an example of it, I thought I'd have to recompile the shader program in ES 2.0 after making new faces or vertices? –  mathacka Apr 29 '13 at 3:39
1  
Your shaders should be fairly independent of your models. Someone with more expertise might be able to offer a better answer, but I don't see why an altered model would require anything unusual with the shaders. –  Attackfarm Apr 30 '13 at 3:58
    
How are you rendering your vertices? It sounds like you're not using a vao/vbo/vetex array. –  sarahm May 1 '13 at 11:38
show 6 more comments

1 Answer 1

up vote 0 down vote accepted

The simple answer is YES. You re-render those dynamic vertices once per 'frame' and it is easy. Making a modeling program will be far from easy however.

You don't have the right notion about shaders and vertices. I think you've misunderstood the examples that you've seen. A shader is the program that draws the fragments that make up the screen. That program has two parts, once that is executed once per vertex, and one that is executed once per fragment.

Look at those examples again and trace the code better. Or put a NSLog or printf by the compile call. You'll see that it only compiles it once. If not you need to look for better teaching exaples.

Compiling a shader is something you can do ONCE at the beginning of an app. You can do more often but I never do. I have several general purpose shaders and I compile each at the start and bind the one I need to use when I need to use it. Binding a shader and compiling it are two different things.

Changing vertices dynamically is easy. I have a flag program that applies physics to a grid of vertices that make up a 'cloth' flag. I update the flag once per cycle and then to draw it I call:

    glDrawElements(GL_TRIANGLES, testFlag.m_NumIndices, GL_UNSIGNED_INT, testFlag.m_Indices);

I think you need to do a lot more research on how open gl es 2 works.

If you wanted to write a modeling program you'd have a stack of objects and properties for each one that tell how many vertices and indicies, etc. We call this type of organization a 3d Engine. Then allow users to mod them. But that will be quite the undertaking. Good Luck!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.