Jump to content
  • Advertisement
Sign in to follow this  
BladeWise

OpenGL Custom C# bindings for vertex arrays

This topic is 4868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!