Ejemplo n.º 1
0
            private void SetNormalAttribute(GraphicsContext ctx)
            {
                if (ArrayBuffer != null)
                {
                    ArrayBufferObjectBase.IArraySection arraySection = ArrayBuffer.GetArraySection(ArraySectionIndex);

                    int arrayLength = (int)ArrayBufferItem.GetArrayLength(arraySection.ItemType);
                    if (arrayLength != 3)
                    {
                        throw new NotSupportedException(String.Format("normal pointer of length {0} not supported", arrayLength));
                    }

                    // Bind the array buffer
                    ArrayBuffer.Bind(ctx);

                    // Set vertex pointer
                    Gl.NormalPointer(
                        ArrayBufferItem.GetNormalPointerType(arraySection.ItemType), arraySection.Stride.ToInt32(),
                        arraySection.Pointer
                        );
                    // Enable vertex attribute
                    Gl.EnableClientState(EnableCap.NormalArray);
                }
                else
                {
                    Gl.DisableClientState(EnableCap.NormalArray);
                }
            }
Ejemplo n.º 2
0
            private void SetTexCoordAttribute(GraphicsContext ctx)
            {
                if (ArrayBuffer != null)
                {
                    ArrayBufferObjectBase.IArraySection arraySection = ArrayBuffer.GetArraySection(ArraySectionIndex);

                    int arrayLength = (int)ArrayBufferItem.GetArrayLength(arraySection.ItemType);
                    int arrayStride = arraySection.Stride.ToInt32();

                    // Bind the array buffer
                    ArrayBuffer.Bind(ctx);

                    // Set vertex pointer
                    Gl.TexCoordPointer(
                        arrayLength, ArrayBufferItem.GetTexCoordPointerType(arraySection.ItemType), arraySection.Stride.ToInt32(),
                        arraySection.Pointer
                        );
                    // Enable vertex attribute
                    Gl.EnableClientState(EnableCap.TextureCoordArray);
                }
                else
                {
                    Gl.DisableClientState(EnableCap.TextureCoordArray);
                }
            }
Ejemplo n.º 3
0
        public static void DisablePrimitiveRestart(GraphicsContext ctx)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException("ctx");
            }

            if (ctx.Caps.GlExtensions.PrimitiveRestart)
            {
                // Enable primitive restart (server state)
                Gl.Disable(EnableCap.PrimitiveRestart);
            }
            else if (ctx.Caps.GlExtensions.PrimitiveRestart_NV)
            {
                // Enable primitive restart (client state)
                Gl.DisableClientState(EnableCap.PrimitiveRestartNv);
            }
            else
            {
                throw new InvalidOperationException("primitive restart not supported");
            }
        }