Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualBCullis

Posted 14 January 2013 - 12:21 PM

This is addressing your first post.

 

 

EDIT: After about 3 hours, I've figured something out. Not sure why it's correct, but it is:



//GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedShort, indices);
//should be
GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedShort, (IntPtr)(0));

 

 

That's because the fourth element should be an offset into the "enabled" array(s) of elements.  From the OpenGL docs:

 

 

void glDrawElements(GLenum  mode,  GLsizei  count,  GLenum  type,  const GLvoid *  indices);

 

When glDrawElements is called, it uses count sequential elements from an
            enabled array, starting at indices to construct a sequence of
            geometric primitives.

 

 

I'm going to hazard a guess that there's a helper function in OpenTK that takes an array argument and converts it to an IntPtr type.  Your working version essentially states "start drawing the enabled elements, and don't skip anything"


#1BCullis

Posted 14 January 2013 - 12:20 PM

This is addressing your first post.

 

EDIT: After about 3 hours, I've figured something out. Not sure why it's correct, but it is:



//GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedShort, indices);
//should be
GL.DrawElements(BeginMode.Triangles, indices.Length, DrawElementsType.UnsignedShort, (IntPtr)(0));

 

That's because the fourth element should be an offset into the "enabled" array(s) of elements.  From the OpenGL docs:

 

When glDrawElements is called, it uses count sequential elements from an
            enabled array, starting at indices to construct a sequence of
            geometric primitives.

 

I'm going to hazard a guess that there's a helper function in OpenTK that takes an array argument and converts it to an IntPtr type.  Your working version essentially states "start drawing the enabled elements, and don't skip anything"


PARTNERS