Example #1
0
        /// <summary>
        /// Create a <see cref="ArrayBufferObjectBase"/> for testing.
        /// </summary>
        /// <returns>
        /// It returns the <see cref="ArrayBufferObjectBase"/> instance to test.
        /// </returns>
        private void CreateGpuInstance(BufferObject buffer)
        {
            if (buffer.GetType() == typeof(ArrayBufferObject))
            {
                ArrayBufferObject arrayBufferObject = (ArrayBufferObject)buffer;

                arrayBufferObject.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ElementBufferObject))
            {
                ElementBufferObject elementBufferObject = (ElementBufferObject)buffer;

                elementBufferObject.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ArrayBufferObjectInterleaved))
            {
                ArrayBufferObjectInterleaved arrayBufferObjectInterleaved = (ArrayBufferObjectInterleaved)buffer;

                arrayBufferObjectInterleaved.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ArrayBufferObjectPacked))
            {
                ArrayBufferObjectPacked arrayBufferObjectPacked = (ArrayBufferObjectPacked)buffer;

                arrayBufferObjectPacked.Create(_Context, CreateTestArray());
            }
        }
Example #2
0
            /// <summary>
            /// Allocate an instance of the type.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating the instance.
            /// </param>
            /// <returns>
            /// It returns an instance of a specific type.
            /// </returns>
            public override object Allocate(GraphicsContext ctx)
            {
                ElementBufferObject arrayBufferObject = new ElementBufferObject(DrawElementsType.UnsignedInt);

                arrayBufferObject.Create(16);

                return(arrayBufferObject);
            }
Example #3
0
            /// <summary>
            /// Allocate an instance of the type mocked for spying.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating the instance.
            /// </param>
            /// <returns>
            /// It returns an instance of a specific type.
            /// </returns>
            public override T AllocateSpy <T>(GraphicsContext ctx)
            {
                T elementBufferObjectSpy = (T)CreateTypeSpy(_InstanceType, DrawElementsType.UnsignedInt);
                ElementBufferObject elementBufferObject = elementBufferObjectSpy as ElementBufferObject;

                if (elementBufferObject != null)
                {
                    elementBufferObject.Create(16);
                }

                return(elementBufferObjectSpy);
            }
Example #4
0
        /// <summary>
        /// Create a <see cref="ArrayBufferObjectBase"/> for testing.
        /// </summary>
        /// <returns>
        /// It returns the <see cref="ArrayBufferObjectBase"/> instance to test.
        /// </returns>
        private void CreateClientInstance(BufferObject buffer)
        {
            if (buffer.GetType() == typeof(ArrayBufferObject))
            {
                ArrayBufferObject arrayBufferObject = (ArrayBufferObject)buffer;

                arrayBufferObject.Create(CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ElementBufferObject))
            {
                ElementBufferObject elementBufferObject = (ElementBufferObject)buffer;

                elementBufferObject.Create(CreateTestArray());
            }
        }
Example #5
0
        private void Initialize(float[] vertexes, uint[] indices, Action bindAttributes)
        {
            _vao = new VertexArrayObject();

            _vao.Bind();

            _vbo = new VertexBufferObject(vertexes);

            if (indices != null)
            {
                _ebo = new ElementBufferObject(indices);
            }

            bindAttributes();

            _vao.Unbind();
        }
Example #6
0
        private ElementBufferObject InitElementArrayBufferForLaterUse(int[] data, DrawElementsType type)
        {
            // Create a buffer object
            ElementBufferObject buffer = new ElementBufferObject();

            GL.GenBuffers(1, out buffer.id);
            if (buffer.id < 0)
            {
                Logger.Append("Failed to create the buffer object");
                return(null);
            }
            // Write date into the buffer object
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, buffer.id);
            GL.BufferData(BufferTarget.ElementArrayBuffer, data.Length * sizeof(float), data, BufferUsageHint.StaticDraw);

            buffer.type = type;

            return(buffer);
        }
