Esempio n. 1
0
 public bool Link()
 {
     GlHelper.ThrowNullException(Id);
     Gl.LinkProgram(Id);
     GlHelper.GetError();
     return(Status);
 }
Esempio n. 2
0
        public static void Create(Texture[] textures, int index, int count)
        {
            if (textures == null)
            {
                throw new ArgumentNullException("textures");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", index, "index is less than 0.");
            }
            if (index + count > textures.Length)
            {
                throw new ArgumentOutOfRangeException("count", count, "index + count is greater than textures.Length.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", count, "count is less than 0.");
            }

            unsafe
            {
                uint *ids = stackalloc uint[count];
                Gl.GenTextures(count, ids);
                GlHelper.GetError();
                for (int i = 0; i < count; ++i)
                {
                    var texture = new Texture();
                    texture.Id          = ids[i];
                    textures[index + i] = texture;
                }
            }
        }
Esempio n. 3
0
 public bool Compile()
 {
     GlHelper.ThrowNullException(Id);
     Gl.CompileShader(Id);
     GlHelper.GetError();
     return(Status);
 }
Esempio n. 4
0
        public static void Create(Query[] queries, int index, int count)
        {
            if (queries == null)
            {
                throw new ArgumentNullException("queries");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", index, "index is less than 0.");
            }
            if (index + count > queries.Length)
            {
                throw new ArgumentOutOfRangeException("count", count, "index + count is greater than queries.Length.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", count, "count is less than 0.");
            }

            unsafe
            {
                uint *ids = stackalloc uint[count];
                Gl.GenQueries(count, ids);
                GlHelper.GetError();
                for (int i = 0; i < count; ++i)
                {
                    var query = new Query();
                    query.Id           = ids[i];
                    queries[index + i] = query;
                }
            }
        }
Esempio n. 5
0
        public static void Create(VertexArray[] arrays, int index, int count)
        {
            if (arrays == null)
            {
                throw new ArgumentNullException("arrays");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", index, "index is less than 0.");
            }
            if (index + count > arrays.Length)
            {
                throw new ArgumentOutOfRangeException("count", count, "index + count is greater than arrays.Length.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", count, "count is less than 0.");
            }

            unsafe
            {
                uint *ids = stackalloc uint[count];
                Gl.GenVertexArrays(count, ids);
                GlHelper.GetError();
                for (int i = 0; i < count; ++i)
                {
                    var array = new VertexArray();
                    array.Id          = ids[i];
                    arrays[index + i] = array;
                }
            }
        }
Esempio n. 6
0
        public static void Create(Buffer[] buffers, int index, int count)
        {
            if (buffers == null)
            {
                throw new ArgumentNullException("buffers");
            }
            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index", index, "index is less than 0.");
            }
            if (index + count > buffers.Length)
            {
                throw new ArgumentOutOfRangeException("count", count, "index + count is greater than buffers.Length.");
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", count, "count is less than 0.");
            }

            unsafe
            {
                uint *ids = stackalloc uint[count];
                Gl.GenBuffers(count, ids);
                GlHelper.GetError();
                for (int i = 0; i < count; ++i)
                {
                    var buffer = new Buffer();
                    buffer.Id          = ids[i];
                    buffers[index + i] = buffer;
                }
            }
        }
Esempio n. 7
0
 public void VertexAttributePointer(int size, DataType type, bool normalized, int stride, int offset)
 {
     unsafe
     {
         Gl.VertexAttribPointer(Index, size, (uint)type, (byte)(normalized ? 1 : 0), stride, (void *)offset);
         GlHelper.GetError();
     }
 }
Esempio n. 8
0
 public static void SetUniform(int location, Ibasa.Numerics.Matrix4x3f value)
 {
     unsafe
     {
         Gl.UniformMatrix4x3fv(location, 1, 0, (float *)(&value));
         GlHelper.GetError();
     }
 }
Esempio n. 9
0
 public static void SetUniform(int location, Ibasa.Interop.UnmanagedArray <Ibasa.Numerics.Vector4ui> value)
 {
     unsafe
     {
         Gl.Uniform4uiv(location, value.Count, (uint *)value.Pointer.ToPointer());
         GlHelper.GetError();
     }
 }
Esempio n. 10
0
 public static void SetUniform(int location, Ibasa.Interop.UnmanagedArray <int> value)
 {
     unsafe
     {
         Gl.Uniform1iv(location, value.Count, (int *)value.Pointer.ToPointer());
         GlHelper.GetError();
     }
 }
Esempio n. 11
0
 public void GetBufferSubData(long offset, long size, IntPtr data)
 {
     unsafe
     {
         Gl.GetBufferSubData(Target, (void *)offset, (void *)size, data.ToPointer());
         GlHelper.GetError();
     }
 }
