Ejemplo n.º 1
0
        public static unsafe void DeleteBuffer(uint buffer)
        {
            uint[] buffers = { buffer };

            fixed(uint *ptr = &buffers[0])
            GLCore.DeleteBuffers(1, ptr);
        }
Ejemplo n.º 2
0
        public static void BufferData <T>(BufferTarget target, int size, T[] data, BufferUsageHint usage)
        {
            GCHandle ptr = GCHandle.Alloc(data, GCHandleType.Pinned);

            GLCore.BufferData(target, (IntPtr)size, ptr.AddrOfPinnedObject(), usage);
            ptr.Free();
        }
Ejemplo n.º 3
0
        public static unsafe void DeleteTexture(uint texture)
        {
            uint[] textures = { texture };

            fixed(uint *ptr = &textures[0])
            GLCore.DeleteTextures(1, ptr);
        }
Ejemplo n.º 4
0
        public static unsafe void DeleteQuery(uint query)
        {
            uint[] queries = { query };

            fixed(uint *ptr = &queries[0])
            GLCore.DeleteQueries(1, ptr);
        }
Ejemplo n.º 5
0
        public static void BufferSubData <T>(BufferTarget target, int offset, int size, T[] data)
        {
            GCHandle ptr = GCHandle.Alloc(data, GCHandleType.Pinned);

            GLCore.BufferSubData(target, (IntPtr)offset, (IntPtr)size, ptr.AddrOfPinnedObject());
            ptr.Free();
        }
Ejemplo n.º 6
0
        private static int CreateCompiledSubShader(ShaderType shaderType, string subShaderCode)
        {
            uint shaderHandle = GLCore.CreateShader(shaderType);

            GLHelper.ShaderSource(shaderHandle, subShaderCode.Replace("precision mediump float;", ""));
            GLCore.CompileShader(shaderHandle);
            return((int)shaderHandle);
        }
Ejemplo n.º 7
0
        private static int CreateCompiledSubShader(ShaderType shaderType, string subShaderCode)
        {
            uint shaderHandle = GLCore.CreateShader(shaderType);

            GLHelper.ShaderSource(shaderHandle, subShaderCode);
            GLCore.CompileShader(shaderHandle);
            return((int)shaderHandle);
        }
Ejemplo n.º 8
0
        public int CreateIndexBuffer(int sizeInBytes, OpenGL20BufferMode mode)
        {
            uint bufferHandle = GLHelper.GenBuffer();

            GLCore.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
            GLCore.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)sizeInBytes, IntPtr.Zero, GetBufferMode(mode));
            return((int)bufferHandle);
        }
Ejemplo n.º 9
0
        public static unsafe uint GenBuffer()
        {
            uint[] buffers = new uint[1];

            fixed(uint *ptr = &buffers[0])
            GLCore.GenBuffers(1, ptr);

            return(buffers[0]);
        }
Ejemplo n.º 10
0
        public static unsafe uint[] GenQueries(int count)
        {
            uint[] queries = new uint[count];

            fixed(uint *ptr = &queries[0])
            GLCore.GenQueries(count, ptr);

            return(queries);
        }
Ejemplo n.º 11
0
        public static unsafe uint GenQuery()
        {
            uint[] queries = new uint[1];

            fixed(uint *ptr = &queries[0])
            GLCore.GenQueries(1, ptr);

            return(queries[0]);
        }
Ejemplo n.º 12
0
 public void SetUniformValues(int uniformLocation, Matrix[] matrices)
 {
     float[] values = new float[matrices.Length * 16];
     for (int matrixIndex = 0; matrixIndex < matrices.Length; ++matrixIndex)
     {
         matrices[matrixIndex].GetValues.CopyTo(values, matrixIndex * 16);
     }
     GLCore.UniformMatrix4fv(uniformLocation, matrices.Length, false, values);
 }
Ejemplo n.º 13
0
        public static unsafe uint GetQueryObjectuiv(uint query, GetQueryObjectParam param)
        {
            uint[] result = new uint[1];

            fixed(uint *ptr = &result[0])
            GLCore.GetQueryObjectuiv(query, param, ptr);

            return(result[0]);
        }
Ejemplo n.º 14
0
        public static unsafe uint GenTexture()
        {
            uint[] textures = new uint[1];

            fixed(uint *ptr = &textures[0])
            GLCore.GenTextures(1, ptr);

            return(textures[0]);
        }
Ejemplo n.º 15
0
        public static unsafe string GetShaderInfoLog(uint shader)
        {
            StringBuilder builder = new StringBuilder(1024);

            int[] length = new int[1];

            fixed(int *ptr = &length[0])
            GLCore.GetShaderInfoLog(shader, builder.Capacity, ptr, builder);

            return(builder.ToString());
        }
Ejemplo n.º 16
0
        public override void Clear()
        {
            Color color = window.BackgroundColor;

            if (color.A == 0)
            {
                return;
            }
            GLCore.ClearColor(color.RedValue, color.GreenValue, color.BlueValue, color.AlphaValue);
            GLCore.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
        }
