OpenGL ES 1.1 on 64 Bit

ArndvonOppenkowskiArndvonOppenkowski DEBeta ✭✭
edited September 2015 in Xamarin.iOS

Hello guys,

I am stuck migrating my game to 64bit. A 32bit build works fine on a 64bit device but a 64bit build does not.

I think the pointers are screwed up in my render method on 64 bit but I have no clue how to fix this. All I see is a black screen.

`
protected void RenderInternal()
{
FetchVertices();

        if (VertexList.Count > 0)
        {
            var vertices = VertexList.ToArray();

            // Preserve pointers during rendering:
            unsafe
            {
                fixed (Vector3* posPointer = &vertices[0].Position)
                {
                    fixed (Vector2* texPointer = &vertices[0].TexCoords)
                    {
                        fixed (Color4* colorPointer = &vertices[0].Color)
                        {
                            // Set the pointers and render the array:
                            GL.VertexPointer(TexturedColoredVertex.PositionSize, TexturedColoredVertex.PositionType, TexturedColoredVertex.Stride, (IntPtr)posPointer);
                            GL.TexCoordPointer(TexturedColoredVertex.TexturePositionSize, TexturedColoredVertex.TexturePositionType, TexturedColoredVertex.Stride, (IntPtr)texPointer);
                            GL.ColorPointer(TexturedColoredVertex.ColorSize, TexturedColoredVertex.ColorType, TexturedColoredVertex.Stride, (IntPtr)colorPointer);
                            GL.DrawArrays(PrimitiveType, 0, vertices.Length);
                        }
                    }
                }
            }
        }
}

`

Did anbody run into the same issue and can help me?

Thanks in advance

Arnd

Tagged:

Answers

  • I forgot to say that I m using interleaved vertex data.

  • Hey guys,

    I figured it out by myself. I hope that this will help you when using OpenTK with interleaved vertex data.
    The whole struct must be packed and the field offsets must be set explicitly.

    /// <summary>
    /// Textured vertex.
    /// </summary>
    [StructLayout(LayoutKind.Explicit, Pack = 1)]
    public struct TexturedColoredVertex
    {
      [FieldOffsetAttribute(0)]
      public Vector3 Position;
    
      [FieldOffsetAttribute(12)]
      public Vector2 TexCoords;
    
      [FieldOffsetAttribute(20)]
      public Color4 Color;
    }
    

    Regards Arnd

Sign In or Register to comment.