public static void PrepareForUse(VertexDeclaration vd)
        {
            GLStateManager.VertexArray(true);

            bool normal   = false;
            bool texcoord = false;

            foreach (var ve in vd.GetVertexElements())
            {
                switch (ve.VertexElementUsage)
                {
                case VertexElementUsage.Position:
                    GL11.VertexPointer(
                        ve.VertexElementFormat.OpenGLNumberOfElements(),
                        ve.VertexElementFormat.OpenGLValueType(),
                        vd.VertexStride,
                        //ve.Offset
                        (IntPtr)ve.Offset
                        );
                    break;

                case VertexElementUsage.Color:
                    GL11.ColorPointer(
                        ve.VertexElementFormat.OpenGLNumberOfElements(),
                        ve.VertexElementFormat.OpenGLValueType(),
                        vd.VertexStride,
                        //ve.Offset
                        (IntPtr)ve.Offset
                        );
                    break;

                case VertexElementUsage.Normal:
                    GL11.NormalPointer(
                        ve.VertexElementFormat.OpenGLValueType(),
                        vd.VertexStride,
                        //ve.Offset
                        (IntPtr)ve.Offset
                        );
                    normal = true;
                    break;

                case VertexElementUsage.TextureCoordinate:
                    GL11.TexCoordPointer(
                        ve.VertexElementFormat.OpenGLNumberOfElements(),
                        ve.VertexElementFormat.OpenGLValueType(),
                        vd.VertexStride,
                        //ve.Offset
                        (IntPtr)ve.Offset
                        );
                    texcoord = true;
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            GLStateManager.TextureCoordArray(texcoord);
            GLStateManager.NormalArray(normal);
        }
        public static void PrepareForUse(VertexDeclaration vd, IntPtr arrayStart)
        {
            GLStateManager.VertexArray(true);

            bool normal   = false;
            bool color    = false;
            bool texcoord = false;

            foreach (var ve in vd.GetVertexElements())
            {
                switch (ve.VertexElementUsage)
                {
                case VertexElementUsage.Position:
                    /* TODO GL.VertexPointer(
                     *  ve.VertexElementFormat.OpenGLNumberOfElements(),
                     *  ve.VertexElementFormat.OpenGLValueType(),
                     *  vd.VertexStride,
                     *  new IntPtr(arrayStart.ToInt32() + ve.Offset)
                     *  );*/
                    break;

                case VertexElementUsage.Color:
                    /* TODO GL.ColorPointer(
                     *  ve.VertexElementFormat.OpenGLNumberOfElements(),
                     *  ve.VertexElementFormat.OpenGLValueType(),
                     *  vd.VertexStride,
                     *  new IntPtr(arrayStart.ToInt32() + ve.Offset)
                     *  );*/
                    color = true;
                    break;

                case VertexElementUsage.Normal:
                    /* TODO GL.NormalPointer(
                     *  ve.VertexElementFormat.OpenGLValueType(),
                     *  vd.VertexStride,
                     *  new IntPtr(arrayStart.ToInt32() + ve.Offset)
                     *  );*/
                    normal = true;
                    break;

                case VertexElementUsage.TextureCoordinate:
                    /* TODO GL.TexCoordPointer(
                     *  ve.VertexElementFormat.OpenGLNumberOfElements(),
                     *  ve.VertexElementFormat.OpenGLValueType(),
                     *  vd.VertexStride,
                     *  new IntPtr(arrayStart.ToInt32() + ve.Offset)
                     *  );*/
                    texcoord = true;
                    break;

                default:
                    throw new NotImplementedException();
                }
            }

            GLStateManager.TextureCoordArray(texcoord);
            GLStateManager.ColorArray(color);
            GLStateManager.NormalArray(normal);
        }
Exemple #3
0
        /// <summary>
        /// 頂点宣言クラスに新しい頂点要素を追加する
        /// </summary>
        /// <param name="vertexDeclaration">追加先の頂点宣言</param>
        /// <param name="extraElements">追加する頂点要素</param>
        /// <returns>新要素追加後の頂点宣言</returns>
        public static VertexDeclaration ExtendVertexDeclaration(
            VertexDeclaration vertexDeclaration, VertexElement[] extraElements)
        {
            VertexElement[] originalElements = vertexDeclaration.GetVertexElements();

              return ExtendVertexDeclaration( vertexDeclaration.GraphicsDevice,
                                          originalElements, extraElements );
        }
        public static void PrepareForUse(VertexDeclaration vd)
        {
            GLStateManager.VertexArray(true);

            bool normal = false;
            bool texcoord = false;

            foreach (var ve in vd.GetVertexElements())
            {
                switch (ve.VertexElementUsage)
                {
                    case VertexElementUsage.Position:
                        GL11.VertexPointer(
                            ve.VertexElementFormat.OpenGLNumberOfElements(),
                            ve.VertexElementFormat.OpenGLValueType(),
                            vd.VertexStride,
                            //ve.Offset
                            (IntPtr)ve.Offset
                            );
                        break;
                    case VertexElementUsage.Color:
                        GL11.ColorPointer(
                            ve.VertexElementFormat.OpenGLNumberOfElements(),
                            ve.VertexElementFormat.OpenGLValueType(),
                            vd.VertexStride,
                            //ve.Offset
                            (IntPtr)ve.Offset
                            );
                        break;
                    case VertexElementUsage.Normal:
                        GL11.NormalPointer(
                            ve.VertexElementFormat.OpenGLValueType(),
                            vd.VertexStride,
                            //ve.Offset
                            (IntPtr)ve.Offset
                            );
                        normal = true;
                        break;
                    case VertexElementUsage.TextureCoordinate:
                        GL11.TexCoordPointer(
                            ve.VertexElementFormat.OpenGLNumberOfElements(),
                            ve.VertexElementFormat.OpenGLValueType(),
                            vd.VertexStride,
                            //ve.Offset
                            (IntPtr)ve.Offset
                            );
                        texcoord = true;
                        break;
                    default:
                        throw new NotImplementedException();
                }
            }

            GLStateManager.TextureCoordArray(texcoord);
            GLStateManager.NormalArray(normal);
        }
        public static void PrepareForUse(VertexDeclaration vd, IntPtr arrayStart)
        {
            GLStateManager.VertexArray(true);

            bool normal = false;
            bool color = false;
            bool texcoord = false;

            foreach (var ve in vd.GetVertexElements())
            {
                    switch (ve.VertexElementUsage)
                    {
                        case VertexElementUsage.Position:
                            /* TODO GL.VertexPointer(
                                ve.VertexElementFormat.OpenGLNumberOfElements(),
                                ve.VertexElementFormat.OpenGLValueType(),
                                vd.VertexStride,
                                new IntPtr(arrayStart.ToInt32() + ve.Offset)
                                );*/
                            break;
                        case VertexElementUsage.Color:
                            /* TODO GL.ColorPointer(
                                ve.VertexElementFormat.OpenGLNumberOfElements(),
                                ve.VertexElementFormat.OpenGLValueType(),
                                vd.VertexStride,
                                new IntPtr(arrayStart.ToInt32() + ve.Offset)
                                );*/
                            color = true;
                            break;
                        case VertexElementUsage.Normal:
                            /* TODO GL.NormalPointer(
                                ve.VertexElementFormat.OpenGLValueType(),
                                vd.VertexStride,
                                new IntPtr(arrayStart.ToInt32() + ve.Offset)
                                );*/
                            normal = true;
                            break;
                        case VertexElementUsage.TextureCoordinate:
                            /* TODO GL.TexCoordPointer(
                                ve.VertexElementFormat.OpenGLNumberOfElements(),
                                ve.VertexElementFormat.OpenGLValueType(),
                                vd.VertexStride,
                                new IntPtr(arrayStart.ToInt32() + ve.Offset)
                                );*/
                            texcoord = true;
                            break;
                        default:
                            throw new NotImplementedException();
                    }
            }

            GLStateManager.TextureCoordArray(texcoord);
            GLStateManager.ColorArray(color);
            GLStateManager.NormalArray(normal);
        }
Exemple #6
0
        internal InstancedModelPart( InstancedModel owner, ContentReader input,
            GraphicsDevice graphicsDevice)
        {
            this.owner = owner;

              indexCount = input.ReadInt32();
              vertexCount = input.ReadInt32();
              vertexStride = input.ReadInt32();

              vertexDeclaration = input.ReadObject<VertexDeclaration>();
              vertexBuffer = input.ReadObject<VertexBuffer>();
              indexBuffer = input.ReadObject<IndexBuffer>();

              input.ReadSharedResource<Effect>( delegate( Effect value )
              {
            Effect = value;
            effectVertexCountParam = Effect.Parameters["VertexCount"];
            effectViewParam = Effect.Parameters["View"];
            effectProjectionParam = Effect.Parameters["Projection"];
            effectEyeParam = Effect.Parameters["EyePosition"];
              } );

              originalVertexDeclaration = vertexDeclaration.GetVertexElements();
        }
Exemple #7
0
        internal static bool AreEqual(VertexDeclaration vertexDeclarationA, VertexDeclaration vertexDeclarationB)
        {
            // Compare vertex strides.
              if (vertexDeclarationA.VertexStride != vertexDeclarationB.VertexStride)
            return false;

              // Compare vertex element count.
              var vertexElementsA = vertexDeclarationA.GetVertexElements();
              var vertexElementsB = vertexDeclarationB.GetVertexElements();
              if (vertexElementsA.Length != vertexElementsB.Length)
            return false;

              // Compare each vertex element structure.
              for (int j = 0; j < vertexElementsA.Length; j++)
              {
            if (vertexElementsA[j] != vertexElementsB[j])
              return false;
              }

              return true;
        }