Ejemplo n.º 17
0
 public override void SetViewport(Size viewportSize)
 {
     if (Settings.Current.StartInFullscreen)
     {
         if (!TryChangeResolution(viewportSize))
         {
             throw new ResolutionRequestFailedCouldNotFindResolution(viewportSize);
         }
     }
     GLCore.Viewport(0, 0, (int)viewportSize.Width, (int)viewportSize.Height);
     SetModelViewProjectionMatrixFor2D();
 }
Ejemplo n.º 18
0
        public static unsafe string GetActiveUniformName(uint program, uint uniformIndex)
        {
            int[]         length = new int[1];
            StringBuilder result = new StringBuilder();

            fixed(int *lenPtr = &length[0])
            {
                GLCore.GetActiveUniformName(program, uniformIndex, 2048, lenPtr, result);
            }

            return(result.ToString());
        }
Ejemplo n.º 19
0
        public static unsafe string GetActiveAttrib(uint program, uint attributeIndex, out int attributeSize, out ActiveAttribType attributeType)
        {
            int[]         length = new int[1];
            int[]         size   = new int[1];
            StringBuilder result = new StringBuilder();

            ActiveAttribType[] type = new ActiveAttribType[1];
            fixed(int *lenPtr = &length[0])
            fixed(ActiveAttribType * typePtr = &type[0])
            {
                GLCore.GetActiveAttrib(program, attributeIndex, 1024, lenPtr, size, (IntPtr)typePtr, result);
            }
            attributeSize = size[0];
            attributeType = type[0];
            return(result.ToString());
        }
Ejemplo n.º 20
0
        public override void SetBlendMode(BlendMode blendMode)
        {
            if (currentBlendMode == blendMode)
            {
                return;
            }
            currentBlendMode = blendMode;
            switch (blendMode)
            {
            case BlendMode.Opaque:
                GLCore.Disable(EnableCap.Blend);
                break;

            case BlendMode.Normal:
                GLCore.Enable(EnableCap.Blend);
                GLCore.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                GLCore.BlendEquation(BlendEquationMode.FuncAdd);
                break;

            case BlendMode.AlphaTest:
                GLCore.Disable(EnableCap.Blend);
                GLCore.Enable(EnableCap.AlphaTest);
                break;

            case BlendMode.Additive:
                GLCore.Enable(EnableCap.Blend);
                GLCore.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
                GLCore.BlendEquation(BlendEquationMode.FuncAdd);
                break;

            case BlendMode.Subtractive:
                GLCore.Enable(EnableCap.Blend);
                GLCore.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);
                GLCore.BlendEquation(BlendEquationMode.FuncReverseSubtract);
                break;

            case BlendMode.LightEffect:
                GLCore.Enable(EnableCap.Blend);
                GLCore.BlendFunc(BlendingFactorSrc.DstColor, BlendingFactorDest.One);
                GLCore.BlendEquation(BlendEquationMode.FuncAdd);
                break;
            }
        }
Ejemplo n.º 21
0
 private static void SetupFrontFaceDirection()
 {
     GLCore.FrontFace(FrontFaceDirection.Ccw);
 }
Ejemplo n.º 22
0
 public unsafe void ReadPixels(Rectangle frame, byte[] bufferToStoreData)
 {
     fixed(byte *ptr = &bufferToStoreData[0])
     GLCore.ReadPixels((int)frame.Left, (int)frame.Top, (int)frame.Width, (int)frame.Height, PixelFormat.Rgb, PixelType.UnsignedByte, (IntPtr)ptr);
 }
Ejemplo n.º 23
0
 public void DrawLines(int vertexOffset, int verticesCount)
 {
     Shader.BindVertexDeclaration();
     GLCore.DrawArrays(BeginMode.Lines, vertexOffset, verticesCount);
 }
Ejemplo n.º 24
0
 public void DrawTriangles(int indexOffsetInBytes, int numberOfIndicesToRender)
 {
     Shader.BindVertexDeclaration();
     GLCore.DrawElements(BeginMode.Triangles, numberOfIndicesToRender, DrawElementsType.UnsignedShort, (IntPtr)indexOffsetInBytes);
 }
Ejemplo n.º 25
0
 public void SetUniformValue(int location, float r, float g, float b, float a)
 {
     GLCore.Uniform4f(location, r, g, b, a);
 }
Ejemplo n.º 26
0
 public void SetUniformValue(int location, Vector3D vector)
 {
     GLCore.Uniform3f(location, vector.X, vector.Y, vector.Z);
 }
Ejemplo n.º 27
0
 public void SetUniformValue(int location, Matrix matrix)
 {
     GLCore.UniformMatrix4fv(location, 1, false, matrix.GetValues);
 }
Ejemplo n.º 28
0
 public void SetUniformValue(int location, float value)
 {
     GLCore.Uniform1f(location, value);
 }
Ejemplo n.º 29
0
 public void SetUniformValue(int location, int value)
 {
     GLCore.Uniform1i(location, value);
 }
Ejemplo n.º 30
0
 public void DefineVertexAttributeWithBytes(int attributeLocation, int numberOfByteComponents, int vertexTotalSize, int attributeOffsetInVertex)
 {
     GLCore.EnableVertexAttribArray((uint)attributeLocation);
     GLCore.VertexAttribPointer((uint)attributeLocation, numberOfByteComponents, VertexAttribPointerType.UnsignedByte, true, vertexTotalSize, (IntPtr)attributeOffsetInVertex);
 }