Bezier Curve issue
-
Hi all, 4 points are defined as follows:
float[,] ctrlpoints = new float [4,3] {{ -4.0f, -4.0f, 0.0f }, { -2.0f, 4.0f, 0.0f }, { 2.0f, -4.0f, 0.0f }, { 4.0f, 4.0f, 0.0f }};
When the 4 points are called in following method:
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
OpenGL gl = openGLControl.OpenGL;// Clear the color and depth buffer. gl.Clear(OpenGL.GL\_COLOR\_BUFFER\_BIT | OpenGL.GL\_DEPTH\_BUFFER\_BIT); int i; gl.Color(1.0f, 1.0f, 1.0f); gl.Begin(OpenGL.GL\_LINE\_STRIP); for (i = 0; i <= 30; i++) { gl.EvalCoord1((float)i / 30.0); } gl.End(); // display the control points gl.PointSize(5.0f); gl.Color(1.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL\_POINTS); for (i = 0; i < 4; i++) { gl.Vertex(&ctrlpoints\[i\]\[0\]); } gl.End(); gl.Flush();
}
The &ctrlpoints[i][0] in gl.Vertex(&ctrlpoints[i][0]) was displayed to be an error. How to fix the problem? Thanks!
-
Hi all, 4 points are defined as follows:
float[,] ctrlpoints = new float [4,3] {{ -4.0f, -4.0f, 0.0f }, { -2.0f, 4.0f, 0.0f }, { 2.0f, -4.0f, 0.0f }, { 4.0f, 4.0f, 0.0f }};
When the 4 points are called in following method:
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
OpenGL gl = openGLControl.OpenGL;// Clear the color and depth buffer. gl.Clear(OpenGL.GL\_COLOR\_BUFFER\_BIT | OpenGL.GL\_DEPTH\_BUFFER\_BIT); int i; gl.Color(1.0f, 1.0f, 1.0f); gl.Begin(OpenGL.GL\_LINE\_STRIP); for (i = 0; i <= 30; i++) { gl.EvalCoord1((float)i / 30.0); } gl.End(); // display the control points gl.PointSize(5.0f); gl.Color(1.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL\_POINTS); for (i = 0; i < 4; i++) { gl.Vertex(&ctrlpoints\[i\]\[0\]); } gl.End(); gl.Flush();
}
The &ctrlpoints[i][0] in gl.Vertex(&ctrlpoints[i][0]) was displayed to be an error. How to fix the problem? Thanks!
Which language are you using? Most of your syntax looks like C#, but
&ctrlpoints[i][0]
looks like C++ (or possibly C# in anunsafe
context). If it's C#, what's the signature of theVertex
method in the Object Browser?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Hi all, 4 points are defined as follows:
float[,] ctrlpoints = new float [4,3] {{ -4.0f, -4.0f, 0.0f }, { -2.0f, 4.0f, 0.0f }, { 2.0f, -4.0f, 0.0f }, { 4.0f, 4.0f, 0.0f }};
When the 4 points are called in following method:
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
OpenGL gl = openGLControl.OpenGL;// Clear the color and depth buffer. gl.Clear(OpenGL.GL\_COLOR\_BUFFER\_BIT | OpenGL.GL\_DEPTH\_BUFFER\_BIT); int i; gl.Color(1.0f, 1.0f, 1.0f); gl.Begin(OpenGL.GL\_LINE\_STRIP); for (i = 0; i <= 30; i++) { gl.EvalCoord1((float)i / 30.0); } gl.End(); // display the control points gl.PointSize(5.0f); gl.Color(1.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL\_POINTS); for (i = 0; i < 4; i++) { gl.Vertex(&ctrlpoints\[i\]\[0\]); } gl.End(); gl.Flush();
}
The &ctrlpoints[i][0] in gl.Vertex(&ctrlpoints[i][0]) was displayed to be an error. How to fix the problem? Thanks!
-
Hi all, 4 points are defined as follows:
float[,] ctrlpoints = new float [4,3] {{ -4.0f, -4.0f, 0.0f }, { -2.0f, 4.0f, 0.0f }, { 2.0f, -4.0f, 0.0f }, { 4.0f, 4.0f, 0.0f }};
When the 4 points are called in following method:
private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e)
{
// Get the OpenGL object.
OpenGL gl = openGLControl.OpenGL;// Clear the color and depth buffer. gl.Clear(OpenGL.GL\_COLOR\_BUFFER\_BIT | OpenGL.GL\_DEPTH\_BUFFER\_BIT); int i; gl.Color(1.0f, 1.0f, 1.0f); gl.Begin(OpenGL.GL\_LINE\_STRIP); for (i = 0; i <= 30; i++) { gl.EvalCoord1((float)i / 30.0); } gl.End(); // display the control points gl.PointSize(5.0f); gl.Color(1.0f, 1.0f, 0.0f); gl.Begin(OpenGL.GL\_POINTS); for (i = 0; i < 4; i++) { gl.Vertex(&ctrlpoints\[i\]\[0\]); } gl.End(); gl.Flush();
}
The &ctrlpoints[i][0] in gl.Vertex(&ctrlpoints[i][0]) was displayed to be an error. How to fix the problem? Thanks!
Didn't you understand the answer to your previous question http://www.codeproject.com/Messages/4850994/How-to-write-an-element-address-of-array-in-Csharp.aspx[^]? You must use the
unsafe
keyword and use its respective compiler option.