Esempio n. 12
0
 public void BufferData(long size, IntPtr data, Usage usage)
 {
     unsafe
     {
         Gl.BufferData(Target, (void *)size, data.ToPointer(), (uint)usage);
         GlHelper.GetError();
     }
 }
Esempio n. 13
0
 public static void SetUniform(int location, Ibasa.Interop.UnmanagedArray <Ibasa.Numerics.Matrix4x3f> value)
 {
     unsafe
     {
         Gl.UniformMatrix4x3fv(location, value.Count, 0, (float *)value.Pointer.ToPointer());
         GlHelper.GetError();
     }
 }
Esempio n. 14
0
 public static void DrawElements(PrimitiveTopology topology, int count, DataType type, int offset, int basevertex)
 {
     unsafe
     {
         Gl.DrawElementsBaseVertex((uint)topology, count, (uint)type, (void *)offset, basevertex);
         GlHelper.GetError();
     }
 }
Esempio n. 15
0
 public static void DrawElements(PrimitiveTopology topology, int count, DataType type, IntPtr indices, int basevertex)
 {
     unsafe
     {
         Gl.DrawElementsBaseVertex((uint)topology, count, (uint)type, indices.ToPointer(), basevertex);
         GlHelper.GetError();
     }
 }
Esempio n. 16
0
 public void Delete()
 {
     GlHelper.ThrowNullException(Id);
     unsafe
     {
         uint id = Id;
         Gl.DeleteVertexArrays(1, &id);
     }
 }
Esempio n. 17
0
 public IntPtr Map(MapAccess access)
 {
     unsafe
     {
         var result = Gl.MapBuffer(Target, (uint)access);
         GlHelper.GetError();
         return(new IntPtr(result));
     }
 }
Esempio n. 18
0
 public static Sync Fence()
 {
     unsafe
     {
         var handle = Gl.FenceSync(Gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
         GlHelper.GetError();
         return(new Sync(new IntPtr(handle)));
     }
 }
Esempio n. 19
0
 public override bool Equals(object obj)
 {
     GlHelper.ThrowNullException(Target);
     if (obj is TextureBinding)
     {
         return(Equals((TextureBinding)obj));
     }
     return(false);
 }
Esempio n. 20
0
 public override bool Equals(object obj)
 {
     GlHelper.ThrowNullException(Id);
     if (obj is VertexArray)
     {
         return(Equals((VertexArray)obj));
     }
     return(false);
 }
Esempio n. 21
0
 public override bool Equals(object obj)
 {
     GlHelper.ThrowNullException(Handle);
     if (obj is Sync)
     {
         return(Equals((Sync)obj));
     }
     return(false);
 }
Esempio n. 22
0
 public override bool Equals(object obj)
 {
     GlHelper.ThrowNullException(Id);
     if (obj is Shader)
     {
         return(Equals((Shader)obj));
     }
     return(false);
 }
Esempio n. 23
0
 public void Delete()
 {
     GlHelper.ThrowNullException(Id);
     unsafe
     {
         uint id = Id;
         Gl.DeleteBuffers(1, &id);
     }
 }
Esempio n. 24
0
        public void Unmap()
        {
            bool result = Gl.UnmapBuffer(Target) != 0;

            GlHelper.GetError();
            if (!result)
            {
                throw new OpenGLException("glUnmapBuffer returned false.");
            }
        }
Esempio n. 25
0
 public void Delete()
 {
     unsafe
     {
         GlHelper.ThrowNullException(Handle);
         Gl.DeleteSync(Handle.ToPointer());
         Handle = IntPtr.Zero;
         GlHelper.GetError();
     }
 }
Esempio n. 26
0
 public static Shader Create(ShaderType type)
 {
     unsafe
     {
         uint id = Gl.CreateShader((uint)type);
         GlHelper.GetError();
         var shader = new Shader();
         shader.Id = id;
         return(shader);
     }
 }
Esempio n. 27
0
 public static Program Create()
 {
     unsafe
     {
         uint id = Gl.CreateProgram();
         GlHelper.GetError();
         var program = new Program();
         program.Id = id;
         return(program);
     }
 }
Esempio n. 28
0
 public static Texture Create()
 {
     unsafe
     {
         uint id;
         Gl.GenTextures(1, &id);
         GlHelper.GetError();
         var texture = new Texture();
         texture.Id = id;
         return(texture);
     }
 }
Esempio n. 29
0
 public static Buffer Create()
 {
     unsafe
     {
         uint id;
         Gl.GenBuffers(1, &id);
         GlHelper.GetError();
         var buffer = new Buffer();
         buffer.Id = id;
         return(buffer);
     }
 }
Esempio n. 30
0
 public static VertexArray Create()
 {
     unsafe
     {
         uint id;
         Gl.GenVertexArrays(1, &id);
         GlHelper.GetError();
         var array = new VertexArray();
         array.Id = id;
         return(array);
     }
 }