using StgSharp.Math;
using System;
using System.Collections.Concurrent;
namespace StgSharp.Graphics
{
public interface IglFunc
{
///
/// 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, uint 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();
///
/// Conpile the provided shader code in string form.
///
/// A string array contains all shaders' code
/// An enum represent the type of the shader to
/// conpile, including vertex shader and fragment shader.
/// An handle of conpiled shader
glHandleSet CompileShader(ShaderType shaderType, params string[] shaderCodeArray);
///
/// 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);
///
/// 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, Type type, IntPtr ptr);
///
/// Same fucntion as the OpenGL api glGenBuffers
///
///
///
unsafe void GenBuffers(uint count, glHandleSet handleSet);
///
/// Same fucnction as OpenGL api glGenTextures.
///
/// amount of textures to generate
/// Handle of texture
unsafe void GenTextures(uint count, glHandleSet handleSet);
///
/// Same fucntion as OpenGL api, glGenVertexArray
///
/// Amount of vao to be generated
/// Handle of vao sign array
unsafe void GenVertexArrays(uint count, glHandleSet handleSet);
void GetGraphicError();
///
/// Same fucntion as OpenGL api, glGetUniformLocation
///
/// Shader program to find the uniform
/// Pointer to byte array of name of the uniform
///
unsafe int GetUniformLocation(uint program, byte* ptr);
bool GetWindowShouldClose(Form form);
///
/// Make the OpenGL context of a vertain as the activated OpenGL context.
///
///
void MakeContexCurrent(Form form);
void SetBufferData(BufferType bufferType, T bufferData, BufferUsage usage) where T : IMat;
void SetBufferData(BufferType bufferType, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible;
internal void SetFrameBufferSizeCallback(IntPtr id, FrameBufferSizeHandler handler);
///
/// 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 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 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
void SetValue(Uniform uniform, float v0, float v1);
///
/// 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 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, Type t, bool normalized, uint stride, int pointer);
void SetWindowShouldClose(Form form, bool mark);
void SwapBuffers(Form form);
///
/// 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
/// pointer to data array of pixels
unsafe void TextureImage2d(uint target, int level, uint internalformat, uint width, uint height, uint format, uint type, void* pixels);
///
/// Same fucntion as OpenGL api glTexParameteri
///
/// texture target to set parameters
/// name of parameter
/// value of parameter
void TextureParameter(uint target, uint pname, int param);
///
/// Same fucntion as OpenGL api glUseShader.
///
/// Sign of program to be used
void UseProgram(uint program);
///
/// Same function as the OpenGL api, glViewPort
///
///
///
///
///
void Viewport(int x, int y, uint width, uint height);
internal void SwitchContext();
}
}