ufnexus.blogg.se

Opengl es 2.0 draw line
Opengl es 2.0 draw line





opengl es 2.0 draw line

And also your shader won't be adaptable that easily to a changing number of control points/curve degree at runtime.īut once again, you cannot put in 5 control points and generate N curve points on the GPU. But otherwise I don't think it really pays. If you need to compute the curve points each frame (because the control points change each frame) and the curve is rather high detail, it might not be that bad an idea. It needs to be evaluated which is the better approach. What you save is the copying of the curve points from CPU to GPU and the computation on the CPU, but on the other hand your vertex shader is much more complex. In the shader you then use this input position (the parameter value) to compute the actual 2D/3D position on the curve using the DeCasteljau algorithm (or whatever) and the points P0 to P4 which you put into the shader as constants (uniform variables in GLSL terms).īut I'm not sure if that would really buy you anything over just computing those points on the CPU and putting them into a dynamic VBO.

opengl es 2.0 draw line

What you can do is put in always the same line strip, having the curve parameter values T as 1D vertex positions.

opengl es 2.0 draw line

So you would have to draw a line strip made out of enough vertices to guarantee a smooth enough curve. The number of output vertices is always the same as the number of input vertices, you can only change their positions (and ohter attributes of course). You cannot generate new vertices inside the vertex shader (you can do it in the geometry shader, which ES doesn't have).







Opengl es 2.0 draw line