Hello everyone
I want to draw a Bezier curve by using JOGL. In the class showing bellow, I display my 8 control points (that’s okay for them) in red and my Bezier curve in blue. The problem is that my curve starts from the first point (nice !) but doesn’t finish at the last point. Moreover, the result of the curve is not really what I have expected.
Here’s a part of the class :
class Renderer implements GLEventListener, KeyListener {
private float [][]ctrlpts = new float [8][3];
public void display(GLDrawable gLDrawable) {
final GL gl = gLDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT);
gl.glColor3f((float)0, (float)0, (float)1);
gl.glBegin(gl.GL_LINE_STRIP);
for (int i=0; i<=100; i++)
gl.glEvalCoord1f((float)(i/100));
gl.glEnd();
gl.glPointSize((float)5);
gl.glColor3f((float)1, (float)0, (float)0);
gl.glBegin(gl.GL_POINTS);
for (int i=0; i<8; i++)
gl.glVertex3fv(ctrlpts[i]);
gl.glEnd();
gl.glFlush();
}
public void displayChanged(GLDrawable gLDrawable, boolean modeChanged, boolean deviceChanged) {
}
public void init(GLDrawable gLDrawable) {
final GL gl = gLDrawable.getGL();
ctrlpts = buildPts();
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glMap1f(GL.GL_MAP1_VERTEX_3, (float)0, (float)1, 3, ctrlpts.length, ctrlpts[0]);
gl.glEnable(GL.GL_MAP1_VERTEX_3);
}
public void reshape(GLDrawable gLDrawable, int x, int y, int width, int height) {
final GL gl = gLDrawable.getGL();
final GLU glu = gLDrawable.getGLU();
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluOrtho2D(-50, width, -50, height);
gl.glMatrixMode(gl.GL_MODELVIEW);
}
Thank you very much for your answers !
Bye bye