PDA

View Full Version : bezier



appdeveloper
10-23-2009, 09:26 AM
I'm trying to create a bezier curve, based on the "OpenGL Red Book" and the site
http://www.ia.hiof.no/~borres/cgraph/math/bezier/p-bezier.html
For some reason i get a red line across the screen in the x axis.
i'm using:
Gl.glOrtho(0, 2500, 0, 2500, -4.0, 4.0)
and when i render the scene i'm using for the bezier curves the following code (att: my 0:0 is the left, bottom side of the screen, since i'm using the simpleOpenGLControl):

ctrlpoints(0, 0) = 40.0
ctrlpoints(0, 1) = 40.0
ctrlpoints(0, 2) = 0.0


ctrlpoints(1, 0) = 20.0
ctrlpoints(1, 1) = 400.0
ctrlpoints(1, 2) = 0.0

ctrlpoints(2, 0) = 200.0
ctrlpoints(2, 1) = 40.0
ctrlpoints(2, 2) = 0.0


ctrlpoints(3, 0) = 400.0
ctrlpoints(3, 1) = 400.0
ctrlpoints(3, 1) = 0.0

Gl.glMap1f(Gl.GL_MAP1_VERTEX_3, CSng(0.0), CSng(1.0), 3, 4, ctrlpoints.GetHashCode)
Gl.glEnable(Gl.GL_MAP1_VERTEX_3)
Gl.glShadeModel(Gl.GL_FLAT)
Gl.glColor3f(1.0, 0.0, 0.0)
Gl.glBegin(Gl.GL_LINE_STRIP)
For i = 0 To 30
Gl.glEvalCoord1f(CSng(i / 30.0))
Next

Gl.glEnd()


What am i doing wrong? why isn't there any bezier curve, and instead there is a line?

appdeveloper
10-26-2009, 07:40 AM
looks like the middle, array coordinates

ctrlpoints(1, 0) = 20.0
ctrlpoints(1, 1) = 400.0
ctrlpoints(1, 2) = 0.0

ctrlpoints(2, 0) = 200.0
ctrlpoints(2, 1) = 40.0
ctrlpoints(2, 2) = 0.0

aren't being used