Custom C# bindings for vertex arrays

Started by
-1 comments, last by BladeWise 18 years, 10 months ago
Hi all, I am using TAO framework to create my OpenGL 3D engine, but I have a *little* problem with my custom binding to gl*Pointer functions... since I'm using Sharp3D library structures to store Vertices/Normals/TexCoord/Color data, I thought about creating a binding for this kind of data, avoiding pinning or else... but something is wrong, since even if my vertices are drawn correctly, normals and texture coords are not correct at all... copying data into a double[] and using gl*Pointer functions in the TAO binding, shows a correct result, so data is correct, but OpenGL receives messed up data... Just to add more, Vector*F and ColorF structures (the ones used in Sharp3D library) have a serial layout (I downloaded and rebuilt sources to make me sure about it)... I'll provide a snippet from my render cycle, and my bindings... hope someone could enlight me :( BINDINGS:

[DllImport("opengl32.dll",
EntryPoint="glVertexPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)]
public static extern void glVertexPointer(int size, int type, int
stride, Vector3F[] vertices);

[DllImport("opengl32.dll",
EntryPoint="glTexCoordPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)]
public static extern void glTexCoordPointer(int size, int type, int
stride, Vector2F[] coords);

[DllImport("opengl32.dll",
EntryPoint="glColorPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)]
public static extern void glColorPointer(int size, int type, int
stride, ColorF[] colors);

[DllImport("opengl32.dll",
EntryPoint="glNormalPointer"),SuppressUnmanagedCodeSecurity,CLSCompliantAttribute(true)]
public static extern void glNormalPointer(int type, int stride,
Vector3F[] normals); 

RENDER:

public virtual void Render()
{
        if(this.m_Normals!=null)
        {
                Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY);
                VGl.glNormalPointer(Gl.GL_FLOAT,0,this.m_Normals);
        }
        else
                Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY);

        Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
        VGl.glVertexPointer(3,Gl.GL_FLOAT,0,this.m_Vertices);

        Gl.glDrawArrays(this.m_FaceMode,0,this.m_Vertices.Length);

} 

Thnx in advance for every help :P

This topic is closed to new replies.

Advertisement