//----------------------------------------------------------------------- //----------------------------------------------------------------------- // file="IglFunc.cs" // Project: StgSharp // AuthorGroup: Nitload Space // Copyright (c) Nitload Space. All rights reserved. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the “Software”), to deal in the Software without restriction, // including without limitation the rights to use, copy, modify, merge, // publish, distribute, sublicense, and/or sell copies of the Software, // and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and // this permission notice shall be included in all copies // or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED “AS IS”, // WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH // THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // //----------------------------------------------------------------------- //----------------------------------------------------------------------- using StgSharp.Math; using System; using System.Collections.Concurrent; using System.ComponentModel.Design; namespace StgSharp.Graphics { public interface IglFunc { internal unsafe GLcontext* Context { get; } /// /// Same function as OpenGL api glActiveTexture /// /// type of texture to activate void ActiveTexture(uint type); /// /// Operation after alignment by calling . /// No calling of this method is acceptable, but it will bring the risk /// of that relevant code will not run if it is interrupted by frame overtime. /// Please call this method immediately after calling , /// too early or sonner may cause . /// /// The form used as frame update benchmark. /// Operation after frame update alignment. /// The action binded to a wrong alignment. void AfterAlign(Form form, Action action); /// /// Align a sets of code to frame update of a . /// Usually, a call of is required. /// This method is used as sigle thread method. If more than one /// alignment is requested, a will throw. /// /// The form used as frame update benchmark. /// More than one alingment attached to one form timer void AlignFrame(Form form); /// /// Same fucntion as OpenGL api glAttachShader. /// Only the first in handle /// will be attached to the first in handle. /// The rest shader and program will be ignored. /// /// Shader program to be attachec /// A shader part to attach void AttachShader(glHandle program, glHandle shader); //TODO:BindBuffer注释没写完 /// /// Bind the indexed buffer object to certain type of buffer /// /// /// void BindBuffer(BufferType bufferType, glHandle handle); /// /// Same function as OpenGL api, glBindTexture. /// /// Type of texture to bind /// Sign of texture void BindTexture(uint type, glHandle texture); /// /// Same function as OpenGL api, glBindVertexArray /// /// void BindVertexArray(glHandle index); /// /// Clear buffers to preset values /// /// void Clear(MaskBufferBit mask); /// /// Call apiClearColor in OpenGL /// specifies the red, green, blue, and alpha values used by apiClear to clear the color buffers. /// Values specified by apiClearColor are clamped to the range [0,1] /// /// Specify the red values used when the color buffers are cleared. /// Specify the red values used when the color buffers are cleared. /// Specify the red values used when the color buffers are cleared. /// Specify the red values used when the color buffers are cleared. void ClearColor(float R, float G, float B, float A); void ClearGraphicError(); void CompileShader(glHandle shaderhandle); /// /// Same function as OpenGL api, glCreateProgram /// /// A handle representing a single shader program glHandle CreateProgram(); /// /// Same function as OpenGL api, glCreateProgram. /// Used for creating multiple shader program. /// /// A handle representing all shader programs glHandleSet CreateProgram(int count); glHandleSet CreateShaderSet(int count, ShaderType type); /// /// Creates a form and its associated /// /// Required width /// Required width /// Tittle of the window /// /// /// IntPtr CreateWindowHandle(int width, int height, string tittle, IntPtr monitor, Form share); glHandle CreatGraphicProgram(); /// /// Same function as OpenGL api, glDeleteBuffer. This method can delete one buffer in one call /// /// a handle representing the buffer to be deleted void DeleteBuffer(glHandle handle); /// /// Same function as OpenGL api, glDeleteBuffer. This method can delete a sets of buffers in one call. /// /// Array of buffers to be deleted unsafe void DeleteBuffers(glHandleSet handleSet); /// /// Same function as OpenGL api, glDeleteVertexArrays /// /// Handle of vertex objects. unsafe void DeleteVertexArrays(glHandleSet handleSet); /// /// /// /// /// /// /// void DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr); /// /// Same fucntion as the OpenGL api glGenBuffers /// /// /// unsafe glHandleSet GenBuffers(int count); /// /// Same fucnction as OpenGL api glGenTextures. /// /// amount of textures to generate unsafe glHandleSet GenTextures(int count); /// /// Same fucntion as OpenGL api, glGenVertexArray /// /// Amount of vao to be generated unsafe glHandleSet GenVertexArrays(int count); /// /// Same fucntion as OpenGL api, glGetUniformLocation /// /// Shader program to find the uniform /// Name of the uniform /// unsafe glSHandle GetUniformLocation(glHandle program, string name); bool GetWindowShouldClose(Form form); void LoadShaderSource(glHandle shaderHandle, string codeStream); /// /// Make the OpenGL context of a certain as the activated OpenGL context. /// /// void MakeContexCurrent(Form form); void SetBufferData(BufferType bufferType, T bufferData, BufferUsage usage) where T : struct, IMat; void SetBufferData(BufferType bufferType, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible; /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// A packing four parameters of the uniform void SetValue(Uniform uniform, Vec4d vec); /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The value to be set void SetValue(Uniform uniform, float v0); /// /// Set data value to a int , /// all types of parameters are int. /// /// The target /// The value to be set void SetValue(Uniform uniform, int i0); /// /// Set data value to a float , /// all types of parameters are . /// /// The target /// A value of the uniform void SetValue(Uniform uniform, Vec4d vec); /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set void SetValue(Uniform uniform, float v0, float v1); /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set /// The third value to be set void SetValue(Uniform uniform, float v0, float v1, float v2); /// /// Set data value to a float , /// all types of parameters are float. /// /// The target /// The first value to be set /// The second value to be set /// The third value to be set /// The forth value to be set void SetValue(Uniform uniform, float v0, float v1, float v2, float v3); /// /// Set how a shader parameter read data from a VBO. /// /// Serial number of the parameter /// Amount of data each elements contains /// Type of data read by shader /// /// Pixels stride of each sets of data /// void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer); /// /// Same function as OpenGL api glTexImage2d /// /// texture target to load image in /// level of mipmap, 0 if default /// OpenGL's internal color channel format /// width of image /// height of image /// color channels of this image /// how this image express each pixel /// data array of pixels unsafe void TextureImage2d(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels) where T : struct; /// /// Same fucntion as OpenGL api glTexParameteri /// /// texture target to set parameters /// name of parameter /// value of parameter void TextureParameter(int target, uint pname, int param); /// /// Same fucntion as OpenGL api glUseShader. /// /// Sign of program to be used void UseProgram(glHandle program); /// /// Same function as the OpenGL api, glViewPort /// /// /// /// /// void Viewport(int x, int y, uint width, uint height); internal void frameworkHandleEnqueue(IntPtr handle, params M128[] param); internal void SwitchContext(); } }