Example #7
0
 private void CreateBackgroundConeBuffers(Vertex[] vertices)
 {
     //first set up the attributes
     BufferObjects.VertexAttribute[] attribute = new BufferObjects.VertexAttribute[3];
     attribute[0] = new BufferObjects.VertexAttribute("position", 3, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                      Vertex.Size, 0);
     attribute[1] = new BufferObjects.VertexAttribute("normal", 3, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                      Vertex.Size, Vector3.SizeInBytes);
     attribute[2] = new BufferObjects.VertexAttribute("texcoord", 2, OpenTK.Graphics.OpenGL.VertexAttribPointerType.Float,
                                                      Vertex.Size, 2 * Vector3.SizeInBytes);
     BGvao = new VertexArrayObject <Vertex>();
     BGvbo = new VertexBufferObject <Vertex>(Vertex.Size, vertices);
     BGvbo.CreateBuffer(BufferUsageHint.StaticDraw);
     BGvao.SetAttributes(BGvbo, shaderMgr.GetShader("BackgroundNoFog"), attribute);
     BGvao.Bind();
     // create the EBO
     int[] EBOindices = new int[]
                        #region
     { 0, 1, 3, 2,
       2, 3, 5, 4,
       4, 5, 7, 6,
       6, 7, 9, 8,
       8, 9, 11, 10,
       10, 11, 13, 12,
       12, 13, 15, 14,
       14, 15, 17, 16,
       16, 17, 19, 18,
       18, 19, 21, 20,
       20, 21, 23, 22,
       22, 23, 25, 24,
       24, 25, 27, 26,
       26, 27, 29, 28,
       28, 29, 31, 30,
       30, 31, 33, 32,
       32, 33, 35, 34,
       34, 35, 37, 36,
       36, 37, 39, 38,
       38, 39, 41, 40,
       40, 41, 43, 42,
       42, 43, 45, 44,
       44, 45, 47, 46,
       46, 47, 49, 48,
       48, 49, 51, 50,
       50, 51, 53, 52,
       52, 53, 55, 54,
       54, 55, 57, 56,
       56, 57, 59, 58,
       58, 59, 61, 60,
       60, 61, 63, 62,
       62, 63, 1, 0 };
     #endregion
     //side walls
     BGSideWallebo = new ElementBufferObject(EBOindices);
     BGSideWallebo.CreateBuffer(BufferUsageHint.StaticDraw);
     EBOindices = null;
     //caps
     EBOindices = new int[]
                  #region
     {
         0, 2, 64,
         2, 4, 64,
         4, 6, 64,
         6, 8, 64,
         8, 10, 64,
         10, 12, 64,
         12, 14, 64,
         14, 16, 64,
         16, 18, 64,
         18, 20, 64,
         20, 22, 64,
         22, 24, 64,
         24, 26, 64,
         26, 28, 64,
         28, 30, 64,
         30, 32, 64,
         32, 34, 64,
         34, 36, 64,
         36, 38, 64,
         38, 40, 64,
         40, 42, 64,
         42, 44, 64,
         44, 46, 64,
         46, 48, 64,
         48, 50, 64,
         50, 52, 64,
         52, 54, 64,
         54, 56, 64,
         56, 58, 64,
         58, 60, 64,
         60, 62, 64,
         62, 0, 64,
         65, 3, 1,
         65, 5, 3,
         65, 7, 5,
         65, 9, 7,
         65, 11, 9,
         65, 13, 11,
         65, 15, 13,
         65, 17, 15,
         65, 19, 17,
         65, 21, 19,
         65, 23, 21,
         65, 25, 23,
         65, 27, 25,
         65, 29, 27,
         65, 31, 29,
         65, 33, 31,
         65, 35, 33,
         65, 37, 35,
         65, 39, 37,
         65, 41, 39,
         65, 43, 41,
         65, 45, 43,
         65, 47, 45,
         65, 49, 47,
         65, 51, 49,
         65, 53, 51,
         65, 55, 53,
         65, 57, 55,
         65, 59, 57,
         65, 61, 59,
         65, 63, 61,
         65, 1, 63,
     };
     #endregion
     BGCapsebo = new ElementBufferObject(EBOindices);
     BGCapsebo.CreateBuffer(BufferUsageHint.StaticDraw);
     BGvao.UnBind();
     BGvbo.UnBind();
     BGSideWallebo.Unbind();
     BGCapsebo.Unbind();
 }