Z
zhilko
Hi,
I'm from C/C++ world and now having troubles converting my old C++
code to C#
The OpenGL function is declared as
void glMultMatrixd( const GLdouble *m );
In C++, I use the code
//-------------------class definition
class CMatrix
{
public: double xx, yx, zx, x0;
double xy, yy, zy, y0;
double xz, yz, zz, z0;
double px, py, pz, w1;
.....
}
//--------------------using
CMatrix myMatrix
glMultMatrixd(&myMatrix.xx)
For C# I'm using the OpenGL wrapper from
http://nehe.gamedev.net/counter.asp?file=files/basecode/nehegl_csharp.zip
I'm trying to use it in such way:
//------------------------definition
namespace MyFormProject
{
public class Matrix
{
public double xx, yx, zx, x0,
xy, yy, zy, y0,
xz, yz, zz, z0,
px, py, pz, w1;
.....
}
}
// -----------------------------wrapper imports OpenGL functions
[DllImport(GL_DLL,EntryPoint ="glMultMatrixd")]
public static extern void glMultMatrixd(double[] m);
// ----------------------using
private unsafe void Draw(Matrix m)
{
fixed (double* d = &m.xx)
{
GL.glMultMatrixd (d); // compiler error!
}
}
This causes the compiler error "Cannot convert double * to double []".
How to do it correctly?
Thanx in advance
Roman.
I'm from C/C++ world and now having troubles converting my old C++
code to C#
The OpenGL function is declared as
void glMultMatrixd( const GLdouble *m );
In C++, I use the code
//-------------------class definition
class CMatrix
{
public: double xx, yx, zx, x0;
double xy, yy, zy, y0;
double xz, yz, zz, z0;
double px, py, pz, w1;
.....
}
//--------------------using
CMatrix myMatrix
glMultMatrixd(&myMatrix.xx)
For C# I'm using the OpenGL wrapper from
http://nehe.gamedev.net/counter.asp?file=files/basecode/nehegl_csharp.zip
I'm trying to use it in such way:
//------------------------definition
namespace MyFormProject
{
public class Matrix
{
public double xx, yx, zx, x0,
xy, yy, zy, y0,
xz, yz, zz, z0,
px, py, pz, w1;
.....
}
}
// -----------------------------wrapper imports OpenGL functions
[DllImport(GL_DLL,EntryPoint ="glMultMatrixd")]
public static extern void glMultMatrixd(double[] m);
// ----------------------using
private unsafe void Draw(Matrix m)
{
fixed (double* d = &m.xx)
{
GL.glMultMatrixd (d); // compiler error!
}
}
This causes the compiler error "Cannot convert double * to double []".
How to do it correctly?
Thanx in advance
Roman.