public static unsafe void DeleteBuffer(uint buffer) { uint[] buffers = { buffer }; fixed(uint *ptr = &buffers[0]) GLCore.DeleteBuffers(1, ptr); }
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(); }
public static unsafe void DeleteTexture(uint texture) { uint[] textures = { texture }; fixed(uint *ptr = &textures[0]) GLCore.DeleteTextures(1, ptr); }
public static unsafe void DeleteQuery(uint query) { uint[] queries = { query }; fixed(uint *ptr = &queries[0]) GLCore.DeleteQueries(1, ptr); }
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(); }
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); }
private static int CreateCompiledSubShader(ShaderType shaderType, string subShaderCode) { uint shaderHandle = GLCore.CreateShader(shaderType); GLHelper.ShaderSource(shaderHandle, subShaderCode); GLCore.CompileShader(shaderHandle); return((int)shaderHandle); }
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); }
public static unsafe uint GenBuffer() { uint[] buffers = new uint[1]; fixed(uint *ptr = &buffers[0]) GLCore.GenBuffers(1, ptr); return(buffers[0]); }
public static unsafe uint[] GenQueries(int count) { uint[] queries = new uint[count]; fixed(uint *ptr = &queries[0]) GLCore.GenQueries(count, ptr); return(queries); }
public static unsafe uint GenQuery() { uint[] queries = new uint[1]; fixed(uint *ptr = &queries[0]) GLCore.GenQueries(1, ptr); return(queries[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); }
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]); }
public static unsafe uint GenTexture() { uint[] textures = new uint[1]; fixed(uint *ptr = &textures[0]) GLCore.GenTextures(1, ptr); return(textures[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()); }
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); }
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(); }
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()); }
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()); }
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; } }
private static void SetupFrontFaceDirection() { GLCore.FrontFace(FrontFaceDirection.Ccw); }
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); }
public void DrawLines(int vertexOffset, int verticesCount) { Shader.BindVertexDeclaration(); GLCore.DrawArrays(BeginMode.Lines, vertexOffset, verticesCount); }
public void DrawTriangles(int indexOffsetInBytes, int numberOfIndicesToRender) { Shader.BindVertexDeclaration(); GLCore.DrawElements(BeginMode.Triangles, numberOfIndicesToRender, DrawElementsType.UnsignedShort, (IntPtr)indexOffsetInBytes); }
public void SetUniformValue(int location, float r, float g, float b, float a) { GLCore.Uniform4f(location, r, g, b, a); }
public void SetUniformValue(int location, Vector3D vector) { GLCore.Uniform3f(location, vector.X, vector.Y, vector.Z); }
public void SetUniformValue(int location, Matrix matrix) { GLCore.UniformMatrix4fv(location, 1, false, matrix.GetValues); }
public void SetUniformValue(int location, float value) { GLCore.Uniform1f(location, value); }
public void SetUniformValue(int location, int value) { GLCore.Uniform1i(location, value); }
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); }