Пример #1
0
        public static VBO Create(int position_dimensions, VertexAttributes attribs)
        {
            VBO v = new VBO();

            GL.GenBuffers(1, out v.PositionArrayBufferID);
            GL.GenBuffers(1, out v.OtherArrayBufferID);
            GL.GenBuffers(1, out v.ElementArrayBufferID);
            v.PositionDimensions = position_dimensions;
            v.VertexAttribs      = attribs;
            return(v);
        }
Пример #2
0
        public static VertexAttributes Create(params int[] counts)          //makes zeroed arrays in the given counts.
        {
            VertexAttributes v = new VertexAttributes();
            int count          = counts.GetLength(0);

            v.Defaults  = new float[count][];
            v.Size      = new int[count];
            v.TotalSize = 0;
            int idx = 0;

            foreach (int i in counts)
            {
                v.Defaults[idx] = new float[i];                 //todo: this method needs a note:  which attribs are assumed to be here already? if you Create(2), is that texcoords? and what?
                v.Size[idx]     = i;
                v.TotalSize    += i;
                ++idx;
            }
            return(v);
        }
Пример #3
0
        public static VertexAttributes Create(params float[][] defaults)
        {
            VertexAttributes v = new VertexAttributes();
            int count          = defaults.GetLength(0);

            v.Defaults  = new float[count][];
            v.Size      = new int[count];
            v.TotalSize = 0;
            int idx = 0;

            foreach (float[] f in defaults)
            {
                v.Defaults[idx] = f;
                v.Size[idx]     = f.GetLength(0);
                v.TotalSize    += v.Size[idx];
                ++idx;
            }
            return(v);
        }
        ///<param name="filename">Note that filename is required even if passing a byte[], because filename is used as the key to identify duplicate textures</param>
        ///<param name="source">Whether to load the texture from file path, from an embedded resource in the entry assembly, or from 'textureBytes'</param>
        ///<param name="textureBytes">Used only if source == TextureLoadSource.FromByteArray</param>
        public static Surface Create(GLWindow window, string texture_filename, TextureMinFilter minFilter, TextureMagFilter magFilter,
                                     TextureLoadSource source, byte[] textureBytes, string frag_shader, bool has_depth, params int[] vertex_attrib_counts)
        {
            Surface s = new Surface();

            s.window = window;
            int dims = has_depth? 3 : 2;

            s.UseDepthBuffer = has_depth;
            VertexAttributes attribs = VertexAttributes.Create(vertex_attrib_counts);

            s.vbo     = VBO.Create(dims, attribs);
            s.texture = Texture.Create(texture_filename, null, minFilter, magFilter, source, textureBytes);
            s.shader  = Shader.Create(frag_shader);
            if (window != null)
            {
                window.Surfaces.Add(s);
            }
            return(s);
        }